# Treemap

> Use a treemap to show many parts of one total at once: each rectangle's area is its value, shaded by group.

- Data type: Shares of a total (`parts`)
- Free (MIT): install with `npx chartreuse add treemap`, or registry item `/r/treemap.json`
- Example: **China alone emits almost a third of the world's CO₂** (CO₂ from fossil fuels and industry by country, 2025, tonnes; shaded by continent)
- How to read it: Each rectangle is one country, its area its emissions; the faded tiles fold together each continent's smaller emitters.
- Phone: Not recommended for mobile (On a phone labels are hard to read or overlap (checked by eye)) · Video formats: none passed; closest 9:16

## Use it when
- many parts (10 to 100) of one total
- a few giants and a long tail is the story
- a group (like continent) helps read the parts

## Avoid it when
- readers must compare similar sizes exactly (use sorted bars)
- the values can be negative
- fewer than about six parts (use a bar or a donut)

## Fields (data.json)
- `country` (place): the country, or the rest of a continent folded together
- `continent` (category): the group that sets the shade
- `tonnes` (number, unit "tonnes", format count): CO₂ emitted, tonnes
- `world` (number, unit "tonnes", format count): the world total the shares are of
- `count` (number, unit "countries", format count): how many countries a folded tile holds

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 tile to read its emissions and share
- hover or tap a continent in the key to light its tiles
- Motion: Tiles grow out from their corners, biggest first, so the giants land before the long tail.
- Sound: A soft pop on hover, pitched by continent. 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": "treemap",
  "title": "China alone emits almost a third of the world's CO₂",
  "subtitle": "CO₂ from fossil fuels and industry by country, 2025, tonnes; shaded by continent",
  "data": "/charts/treemap.data.json"
}
```

## Source
Annual CO₂ emissions, Our World in Data (Global Carbon Budget, Global Carbon Project) (CC BY 4.0), retrieved 2026-12-01: https://ourworldindata.org/grapher/annual-co2-emissions-per-country

Note: Shares are of the world total, which also counts international aviation and shipping, so the tiles add to slightly less than 100%. 2025 figures are the Global Carbon Project's latest estimates.

Live: /charts/treemap · Manifest: /charts/treemap.json · Tags: part to whole, treemap, area, carbon, co2, climate, emissions, countries
