Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Bowl of Fruit - General Update Pattern

Public visualization

Viewing a saved revision (read-only)

6e0d955c7c9d45c4b95e33dbc7152889

Bowl of Fruit - General Update Pattern

0 stars2🌍 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