Skip to content

Animation ​

On or off ​

ts
createChart(host, spec);                            // animated
createChart(host, spec, { animation: false });      // drawn at once

People who ask their system for less motion get no animation, whatever you write.

When ​

ts
createChart(host, spec, { animation: { start: 'load' } });     // at once, the default
createChart(host, spec, { animation: { start: 'visible' } });  // when the reader scrolls to it
const chart = createChart(host, spec, { animation: { start: 'manual' } });
button.onclick = () => chart.play();                           // when you decide, as often as you want

The room of the chart is kept while it waits, so nothing on the page jumps.

How ​

OptionDoes
speed2 is twice as fast
durationmilliseconds for each mark, instead of the timing of the chart
delaymilliseconds before the first mark
staggerfalse moves every mark together
easinglinear, ease, ease-in, ease-out, ease-in-out, bounce, elastic, or any CSS easing such as cubic-bezier(.34,1.56,.64,1)
effectfade replaces movement by a fade
loopplays the entrance again and again, with a pause between two runs; update() and refresh() start it again with the new data, destroy() stops it
linehow the lines of xy charts come in: trace (default), grow or draw

Easing ​

bounce and elastic go past the end and come back. They are written as a CSS linear() curve; a browser that cannot read it uses the easing of the chart instead.

ts
createChart(host, spec, { animation: { easing: 'bounce' } });
createChart(host, spec, { animation: { easing: 'ease-out', duration: 600 } });

Lines ​

ts
createChart(host, spec, { animation: { line: 'draw' } });
lineLines come in
trace (default)traced along their length, each series a little after the one before
growup from the axis, with their areas and points
drawfrom left to right at an even pace: the line, its area, its dots and its labels are uncovered together, like a pen drawing it

line applies to lines, areas and bands of xy charts; bars and other charts keep their own entrance. With effect: 'fade', lines fade like the rest.

Loop ​

ts
createChart(host, spec, { animation: { loop: true, line: 'draw' } });

The entrance plays again once every movement has ended, after a short pause, until update with another spec, refresh (live data) or destroy. People who ask their system for less motion see the chart drawn once, still.

Charts use the Web Animations API of the browser: no timer runs once they are drawn. Only liquid and pipeline with flow move without end.

chart.update(spec) plays again; chart.refresh(spec) does not, for live data.