Skip to main content
100%

Bowl of Fruit - Click events with D3.js!

✓ Published0🌍 Public
SSaroj Khanal
Last edited Jul 20, 2020
Created on Jul 20, 2020

This example demonstrates interactive SVG circles representing a bowl of fruit, where clicking a fruit highlights it with a black stroke. The visualization uses D3.js data joins to smoothly transition fruit sizes and positions when apples are removed or replaced with lemons over timed intervals. The `fruitBowl` function handles enter, update, and exit selections with animated radius and x-coordinate transitions. React is used as the framework wrapper, while `scaleOrdinal` maps fruit types to colors and radii, and event listeners trigger the selection state updates.

AI-generated description

Click events.

A bare minimum HTML page.

See also React Starter.

MIT Licensed

Similar vizzes