Skip to main content
100%

Let's make a face with D3.js!

✓ Published1🌍 Public
Ccentem
Last edited Jul 28, 2020
Created on Jul 28, 2020

This example demonstrates how to build a smiley face whose eyebrows move using fundamental D3.js DOM manipulation. The code selects SVG elements and binds data to them with `d3.select` and `data()`, then applies updates via `enter` and `merge` selections. It uses `d3.interval` to drive the animation, adjusting eyebrow positions through `attr` calls on the `cx` and `cy` properties. Rendering occurs in an SVG container created in the HTML, with styles defined in an external stylesheet. The face itself is composed of circles and ellipse shapes, while the script runs a continuous loop to shift the eyebrows in and out.

AI-generated description

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

MIT Licensed

Similar vizzes