# Collapsible tree

> Use a collapsible tree when a hierarchy is too big to show at once: start with the top levels and let readers open only the branches they care about.

- Data type: Groups within groups (`hierarchy`)
- Free (MIT): install with `npx chartreuse add collapsible-tree`, or registry item `/r/collapsible-tree.json`
- Example: **Medicine and physics have honoured the most Nobel laureates; economics, added in 1969, the fewest** (Every Nobel Prize laureate, 1901 to 2026, by prize and decade; 1,036 awards to people and organisations)
- How to read it: Each prize branches into decades and each decade into its laureates; click a prize or a decade to open or close it, and the number beside it counts its laureates.
- Interactive: expand
- 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
- a hierarchy with hundreds or thousands of leaves
- readers explore one branch at a time
- 3 or more levels where the top levels alone tell part of the story

## Avoid it when
- the whole shape must be seen at once (use a radial tree or treemap)
- printed or static output
- the tree is shallow and small enough to draw open

## Fields (data.json)
- `name` (category): a node's name: the root (drawn as the tree's first label), a branch or a leaf
- `children` (id): the nodes below; any depth (2 to about 6 levels), leaves have none
- `value` (number, unit "items", format count): optional: a leaf's size (1 when left out); a branch counts the sum of its leaves
- `year` (year): optional: a leaf's year, shown after its name; the root's tooltip spans the years
- `org` (category): optional: true marks a leaf whose tooltip says the hint flag

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
- click a prize or a decade to open or close it
- hover or tap any node to read it
- Motion: Branches slide out from the node you click and fold back into it when closed; the page grows to fit.
- Sound: A pop on hover pitched by prize. 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": "collapsible-tree",
  "title": "Medicine and physics have honoured the most Nobel laureates; economics, added in 1969, the fewest",
  "subtitle": "Every Nobel Prize laureate, 1901 to 2026, by prize and decade; 1,036 awards to people and organisations",
  "data": "/charts/collapsible-tree.data.json"
}
```

## Source
Nobel Prize API v2.1, nobelPrizes endpoint, Nobel Prize Outreach (CC0 1.0 (data)), retrieved 2026-12-01: https://www.nobelprize.org/about/developer-zone-2/

Note: Counts are awards, so people who won twice (such as Marie Curie) count twice; the Peace Prize includes organisations. Years with no award add nothing.

Live: /charts/collapsible-tree · Manifest: /charts/collapsible-tree.json · Tags: collapsible tree, expandable, drill down, hierarchy, nobel prize, science, history
