#22

Add reanimate prop to skip the entrance replay on data updates

OpenKyleKreuterwants to merge intofrom

What

Adds an opt-in reanimate prop (default true) to every chart root. With reanimate={false}, a new data array no longer re-plays the entrance animation — the chart keeps its mount entrance and then just eases toward the new values. This is the behavior you want for streaming / live data (SSE, polling), where a fresh array arrives on every tick.

// mount entrance once, then morph on each SSE tick
<AreaChart data={live} config={cfg} reanimate={false}>
  <Area dataKey="v" />
</AreaChart>

Default is unchanged: a data change still replays the entrance.

Why

useRevision(data, replayToken) bumps on every new data identity, and each canvas (cartesian / bar / pie / radar) resets animStart on a revision change and re-runs its reveal sweep. For a stream that pushes a new array each tick, that's a constant re-reveal. revision drives only the entrance reveal — the bands/scales/targets recompute from data directly and the RAF loop already eases current toward them — so gating what revision keys on is safe and non-breaking.

How

  • chart-context.tsx / polar-context.tsx — useRevision(reanimate ? data : null, replayToken). When reanimate is false, data changes no longer bump the revision (mount + replayToken still do).
  • cartesian-root.tsx / polar-root.tsx — thread the prop to the controllers.
  • pie-chart.tsx / radar-chart.tsx — expose reanimate (area / line / bar inherit it via CartesianChartProps).

One lever fixes area / line / bar / pie / radar at once, since every canvas keys its reveal off the shared revision. No changes to the canvases or the easing.

Tests

tests/reanimate.test.tsx asserts a fresh data array bumps the entrance revision by default and leaves it unchanged when reanimate={false}. Full suite: 30 passing. Registry regenerated with npm run build:registry.

Summary by Comp AI

1 issue found.

Written for commit b1ab245. New commits will trigger a re-review. Generated by Comp AI.

Activity

5
tripwire-sh[bot]4mo ago

passed — nothing tripped. good to merge.

comp-ai-code-review[bot]4mo ago

⚠️ Comp AI code review complete — 1 issue found.

Reviewed commit b1ab245.

Posted by Comp AI Code Reviews.

comp-ai-code-review[bot]reviewed4mo ago
comp-ai-code-review[bot]4mo ago

1 issue found across 1 file.

Prompt for AI agents (all issues)
Check whether each issue below is valid; if so, find the root cause and fix it. Read the referenced code to confirm the problem before changing it, and use sub-agents to handle independent issues in parallel.

<file name="r/core.json">
<issue n="1" at="r/core.json" severity="MEDIUM">Unguarded PALETTE lookup crashes on invalid config color — In palette.ts, `seedOfColor(color)` performs `PALETTE[color]` with no runtime guard, and a helper `isDitherColor` exists but is never used to validate before lookup. Fix: Have `seedOfColor` fall back to the grey seed when `color` is not a valid key: `export const seedOfColor = (color: DitherColor): Seed => PALETTE[color] ??</issue>
</file>

Posted by Comp AI Code Reviews.