Skip to main content
100%

Stacked Bar Chart with Tooltip by D3 v4

✓ Published0🌍 Public
Aabrahamdu
Last edited May 20, 2017
Created on May 17, 2017

This example shows the age distribution of the U.S. population by gender, with males and females stacked as colored segments within each age group. The chart uses D3 v4's `d3.scaleBand` for the age categories, `d3.scaleLinear` for percentages, and `d3.scaleOrdinal` for color encoding. Hovering over a segment triggers a tooltip built with a separate SVG that displays the exact value. The data comes from data.gov, and the code draws from examples by Mike Bostock and Michael Stanaland.

AI-generated description

This is stacked bar chart done by D3.

Based on D3 Stacked Bar Chart by Mike Bostock https://bl.ocks.org/mbostock/3886208 Tooltip code based on D3 Stacked Bar Chart with Tooltips by Michael Stanaland http://bl.ocks.org/mstanaland/6100713

The data source comes from data.gov

mit Licensed

Similar vizzes