Skip to main content
100%

Bowl of fruit - Hover to select

✓ Published0🌍 Public
BB Sundaresan
Last edited Jul 11, 2020
Created on Jul 11, 2020

Five fruit circles are rendered in an SVG, initially all apples, with a black stroke appearing on whichever fruit the mouse hovers over. The code uses a React-style render function with d3 selections and the `scaleOrdinal` color and radius scales to map fruit types to visuals. Updates occur via timed transitions: an apple is removed, a lemon replaces one apple, and another apple is filtered out. The `fruitBowl` function handles enter, update, and exit selections with `.transition().duration(1000)` for animated changes, while mouseover triggers `setSelected` to update the selection state.

AI-generated description

A bare minimum HTML page.

See also React Starter.

MIT Licensed

Similar vizzes