🌍 Public
Fork of Bowl of Fruit - General Update Pattern Special Cases
Ssohum42
Last edited Jan 2, 2022
Created on Jan 2, 2022
This example demonstrates the general update pattern for SVG elements in D3 v5, showing how a bowl of fruit changes as apples are eaten or replaced by lemons. Three distinct update scenarios occur sequentially: removing the last apple, changing an apple’s type to lemon, and filtering out an apple from the middle. The `fruitBowl` function uses D3’s `selectAll` and `.merge` with ordinal scales for color and radius to handle entering, updating, and exiting groups. The underlying code uses `d3.select` and `d3.range` to manage the data array, while SVG `rect` and `circle` elements are re-rendered at each timeout-driven step.
AI-generated descriptionMIT Licensed








Comments
Sign in to join the discussion.