Untitled
This example uses d3.pie and d3.arc to render a matrix of donut charts, one per U.S. state, with each donut’s area scaled via d3.scaleSqrt to reflect the state’s total population. The arcs within each donut represent age brackets, colored using d3.scaleOrdinal. Data is loaded from a CSV with d3.csv, and the `selection.each` method provides simultaneous access to parent state data and child age data. The SVG charts are sized dynamically based on each state’s population sum.
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.