Skip to main content
100%

Fruit Bowl nested elements

✓ Published0🌍 Public
TTimothy sit
Last edited Dec 29, 2020
Created on Dec 29, 2020

This example demonstrates the D3 lifecycle for creating, updating, and removing nested SVG elements by managing a fruit bowl of apples and lemons. It shows how a single selection can synchronize groups, circles, and text labels as the underlying data array changes over time through timed mutations. Using D3 v5’s `select`, `range`, and `scaleOrdinal`, the code dynamically repositions and recolors each fruit’s circle and label, removing or modifying elements when fruits are eaten or replaced. The rendering relies on SVG groups and merge operations for efficient updates.

AI-generated description

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

MIT Licensed

Similar vizzes