Skip to main content
100%

Bow of Fruit - General Update Pattern

✓ Published0🌍 Public
VVinh H. Le
Last edited May 14, 2020
Created on May 9, 2020

This example demonstrates D3.js’s general update pattern by showing a row of fruit that changes over time. It begins with five apples, then removes one apple and later changes another apple into a lemon, with each transition updating the SVG circles’ fill color and radius via `scaleOrdinal` mappings. Using `selection.data`, `enter`, `merge`, and `exit`, the code binds an array of fruit objects to circles, appending new elements, updating existing ones, and removing deleted ones on each render. Data is generated locally with `d3.range` and `setTimeout` triggers the sequential updates.

AI-generated description

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

MIT Licensed

Similar vizzes