Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Bowl of Fruit - General Update Pattern Special Cases

Public visualization

Viewing a saved revision (read-only)

6b59225b1da74fbf819316908344d386

Bowl of Fruit - General Update Pattern Special Cases

0 stars0🌍 Public
TThomas Hooper
Last edited Jun 19, 2020
Created on Jun 19, 2020

This example demonstrates the general update pattern’s special cases in D3 v5, animating a bowl of fruit with apples and lemons as data changes over time. It shows how to handle entering, updating, and exiting elements when items are added, removed, or modified, using SVG groups for each fruit. The code leverages `d3.scaleOrdinal` for color and radius mappings, and `selection.merge` with `transition.duration` to smoothly animate attribute changes. The scene updates three times via `setTimeout`, illustrating an apple removal, a type replacement, and a filter-based deletion.

AI-generated description