Bowl of Fruit - General Update Pattern Special Cases
✓ Published219🌍 Public
This example demonstrates the general update pattern in D3, handling special cases when a data array changes through add, remove, and mutation operations. A row of apples rendered as SVG circles is modified over time: one apple is eaten, another becomes a lemon, and a middle apple disappears. The code uses D3’s `selectAll` with data joins, `.enter()`, `.merge()`, and `.exit()` to manage entering, updating, and exiting elements. The `fruitBowl` function uses scaleOrdinal to map fruit types to colors and radii, with circles and text labels positioned by index.
AI-generated descriptionMIT Licensed