Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Bowl of Fruit - General Update Pattern.js

Public visualization

Viewing a saved revision (read-only)

9fd33c8482ea4868bbdcc8ee49d61375

Bowl of Fruit - General Update Pattern.js

0 stars1🌍 Public
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