🌍 Public
Viewing a saved revision (read-only)
b842fc424dc543c9b96a8fffcdffc588
Bowl of Fruit - General Update Pattern
This example demonstrates the general update pattern in D3.js v5, showing how SVG circle elements are added, removed, and updated as a data array changes over time. It uses `selection.selectAll`, `enter()`, `merge`, and `exit()` to manage the lifecycle of each circle, while `scaleOrdinal` maps fruit types to colors and radii. The animation sequence buys five apples, eats one, replaces one with a lemon, and removes another, with each change triggered by `setTimeout` and re-rendered by calling the `fruitBowl` function.
AI-generated description