# Proportional squares

> Use proportional squares to compare amounts as squares sharing one corner, so each area can be seen inside the next.

- Data type: One very big or small number (`scale`)
- Free (MIT): install with `npx chartreuse add proportional-squares`, or registry item `/r/proportional-squares.json`
- Example: **Oil, coal and gas still supplied 87% of the world's energy in 2024** (World primary energy by source, 2024, terawatt-hours (substitution method))
- How to read it: Each square's area is one source's energy, all sharing the bottom-left corner; fossil fuels are the three biggest.
- Phone: Adapts to mobile (Draws its own phone layout below 520px) · Video formats: 16:9 (best 16:9)

## Use it when
- a few amounts of very different size
- parts that readers should see nested inside the biggest
- squares fit the layout better than circles

## Avoid it when
- close values (use bars)
- more than about 10 items (past 12 the smallest fold into Other)
- parts must sum visibly to a whole (use a treemap or waffle)

## Fields (data.json)
- `source` (category): the item each square stands for
- `twh` (number, unit "TWh", format count): primary energy, TWh
- `group` (category): optional: the group that colours a square (else hints.groupOf by name; the first group heads the headline and is drawn light)

Units are the example's: with your own data, set each number field's `unit` and `format` (percent, count, decimal, currency, compact) in the meta you pass to mount, or `chartreuse render --unit field=text --format field=count`. Scales and labels follow your data.

## Interactions, motion, sound
- hover or tap a square or label to read the source's energy and share
- Motion: Squares unfold from the shared corner, smallest first.
- Sound: A pop on hover. Quiet while it draws and between steps; mute it from its card. (sound is off until the viewer turns it on)

## Example spec
```json
{
  "chart": "proportional-squares",
  "title": "Oil, coal and gas still supplied 87% of the world's energy in 2024",
  "subtitle": "World primary energy by source, 2024, terawatt-hours (substitution method)",
  "data": "/charts/proportional-squares.data.json"
}
```

## Source
Energy consumption by source, Our World in Data (Energy Institute Statistical Review of World Energy (2025)) (CC BY 4.0), retrieved 2026-12-01: https://ourworldindata.org/grapher/energy-consumption-by-source-and-country

Note: Non-fossil electricity is counted with the substitution method: the fossil input it would take to make the same power.

Live: /charts/proportional-squares · Manifest: /charts/proportional-squares.json · Tags: proportional squares, area, energy, fossil fuels, renewables, climate, scale
