# Nested treemap

> Use a nested treemap to show a two-level hierarchy by size: groups as bordered boxes, their members as tiles inside.

- Data type: Groups within groups (`hierarchy`)
- Pro · not released yet: its code is not available; try it on its page, or use a free chart of the same data type (`hierarchy`)
- Example: **The US and China together make 43% of the world's GDP** (Gross domestic product by country, 2024, current US dollars; boxed by continent)
- How to read it: Each box is a continent and each tile a country, its area its GDP; faded tiles fold the economies under $100 billion together.
- 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
- two levels (groups and members) of one total
- both the group totals and the biggest members matter
- 20 to 200 members

## Avoid it when
- more than two levels (use a sunburst, an icicle or a zoomable treemap)
- exact comparison of similar tiles
- negative values

## Fields (data.json)
- `country` (place): the country, or a continent's smaller economies folded together
- `continent` (category): the group
- `usd` (number, unit "billion USD", format count): GDP, billion current US dollars
- `worldBn` (number, unit "billion USD", format count): world GDP, billion US dollars

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 GDP and its share of the world and of its continent
- Motion: Continent boxes appear one by one, then their countries pour into them from the top, biggest first.
- 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": "nested-treemap",
  "title": "The US and China together make 43% of the world's GDP",
  "subtitle": "Gross domestic product by country, 2024, current US dollars; boxed by continent",
  "data": "/charts/nested-treemap.data.json"
}
```

## Source
GDP (current US$), NY.GDP.MKTP.CD; continents from Our World in Data, World Bank World Development Indicators (CC BY 4.0), retrieved 2026-12-01: https://data.worldbank.org/indicator/NY.GDP.MKTP.CD

Note: Shares are of the World Bank's world total; a few economies with no 2024 figure are missing, so the tiles add to 99%.

Live: /charts/nested-treemap · Manifest: /charts/nested-treemap.json · Tags: nested treemap, treemap, hierarchy, gdp, economy, countries, continents, money
