Skip to main content
100%

Let's make a face with D3.js!

✓ Published0🌍 Public
Gghsueh01
Last edited Nov 6, 2019
Created on Nov 6, 2019

This example demonstrates fundamental DOM manipulation with D3.js by building a smiley face from an SVG circle. Using the `select`, `append`, and `attr` methods from d3-selection, it sets the circle’s radius to half the SVG height and centers it via the `cx` and `cy` attributes. The code reads the SVG’s `height` and `width` attributes directly from the DOM, and runs against d3.v5 in a minimal HTML page with external styles defining the body margin and overflow. The face is static, with no interactive or animated features beyond the initial rendering.

AI-generated description

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

MIT Licensed

Similar vizzes