Skip to main content
Public

Share visualization

Loading preview…

Bowl of Fruit - Adding Fruit Labels (3)

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

Bowl of Fruit - Adding Fruit Labels (3)

0
NNathan Cheever
Last edited Jan 4, 2020
Created on Jan 4, 2020

This example demonstrates a data join updating a bowl of fruit, with apples and lemons represented as colored circles with labels. The visualization uses D3 v5’s general update pattern, calling `selection.enter()`, `merge()`, and `exit().remove()` to handle dynamic changes. Initialized with five apples, the render function uses `scaleOrdinal` for color and radius scales, then updates over time: removing the last fruit, changing one apple to a lemon, and filtering out another by index. SVG elements—a bowl `rect` and grouped `circle` and `text` elements—are rendered and repositioned via transform attributes.

AI-generated description

Comments

Sign in to join the discussion.

MIT Licensed