Sized Donut Multiples
This example uses a matrix of donut charts to show the population distribution across age groups for each US state. Each donut’s area is proportional to the state’s total population, using `d3.scaleSqrt` for scaling. The code uses `d3.csv` to load the data, `d3.pie` and `d3.arc` to compute and render the arcs, and `d3.selectAll` with `selection.each` to access both the state-level and age-group-level data simultaneously within the SVG. The legend maps age categories to colors via `d3.scaleOrdinal`.
AI-generated descriptionThis example demonstrates how to use selection.each to create a context to access parent and child data simultaneously. The donut multiples are sized such that the area of each donut is proportionate to the total population, such that the area of the arcs is comparable across states.
This is a technical demonstration rather than a design recommendation; you probably don’t want to use this visual form. A normalized stacked bar chart is better at comparing the age distribution across states, and a stacked or grouped bar chart is better at comparing absolute values.
forked from <a href='http://bl.ocks.org/mbostock/'>mbostock</a>'s block: <a href='http://bl.ocks.org/mbostock/4c5fad723c87d2fd8273'>Sized Donut Multiples</a>