Animation
On or off
createChart(host, spec); // animated
createChart(host, spec, { animation: false }); // drawn at oncePeople who ask their system for less motion get no animation, whatever you write.
When
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 wantThe room of the chart is kept while it waits, so nothing on the page jumps.
How
| Option | Does |
|---|---|
speed | 2 is twice as fast |
duration | milliseconds for each mark, instead of the timing of the chart |
delay | milliseconds before the first mark |
stagger | false moves every mark together |
easing | linear, ease, ease-in, ease-out, ease-in-out, bounce, elastic, or any CSS easing such as cubic-bezier(.34,1.56,.64,1) |
effect | fade replaces movement by a fade |
loop | plays the entrance again and again, with a pause between two runs; update() and refresh() start it again with the new data, destroy() stops it |
line | how 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.
createChart(host, spec, { animation: { easing: 'bounce' } });
createChart(host, spec, { animation: { easing: 'ease-out', duration: 600 } });Lines
createChart(host, spec, { animation: { line: 'draw' } });line | Lines come in |
|---|---|
trace (default) | traced along their length, each series a little after the one before |
grow | up from the axis, with their areas and points |
draw | from 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
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.