Skip to main content
Public

Share visualization

Loading preview…

Bowl of Fruit - Click to Select.js

vizhub.com

Shared links may look like this on X, LinkedIn, Slack, and Discord.

Before sharing, review the publishing checklist.

Choose how to deliver this visualization

LinkedIn caption

LinkedIn may not keep text supplied by the share sheet. Copy the caption and paste it into the post if needed. You can tag the VizHub company page when posting.

More options

Embed on a websiteCopy iframe embed code
Download & exportPNG, HTML, source ZIP

Bowl of Fruit - Click to Select.js

0
Xxsg13
Last edited Dec 15, 2020
Created on Dec 15, 2020

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 description

Comments

Sign in to join the discussion.

MIT Licensed