Skip to main content
Public

Share visualization

Loading preview…

77. D3 Adding Removing

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

77. D3 Adding Removing

0
Aamakanju@nyit.edu
Last edited Feb 23, 2026
Created on Feb 23, 2026

This example demonstrates how to add and remove data values from a bar chart in real time. Clicking the "Add a new data value" button pushes a randomly generated number onto a dataset, while clicking "Remove a data value" shifts the first element off the array. The SVG bars and text labels update with smooth transitions using D3’s `transition` and `duration` methods, with the x-scale domain recalculated via `d3.scaleBand` and `d3.range` to reflect the changing data length.

AI-generated description

Comments

Sign in to join the discussion.

MIT Licensed