Skip to main content
100%

Let's make a face with D3.js!

✓ Published1🌍 Public
JJishen Xu
Last edited Aug 25, 2018
Created on Aug 25, 2018

This example uses D3.js (v5) to construct an animated smiley face entirely through SVG primitives and DOM manipulation. It shows how a face composed of a circle, eyes, eyebrows, and a mouth can be built and animated on an empty 960x500 SVG canvas. The code demonstrates chained `transition().duration()` calls to move the left eyebrow up and down over two seconds, while the right eyebrow is a rectangle and the mouth is an arc path generated with the `d3.arc` API. All elements are positioned through SVG attributes and groups, with no external data—the face is purely synthetic.

AI-generated description

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

MIT Licensed

Similar vizzes