feat: chart interactivity, non-finite robustness, and full API docs (0.3.0) - #2
Merged
Merged
Conversation
Interactivity (opt-in, zero new deps): - InteractiveChart wrapper + ChartInteraction config (tooltip/trackball, tap-select, drag range-select) painted on the same Canvas - InteractiveRenderer interface + ChartScene/PlotMark retained geometry, reversible CartesianScale, ChartHitTest, LabelLayout de-overlap - cartesian renderers implement buildScene(); ChartRenderer/InteractiveRenderer re-exported; duration param added to every chart widget Robustness: - drafterFinite/drafterFiniteOrNull sanitizers applied at value ingestion across all renderers; fixes release-mode crashes where NaN/Infinity reached .toInt() (histogram bins, bubble nice-numbers, axis steps) and 5 bar-chart buildScene non-finite centers - InteractiveChart.didUpdateWidget resets cached scene/state on renderer swap; _publish guarded against post-dispose pointer events; hit-test guards non-finite Docs & quality: - documented every public member; enabled public_member_api_docs as the gate - @immutable on all data classes - tests 57 -> 196 (robustness matrix + interaction behavior); line coverage 96.3%
A theme-aware legend for multi-series charts. Build from explicit LegendItems or from labels (DrafterLegend.fromLabels, colored by the active theme palette). Horizontal (wrapping) or vertical layout; square/circle/line markers; optional onItemTap for series toggling. Exported from package:drafter/drafter.dart; documented under the public_member_api_docs gate; 11 widget/unit tests; README + CHANGELOG + example gallery tile.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes the Flutter charting library interactive and hardens it to ship-grade. Three pillars: interactivity (opt-in, no new deps), non-finite robustness (real crash fixes), and complete public-API docs + a much larger test suite. Bumps to
0.3.0.Interactivity
Render-only charts can now be made interactive by wrapping any cartesian renderer:
InteractiveChartwrapper +ChartInteractionconfig β trackball/tooltip, tap-to-select, drag range-select, all painted on the same Canvas (reuses the reveal animation, zero new dependencies).InteractiveRendererinterface,ChartScene/PlotMark, reversibleCartesianScale,ChartHitTest, and aLabelLayoutde-overlap helper. Paint geometry and hit-test geometry share one scale so they can't drift.buildScene().ChartRenderer/InteractiveRendererare re-exported, and adurationknob was added to every chart widget (defaults preserve prior behavior).Robustness
drafterFinite/drafterFiniteOrNullsanitizers applied at value ingestion across all renderers. This fixes release-mode crashes whereNaN/Infinityreached.toInt()(histogram bins, bubble nice-number rounding, axis steps), plus 5 bar-chartbuildScenenon-finite centers caught by the new tests.InteractiveChart.didUpdateWidgetresets the cached scene + interaction state on renderer swap (no stale highlight);_publishis guarded against post-dispose pointer events; hit-test +CartesianScale.nearestIndexguard non-finite pixels.Docs & quality
public_member_api_docsas an enforced gate β a clean analyze now proves doc completeness.@immutableon all data classes (intentionally not on renderers that hold size-keyed memo caches).robustness_test.dartmatrix: empty/single/all-equal/negative/NaN/Inf across every renderer + all widgets;interaction_behavior_test.dart: hover/tap/drag/dispose/renderer-swap/scene-cache). Line coverage 96.3%.Verification
flutter analyzeβ No issues found (withpublic_member_api_docson)flutter testβ 196/196 passdart formatβ cleandart pub publish --dry-runβ only the benign uncommitted-files notice