Skip to main content
100%

Create an animated rectangle with D3

✓ Published2🌍 Public
NNita
Last edited Jan 16, 2020
Created on Jan 14, 2020
Forked from HTML Starter

This example demonstrates how D3 transitions can animate the properties of an SVG rectangle. An initially short, 100-pixel-wide rectangle grows in height from zero to 400 pixels over two seconds after a one-second delay, while its fill color changes from steelblue to a warm orange in a second transition. The code uses D3 v5’s `d3.select` to append an SVG element, `selection.append('rect')` to create the shape, and chained `transition()` calls with `.delay()` and `.duration()` methods. The rectangle is rendered directly in the browser via SVG, with all styling and timing defined imperatively in JavaScript.

AI-generated description

A bare minimum HTML page.

See also React Starter.

MIT Licensed

Similar vizzes