Skip to main content
100%

Let's make a face with D3.js!

✓ Published1🌍 Public
Cchenyucook
Last edited Dec 5, 2018
Created on Dec 5, 2018

This example builds a simple smiley face in an SVG canvas using D3.js v5, with a yellow circle for the head, two eyes, and an arc-based mouth. The code demonstrates basic DOM selection and manipulation via `d3.select` and `append`, alongside geometric positioning with `attr`. A notable feature is the animated eyebrows, which move up and down repeatedly using chained `transition().duration()` calls that alternate the group’s `transform` attribute. The example uses D3’s `arc` generator to draw the mouth and relies on plain SVG elements, showing how to combine static shapes with simple programmatic animation.

AI-generated description

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

MIT Licensed

Similar vizzes