Skip to main content
Public

Share visualization

Loading preview…

Bowl of Fruit - General Update Pattern

vizhub.com

Shared links may look like this on X, LinkedIn, Slack, and Discord.

Before sharing, review the publishing checklist.

Choose how to deliver this visualization

LinkedIn caption

LinkedIn may not keep text supplied by the share sheet. Copy the caption and paste it into the post if needed. You can tag the VizHub company page when posting.

More options

Embed on a websiteCopy iframe embed code
Download & exportPNG, HTML, source ZIP

Bowl of Fruit - General Update Pattern

2
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

Comments

Sign in to join the discussion.

MIT Licensed