Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Bowl of Fruit - General Update Pattern

Public visualization

Bowl of Fruit - General Update Pattern

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

Comments

Sign in to join the discussion.

MIT Licensed