Skip to content

feat: opt-in data-change transitions on core charts (#126)#133

Merged
Ben Severn (benzsevern) merged 1 commit into
mainfrom
feat/126-data-transitions
May 28, 2026
Merged

feat: opt-in data-change transitions on core charts (#126)#133
Ben Severn (benzsevern) merged 1 commit into
mainfrom
feat/126-data-transitions

Conversation

@benzsevern
Copy link
Copy Markdown
Collaborator

Summary

  • New transitions?: { enabled?, durationMs? } on BaseChartProps (default enabled: false so existing renders stay byte-identical).
  • BarChart, LineChart, AreaChart, PieChart wrap their data prop in the existing useDataTransition hook.
  • Honours prefers-reduced-motion via the existing helper (snaps instead of tweening).
  • docs/INTERACTIVITY.md gains a Data-change transitions section.

Why narrower than the issue

  • Spec listed all 5 charts including ScatterPlot. ScatterDatum isn't yet supported by interpolateChartData — would need a separate change to extend the interpolator. Tracked as follow-up.
  • Tests around the transition behaviour itself are deferred: project convention avoids jsdom (InteractiveChart.test.ts) and useEffect doesn't fire under SSR rendering, so we can't drive frames in a unit test. The transition primitives (interpolateChartData, lerp, easeInOutCubic, interpolateNumberMap) are already covered by src/core/transition.test.ts (8 tests).

Verification

  • npm run typecheck clean
  • npm test — 421 existing tests pass (no transition-specific tests added; see above)
  • npm run build && npm run check:bundle — browser entry 51 KB gzipped (+1 KB from pulling useDataTransition onto the main entry, budget 75 KB)

Test plan

  • Typecheck clean
  • Full test suite green
  • Bundle guard green
  • CI green
  • Manual playground verification (carry-forward npm run compare not needed — output unchanged when transitions disabled)

Closes #126 modulo ScatterPlot, which I'll open as a follow-up if needed.

useDataTransition / interpolateChartData / prefersReducedMotion already
exist in goldenchart/interactive but no chart consumed them by default,
so changing `data` mid-mount snapped instead of animating.

- new `transitions?: { enabled?, durationMs? }` on BaseChartProps
  (default `enabled: false` so existing renders stay byte-identical)
- BarChart, LineChart, AreaChart, PieChart wrap their data prop in
  useDataTransition; ScatterPlot deferred (needs ScatterDatum support
  in interpolateChartData — separate issue)
- honours prefers-reduced-motion via the existing hook
- docs/INTERACTIVITY.md gains a Data-change transitions section
- Rough.js seeds are index-based; verified stable across frames so
  hand-drawn strokes don't shimmer mid-tween

Bundle 51 KB gzipped (budget 75 KB; +1 KB from pulling
useDataTransition into the main entry).
@benzsevern Ben Severn (benzsevern) merged commit 75dc583 into main May 28, 2026
5 checks passed
@benzsevern Ben Severn (benzsevern) deleted the feat/126-data-transitions branch May 28, 2026 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Data-change animations: enter/update/exit transitions on prop change

1 participant