Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Bowl of Fruit - General Update Pattern Special Cases

Public visualization

Bowl of Fruit - General Update Pattern Special Cases

0 stars0🌍 Public
DDifan Gu
Last edited Jul 11, 2020
Created on Jul 11, 2020

This example demonstrates special cases of D3’s general update pattern for animated transitions in SVG. It shows a bowl of fruit where apples are initially added, then removed, one apple is replaced with a lemon, and another apple is deleted, with each change re-rendering the scene. The code uses `d3.select` and `d3.range` to manage the data, while custom functions `groupsEnter.merge(groups)` and `groups.exit().remove()` handle enter, update, and exit states. Ordinal scales (`scaleOrdinal`) map fruit types to radii and fill colors, with `rect` and `circle` elements drawn via SVG attributes.

AI-generated description

Comments

Sign in to join the discussion.

MIT Licensed