Skip to main content
100%

Bowl of Fruit - General Update Pattern

✓ Published0🌍 Public
KKinjal-Goyani
Last edited Oct 31, 2022
Created on Oct 31, 2022

This example demonstrates D3’s general update pattern by animating a bowl of fruit as apples are removed or replaced with lemons. It shows the enter, update, and exit selections in action: new circles enter, existing circles transition their radius based on fruit type, and removed circles shrink to zero before being deleted. The code uses d3.scaleOrdinal for color and radius mapping, with d3.transition handling the 1-second animations. The visualization is driven by timed updates to a JavaScript array, which is re-rendered through the fruitBowl function.

AI-generated description

Demonstrates fundamental DOM manipulation using D3.js by making a smiley face whose eyebrows move.

MIT Licensed

Similar vizzes