# Dendrogram

> Use a dendrogram to show a cluster tree: which items are most alike, in what order groups merge, and how far apart they are when they do.

- Data type: Groups within groups (`hierarchy`)
- Free (MIT): install with `npx chartreuse add dendrogram`, or registry item `/r/dendrogram.json`
- Example: **Climate twins: London pairs with Paris, Mumbai with Singapore, Sydney with Cape Town** (20 cities clustered by their monthly mean temperatures in 2024; branch depth is the average gap between groups, °C)
- How to read it: Cities joined by a short branch on the right have similar years; the further left two branches meet, the more their climates differ.
- Phone: Not recommended for mobile (On a phone labels are hard to read or overlap (checked by eye)) · Video formats: 16:9 (best 16:9)

## Use it when
- items were clustered and the merge order and distances matter
- 5 to 60 leaves with readable names
- you want readers to choose how many groups to cut into

## Avoid it when
- the tree is a real hierarchy, not a clustering (use a tree or an indented tree)
- hundreds of leaves (use a heatmap with a dendrogram edge, or a radial tree)
- the distance measure is not explained

## Fields (data.json)
- `name` (category): a leaf: the city
- `months` (number, unit "°C", format decimal): a leaf's values, one per period, in order (12 monthly mean temperatures in 2024, °C, in the example; any count works, named by hints.periods, else month initials for twelve, else 1 to N)
- `height` (number, unit "°C", format decimal): an inner node: the average distance between the two groups it joins
- `children` (id): an inner node's two subtrees

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 city to read its months and its closest twin
- hover a join to read who merges there and how far apart they are
- Play cuts the tree into 2 to 6 groups
- Motion: Branches grow from the cities back towards the root, in the order the clustering merged them.
- Sound: A pop on hover, warmer cities higher. 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": "dendrogram",
  "title": "Climate twins: London pairs with Paris, Mumbai with Singapore, Sydney with Cape Town",
  "subtitle": "20 cities clustered by their monthly mean temperatures in 2024; branch depth is the average gap between groups, °C",
  "data": "/charts/dendrogram.data.json"
}
```

## Source
Historical Weather API: daily mean 2 m temperature, 2024 (ERA5 reanalysis), Open-Meteo (Copernicus Climate Change Service ERA5) (CC BY 4.0), retrieved 2026-12-01: https://open-meteo.com/en/docs/historical-weather-api

Note: Distance is the Euclidean distance between two cities' 12 monthly means; groups merge by average linkage. Sydney's and Cape Town's seasons are flipped, so they pair with each other rather than with northern cities of a similar average.

Live: /charts/dendrogram · Manifest: /charts/dendrogram.json · Tags: dendrogram, cluster tree, hierarchical clustering, similarity, climate, cities, weather
