Skip to main content
100%

Animate thousands of points with canvas and D3

✓ Published0🌍 Public
TThanaporn-sk
Last edited Mar 17, 2017
Created on Mar 17, 2017

This example shows 7,000 points smoothly animating through a repeating sequence of five layouts: sine wave, phyllotaxis spiral, spiral, phyllotaxis, and grid. The animation updates point positions by interpolating between source and target coordinates over 1.5 seconds using `d3.timer` and an easing function. Instead of SVG, it draws each point as a filled rectangle on an HTML5 Canvas via `getContext('2d')`, allowing for thousands of elements without performance degradation. Point colors are assigned using `d3.interpolateViridis`.

AI-generated description

Animate thousands of points with canvas and D3

Using D3 and d3-transition works great when animating hundreds of points with SVG, but performance breaks down when you need to animate more than a thousand. This block demonstrates a simple approach to animating thousands of points between different layouts using canvas, d3-timer, and d3-ease.

See the blog post for more details.

forked from <a href='http://bl.ocks.org/pbeshai/'>pbeshai</a>'s block: <a href='http://bl.ocks.org/pbeshai/65420c8d722cdbb0600b276c3adcc6e8'>Animate thousands of points with canvas and D3</a>

mit Licensed

Similar vizzes