Bowl of Fruit - Adding Fruit Labels (3)
✓ Published0🌍 Public
This example demonstrates a data join updating a bowl of fruit, with apples and lemons represented as colored circles with labels. The visualization uses D3 v5’s general update pattern, calling `selection.enter()`, `merge()`, and `exit().remove()` to handle dynamic changes. Initialized with five apples, the render function uses `scaleOrdinal` for color and radius scales, then updates over time: removing the last fruit, changing one apple to a lemon, and filtering out another by index. SVG elements—a bowl `rect` and grouped `circle` and `text` elements—are rendered and repositioned via transform attributes.
AI-generated descriptionMIT Licensed