Skip to main content
100%

Bowl of Fruit - General Update Pattern

✓ Published1🌍 Public
CChenluWang96
Last edited Mar 10, 2020
Created on Mar 10, 2020

This example demonstrates the general update pattern in D3 for animating changes to a dataset. It shows a row of circles representing fruit, starting with five apples, then removing one, swapping an apple for a lemon, and removing another. The visualization uses d3.v5 to bind data to SVG circle elements, with enter, update, and exit selections to handle additions, modifications, and deletions. The `fruitBowl` function explicitly uses `.enter().append()`, `.merge()`, and `.exit().remove()` to manage the lifecycle of each circle, and uses `scaleOrdinal` to map fruit types to colors and radii.

AI-generated description
MIT Licensed

Similar vizzes