Skip to main content
100%

d3 Bowl of Fruit - General Update Pattern

✓ Published1🌍 Public
JJohnPaulPagelerJr
Last edited Feb 26, 2019
Created on Feb 20, 2019
Forked from d3 Bland Canvas

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 description
MIT Licensed

Similar vizzes