Bowl of Fruit - Click to Select.js
✓ Published0🌍 Public
Xxsg13
Last edited Dec 15, 2020
Created on Dec 15, 2020
Forked from Bowl of Fruit - General Update Pattern.js
Five apples are displayed in a row within an SVG bowl, and hovering over a fruit selects it with a black stroke. D3’s data join uses `selection.data` with a key function, and `merge` handles updates while `exit` transitions shrink removed fruits. Interactions trigger `setSelectedFruit` on mouseover and mouseout, and timed callbacks mutate the data array to remove apples or replace one with a lemon. The code relies on `scaleOrdinal` for color and radius, with `transition` animating position and size over one second.
AI-generated descriptionMIT Licensed