Population Pyramid
Source: Data Visualisation Catalogue - Population Pyramid
Why This Belongs In The Compiler Gallery
The catalogue population pyramid is a practical test for diverging bar charts. It needs ordinary rect marks, but it also needs compiler-owned signed geometry so left and right cohorts share one symmetric scale and one zero spine.
Data Contract
Each raw row represents one age cohort with two positive measures.
| Field | Type | Purpose |
|---|---|---|
ageGroup | ordinal | Cohort label shown on the y axis. |
male | quantitative | Left-side population measure. |
female | quantitative | Right-side population measure. |
side | categorical, derived | Output side label. |
value | quantitative, derived | Positive cohort value. |
signedValue | quantitative, derived | Negative left value or positive right value for symmetric domains. |
start | quantitative, derived | Rect start bound on the diverging x scale. |
end | quantitative, derived | Rect end bound on the diverging x scale. |
Expected Visual
The faithful catalogue version should show two mirrored horizontal bars for every age cohort. Left and right bars meet at a shared zero centerline, and x-axis labels should read as absolute values instead of negative values on the left.
| Element | Expected treatment |
|---|---|
| Cohort bars | Rects using start and end bounds from the diverging layout transform. |
| Centerline | Vertical guide line at zero. |
| X axis | Symmetric quantitative scale with absolute tick labels. |
| Y axis | Age cohort labels in input order. |
| Color | Side-based categorical encoding. |
Compiler Mapping
| Compiler part | Mapping |
|---|---|
| Data source | age-population raw cohort table and derived pyramid-segments table. |
| Transform | layout with layoutKind: "divergingBars" derives left/right segment rows. |
| Scales | x: linear with symmetric and padding, y: band, color: ordinal. |
| Guides | Generated x grid/axis, generated y labels, generated side legend, and an explicit zero centerline. |
| Layers | Rect bars plus guide layers. |
| Interaction | Hover exposes age cohort, side, value, and source row. |
Faithfulness Notes
The core chart is compiler-owned now, including the side legend generated from the color scale. Remaining polish includes optional percent-of-total formatting and richer demographic axis policies for very dense age bands.