d3 Bowl of Fruit - General Update Pattern
✓ Published1🌍 Public
A bowl of fruit demonstrates the D3 general update pattern in SVG. The visualization begins with five apples, then at one-second intervals removes an apple, changes one apple into a lemon, and removes another apple, all while a black outline highlights the fruit under the mouse cursor. The `fruitBowl` function uses `selection.selectAll`, `.enter()`, `.merge()`, and `.exit()` on `g` and `circle` elements to handle added, updated, and removed data. The `d3.scaleOrdinal` maps fruit types to colors (`darkred` for apple, `#f1f90c` for lemon) and radii, while `.transition().duration(1000)` animates circle positions and radii, and `.remove()` deletes exiting elements.
AI-generated descriptionMIT Licensed