Bowl of Fruits - Click to Select
✓ Published0🌍 Public
This example demonstrates a dynamic fruit bowl visualization where users can click individual fruit circles to select them. It shows how D3’s general update pattern handles entering, updating, and exiting SVG elements with smooth transitions. The code uses `d3.scaleOrdinal` for color and radius mappings, `selection.enter()` and `selection.exit()` with `.transition()` to animate circle appearance and removal, and an `onClick` handler that triggers a re-render. Randomly generated fruit IDs serve as data keys, with apples and lemons represented as red and yellow circles.
AI-generated descriptionAn example showing the capabilities of VizHub.
MIT Licensed