Skip to main content
100%

D3 Example

✓ Published0🌍 Public
CCurran Kelleher
Last edited Nov 20, 2015
Created on Nov 20, 2015

This example shows a single stacked bar chart that breaks down the world’s total population by religious affiliation, using one bar per region (here, a single “World” region) with each segment colored by religion. The visualization uses the D3.js library’s `d3.layout.stack` to compute the stacking of values, while `d3.scale.ordinal` and `d3.scale.linear` map categorical regions and numeric populations to screen positions. Axes are rendered with `d3.svg.axis`, and a color legend is added via `d3.legend.color`. Data comes from the bundled CSV file `religionWorldTotals.csv`, which lists population counts for each religion, and the chart is drawn in SVG.

AI-generated description

This example shows how to split a rectangle into a stack using d3.layout.stack. This is example 12 from the screencast Splitting Charts.

MIT License

<!-- Start of SimpleHitCounter Code --> <div align="center"><a href="http://www.simplehitcounter.com" target="_blank"><img src="http://simplehitcounter.com/hit.php?uid=1979130&f=16777215&b=0" border="0" height="18" width="83" alt="web counter"></a></div> <!-- End of SimpleHitCounter Code -->

Similar vizzes