Bowl of Fruit - General Update Pattern
✓ Published2🌍 Public
This example demonstrates the D3 general update pattern by animating a bowl of fruit, where circles representing apples and lemons appear, disappear, and change color through data-driven transitions. It shows enter, update, and exit selections working together as fruits are eaten or replaced over time. The code uses `selection.data()` with a key function, `selection.enter()`, `selection.merge()`, and `selection.exit()` alongside `transition()` for smooth radius and position changes. D3’s `scaleOrdinal` maps fruit types to colors and radii, while `Math.random()` generates unique IDs for each fruit.
AI-generated descriptionMIT Licensed