Skip to main content
100%

Stacked Bar Chart

✓ Published0🌍 Public
YYkelf
Last edited Oct 24, 2017
Created on Oct 24, 2017

This stacked bar chart displays the population of U.S. states broken down by seven age groups, with states sorted by total population and segments color-coded by age category. The visualization is rendered as an SVG using D3 v4, loading data from a CSV file via d3.csv. The code uses d3.scaleBand for the x-axis, d3.scaleLinear for the y-axis, d3.scaleOrdinal for colors, d3.stack to compute stacked positions, and d3.axisBottom and d3.axisLeft for the axes. A legend identifies each age group, and the y-axis labels use SI-prefix formatting via d3.format.

AI-generated description

This stacked bar chart is constructed from a CSV file storing the populations of different states by age group. The chart employs conventional margins and a number of D3 features:

  • d3-dsv - load and parse data
  • d3-scale - x- and y-position, and color encoding
  • d3-format - SI prefix formatting (e.g., “10M” for 10,000,000)
  • d3-array - compute simple statistics (e.g., max)
  • d3-axis - display axes
  • d3-shape - computed stacked positions

forked from <a href='http://bl.ocks.org/mbostock/'>mbostock</a>'s block: <a href='http://bl.ocks.org/mbostock/3886208'>Stacked Bar Chart</a>

forked from <a href='http://bl.ocks.org/anonymous/'>anonymous</a>'s block: <a href='http://bl.ocks.org/anonymous/614b5d5d6df20fb06867760f124636dd'>Stacked Bar Chart</a>

gpl-3.0 Licensed

Similar vizzes