Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Let's make a face with D3.js!

Public visualization

Viewing a saved revision (read-only)

6ec8c63a9c3f49b79efe28ea53a1b43d

Let's make a face with D3.js!

0 stars0🌍 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.