Skip to main content
Public

Share visualization

Loading preview…

Fork of Bowl of Fruit - General Update Pattern w/ Nested Animation Transitions

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

Fork of Bowl of Fruit - General Update Pattern w/ Nested Animation Transitions

1
Fframptonb
Last edited Feb 16, 2023
Created on Feb 15, 2023

This example demonstrates D3’s general update pattern with nested transitions by animating a bowl of fruit as apples are removed, replaced by lemons, and filtered out. It shows how the `enter`, `update`, and `exit` selections handle DOM creation, modification, and removal, using `selection.merge()` to apply shared attributes to groups, circles, and text. The code leverages d3.scaleOrdinal for color and radius mappings, and updates the SVG via timed `setTimeout` calls. The bowl is drawn as a static rectangle, with fruit rendered as SVG circles and labels.

AI-generated description

Demonstrates fundamental DOM manipulation using D3.js by taking advantange of the D3 .enter, .update and .exit events/update patterns when creating, updating and removing circles. This also incorporates D3 Animated Transitions and deals with Object Constancy (based on tutorial by Curran Kelleher)

<iframe width="560" height="315" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>

Comments

Sign in to join the discussion.

MIT Licensed