Skip to main content
100%

Bowl of Fruit - General Update Pattern

✓ Published2🌍 Public
YYifei Liu
Last edited Sep 13, 2020
Created on Sep 12, 2020

Five circles represent a bowl of fruit whose contents change over time: apples shrink and vanish when eaten, and one apple transforms into a lemon. The example demonstrates the D3 general update pattern, using `selectAll` with a key function on `d.id` to track entering, updating, and exiting elements. Each circle's radius transitions to zero on exit, while new and updated fruits animate their radius and color via `transition().duration(1000)`. The code leverages `scaleOrdinal` for fruit type to color and radius mappings, with SVG rendered through d3 v5.

AI-generated description
MIT Licensed

Similar vizzes