Skip to main content
100%

Bowl of Fruit - General Update Pattern

✓ Published0🌍 Public
NNita
Last edited Sep 17, 2018
Created on Sep 17, 2018

This example demonstrates the general update pattern in D3.js v5, showing how SVG circle elements are added, removed, and updated as a data array changes over time. It uses `selection.selectAll`, `enter()`, `merge`, and `exit()` to manage the lifecycle of each circle, while `scaleOrdinal` maps fruit types to colors and radii. The animation sequence buys five apples, eats one, replaces one with a lemon, and removes another, with each change triggered by `setTimeout` and re-rendered by calling the `fruitBowl` function.

AI-generated description
MIT Licensed

Similar vizzes