Keep record IDs, scales and frame provenance stable; offer pause and a static path through the same observations.
Animated charts: do not let motion invent data
Frames are data snapshots
An animated chart displays a sequence of observations, not a continuous measurement just because movement looks continuous. Store the date, source revision, eligibility rule and unit for every frame. When data exist only at two dates, intermediate positions are visual interpolation and must not be described as observed measurements. A bar that grows from 47 to 81 may imply smooth change even if the underlying quantity jumped at one import. Time-series completeness should determine which frames can be compared and which remain provisional.
Identity must survive reordering
Use stable entity IDs across frames. A ranked bar animation may reorder entities; if color or label is assigned by array position, it can appear that one entity changes into another. Match records by ID, separate newly entering and exiting entities, and never fill a missing measurement with zero unless zero is a real observation. Rank movement charts are often better as a static alternative when the main question is who changed position. Keep the selection anchored to ID if a user pauses halfway through a transition.
Lock the scale or disclose change
An axis that rescales independently at every frame can make a flat series appear to surge or a large decline look minor. Fix a domain across the full sequence when the comparison is meant to be quantitative. If an extreme new value requires a domain change, pause, label the change and provide the numeric context. Axis integrity applies to every frame, and extrema checks must run before the domain is chosen. Keep category colors, units and legend order stable too.
Motion is optional
Provide play, pause, next-frame and previous-frame controls that work with a keyboard. Do not trap focus on the chart. Respect reduced-motion preference and offer a static small-multiple view or data table that carries the same observations. A paused live feed should indicate whether resuming continues from the pause point or jumps to the latest state. Keyboard and table contracts keep the analysis available without timed interaction. Export frame ID, timestamp, scale domain and source record IDs so a particular visual state can be cited and reproduced.
Worked contract
function pairedFrameValues(previousFrame, nextFrame) {
const previous = new Map(previousFrame.map(record => [record.id, record.value]));
const next = new Map(nextFrame.map(record => [record.id, record.value]));
if (previous.size !== previousFrame.length || next.size !== nextFrame.length) {
throw new Error("each frame needs unique record IDs");
}
const paired = [];
for (const [id, earlierValue] of previous) {
if (next.has(id)) {
const laterValue = next.get(id);
if (!Number.isFinite(earlierValue) || !Number.isFinite(laterValue)) {
throw new Error("frame values must be finite");
}
paired.push({id, earlierValue, laterValue});
}
}
return paired;
}
const pairedDepots = pairedFrameValues(
[{id: "north-47", value: 47}, {id: "south-59", value: 59}],
[{id: "south-59", value: 81}, {id: "north-47", value: 52}],
);
if (pairedDepots[0].id !== "north-47" || pairedDepots[0].laterValue !== 52) {
throw new Error("records must match by identity, not array position");
}Performance and operating cost
Building two ID maps and pairing N previous records with M next records takes O(N+M) time and space. This code deliberately omits entering and exiting entities from interpolation; the view should represent them with explicit entry or exit states, not fabricate an earlier zero. A full animation also needs frame controls, reduced-motion handling, stable scales and a static equivalent. The pairing function is the data boundary that prevents position-based identity errors.
Common Mistakes
- Presenting interpolated in-between positions as measured observations.
- Matching reordered rows by array index so entities switch labels or colors.
- Auto-scaling every frame while inviting quantitative comparison.
- Autoplaying without a working pause and static way to inspect the data.
Validation drill
Animate 47 weekly depot snapshots. Lock the quantity scale, audit entry and exit states, pause on a chosen week and confirm the static table reports the same IDs and values.
