Skip to main content
100%

Fork of Bowl of Fruit - General Update Pattern Special Cases

✓ Published0🌍 Public
Eeefjescheerder
Last edited Dec 22, 2021
Created on Dec 22, 2021

This example demonstrates the general update pattern in D3 v5, showing how to handle special cases when adding, removing, and modifying data-bound elements. It visualizes a bowl of fruit where apples and lemons are represented by colored circles, with SVG `<circle>` and `<text>` elements updated through `selection.merge` and `selection.exit`. The code uses `d3.scaleOrdinal` for color and radius mapping, and triggers three sequential updates via `setTimeout`: removing a fruit, changing an apple to a lemon, and filtering out another fruit.

AI-generated description
MIT Licensed

Similar vizzes