drafter 0.3.0
drafter: ^0.3.0 copied to clipboard
A premium, dependency-free Flutter charting library with ~27 chart types, smooth Catmull-Rom curves, soft gradient fills and a left-to-right reveal.
Changelog #
0.3.0 #
Added #
- Interactivity — a new
InteractiveChartwrapper turns any chart into a touch/mouse-driven one: a trackball with a de-overlapping multi-series tooltip, tap value-selection, and drag range-selection, all painted on a non-rebuilding Canvas overlay so the base chart's reveal animation is never disturbed. Works across every chart type — cartesian charts (line/area/step/bar/candlestick/ stream) get a trackball-column tooltip + range band; radial and free-layout charts (pie/donut/polar/sunburst/treemap/heatmap/funnel/bullet/box-plot/bubble/ gantt/sankey/scatter/radar) get per-mark hover highlighting. ChartInteractionconfig — independently toggletooltip,selectionandrangeSelection, withonSelected/onRangeSelectedcallbacks and a customrowLabeltooltip formatter.- Public interaction model —
ChartScene,PlotMark,ChartSelection,ChartRange(frompackage:drafter/drafter.dart) and the pureChartHitTest/LabelLayouthelpers (frompackage:drafter/painting.dart), so you can hit-test custom charts. Renderers opt in via theInteractiveRendererinterface and abuildScene(Size)derived from the same math they paint with. CartesianScale— a reversible data↔pixel mapping shared by paint and hit-test, so the two can never drift.- Every chart widget (and
InteractiveChart) now exposes adurationparameter to tune the entrance-animation length. ChartRenderer/InteractiveRendererare now re-exported from the mainpackage:drafter/drafter.dartentrypoint (they appear inInteractiveChart's signature).DrafterLegend— a reusable, theme-aware legend widget. Build it from explicitLegendItems or from a list of labels (DrafterLegend.fromLabels, which colors each entry by the active theme palette). Supports horizontal (wrapping) or vertical layout,square/circle/linemarkers, and an optionalonItemTapcallback for wiring series toggling.
Fixed #
- Robustness — non-finite (
NaN/Infinity) input values are now coerced at ingestion across all value-based charts, so malformed data can no longer produce a non-finiteCanvascoordinate (a debug assert) or reach atoInt()(which threwUnsupportedErroreven in release builds — histogram binning, bubble axis rounding, line/bar axis steps). InteractiveChartresets its interaction state when itsrendererchanges, so a stale selection highlight can't linger over new data, and it no longer writes to its disposed notifier if the pointer exits during teardown.
Performance #
- The interaction overlay only repaints when the resolved hover/selection state
actually changes (value-equal snapshots), is isolated in its own
RepaintBoundary, and hit-tests by squared distance. - Layout-heavy renderers (heatmap, treemap, sankey, candlestick moving-averages) memoize their progress-independent layout per size instead of recomputing it on every animation frame; candlestick moving averages now use an O(n) sliding window.
Documentation #
- The full public API is now documented (every constructor, field and getter),
enforced by enabling
public_member_api_docsin the analyzer.
0.2.0 #
Added #
ScatterPlot.values(values: [(x, y), …])— a values-first convenience constructor matching the line/area/bar charts.package:drafter/painting.dart— a dedicated entrypoint for the chart-authoring extension API (ChartRenderer,ChartCanvas, layout math, smooth-graphics helpers), keeping the maindrafter.dartnamespace focused on charts/data/theme.
Changed (breaking) #
- The low-level drawing/layout helpers (
smoothPath,trimPath,drawChartText,ChartBounds,RadialLayout,HAlign/VAlign, etc.) are no longer exported frompackage:drafter/drafter.dart— importpackage:drafter/painting.dartinstead. The everyday chart widgets, data models and theming are unchanged.
Fixed #
BubbleChartno longer crashes (debug assert via a non-finiteOffset) when every bubble shares a zero on an axis.DrafterThemeColors==/hashCodenow include thepalette, so a palette-only theme change correctly repaints the charts.colorAtfalls back instead of throwing on an empty palette.ChartCanvasnow picks up a changeddurationon rebuild.
Performance #
- Static label text is cached (
TextPainters are no longer re-shaped every animation frame), the painter repaints off the animation listenable inside aRepaintBoundary, line charts compute path metrics once per frame instead of twice, and the stream graph no longer builds its top spline twice per band.
0.1.0 #
Initial release — a premium, dependency-free Flutter charting library, a faithful port of the Compose/SwiftUI Drafter charts.
- ~27 chart types across one shared core: line, grouped line, stacked line, area, step line, simple/grouped/stacked bar, histogram, waterfall, pie, donut, radar, polar area, gauge, scatter, bubble, heatmap, funnel, bullet, box plot, treemap, sunburst, sankey, gantt, stream graph and candlestick.
- Renderer architecture: every chart is a pure
ChartRendererdrawing into aCanvas, hosted by a thin widget over shared data models, axis/radial math, Catmull-Rom smooth graphics and a left-to-right reveal animation. DrafterTheme/DrafterThemeColorsfor light/dark palettes — a calm, premium color set (no harsh red).- Built-in semantics: each chart exposes an accessibility label and value.