D3 Example
✓ Published0🌍 Public
CCurran Kelleher
Last edited Nov 20, 2015
Created on Nov 20, 2015
This example demonstrates how to combine `d3.nest` and `d3.layout.stack` to prepare data for a stacked bar chart, using a dataset of religious populations by country. The code groups rows by religion via `d3.nest()`, then passes the nested entries to the stack layout with `stack.values()` and a custom `stack.y` accessor for the population column. It outputs the resulting stacked layers as a formatted JSON string in a `<pre>` element. The visualization reads from a local CSV file (`religionByCountryTop5.csv`) and uses D3.js version 3.5.5.
AI-generated descriptionThis example shows how d3.nest and d3.layout.stack can be used in conjunction. This forms the basis for a stacked bar chart. This is example 16 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=1979129&f=16777215&b=0" border="0" height="18" width="83" alt="web counter"></a></div> <!-- End of SimpleHitCounter Code -->