Skip to main content
100%

Stacked Bar Chart

✓ Published0🌍 Public
MMTClass
Last edited May 11, 2017
Created on Apr 27, 2017

This stacked bar chart shows population totals for each state, broken down by seven age groups, with each bar sorted by overall population and segments colored by age category. It loads data from a remote CSV file using d3.csv, then builds the visualization with d3.scaleBand for the x-axis, d3.scaleLinear for the y-axis, and d3.scaleOrdinal for color encoding. The stacked positions are computed using d3.stack, while d3.axisBottom and d3.axisLeft render the axes. The chart includes a legend and uses an SVG rendering approach with conventional margins.

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>

gpl-3.0 Licensed

Similar vizzes