Skip to main content
100%

Let's make a face with D3.js!

✓ Published2🌍 Public
NNathan Neelis
Last edited Nov 4, 2020
Created on Nov 4, 2020

This example demonstrates fundamental DOM manipulation with D3.js by building a smiley face whose eyebrows animate up and down. The code creates the face using SVG primitives—a yellow circle, two eyes, and rectangular eyebrows—all grouped and positioned through chained `.attr()` calls and transform translations. The animation is achieved by chaining two `.transition().duration(2000)` methods on the eyebrow group, which alternately shifts its vertical offset. Using D3 v5 and the `select`, `arc`, and `transition` APIs, the example shows how to construct and animate simple shapes directly in an SVG canvas.

AI-generated description

Demonstrates fundamental DOM manipulation using D3.js by making a smiley face whose eyebrows move.

MIT Licensed

Similar vizzes