Skip to main content
Public

Share visualization

Loading preview…

Bowl of Fruit - General Update Pattern.js

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.js

1
Xxsg13
Last edited Nov 30, 2020
Created on Nov 29, 2020

This example demonstrates how the general update pattern in D3 can handle dynamic changes to a dataset representing fruit in a bowl. An initial set of apples is rendered as colored circles with labels inside a rounded rectangle, and updates occur over time as apples are removed or replaced with lemons. The code uses `selectAll`, `enter`, `merge`, and `exit` to manage SVG groups, with `scaleOrdinal` mapping fruit types to colors and radii. Timed `setTimeout` calls trigger re-rendering of the bowl via the custom `fruitBowl` function.

AI-generated description

Comments

Sign in to join the discussion.

MIT Licensed