Skip to main content
100%

Bowl of Fruit - Click to Select

✓ Published2🌍 Public
Ssheafallick
Last edited Dec 15, 2022
Created on Dec 15, 2022
Forked from Bowl of Fruit

Five pieces of fruit rendered as SVG circles sit in a row, and clicking one selects it with a black outline. The example demonstrates a stateful selection pattern using D3 v7’s `scaleOrdinal` for color and radius, and a 1000ms transition for entrance, exit, and updates. Over four timed steps, an apple is removed, a lemon replaces an apple, a lemon is added, and another apple is deleted. The `fruitBowl` function handles `enter`, `merge`, and `exit` selections, and `on('click')` triggers a callback to update the `selectedFruit` state.

AI-generated description

When you click on circle, it shows up as selected.

MIT Licensed

Similar vizzes