Skip to main content
100%

Let's make a face with D3.js!

✓ Published0🌍 Public
ZZhang Shengli
Last edited Sep 26, 2019
Created on Sep 26, 2019

This example demonstrates fundamental D3.js data joins and DOM manipulation by rendering a row of five fruit-colored circles that update when data changes. It uses `d3.select`, `d3.range`, and `d3.scaleOrdinal` to map fruit types to colors, with `selection.enter()`, `merge()`, and `exit()` to handle adding, updating, and removing SVG circles. After an initial render, a pop removes one circle, and a subsequent change re-colors the middle circle from red to yellow, showing dynamic updates driven by array mutations.

AI-generated description

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

MIT Licensed

Similar vizzes