# Sankey

> Use a Sankey to show how a total splits and merges across two or more stages, with each ribbon's width as its volume. Takes either the example's countries-by-source table or any process flow as { nodes?, links: [{ source, target, value }] }, with 2 to 5 stages found from the links.

- Data type: Movement between stages (`flow`)
- Free (MIT): install with `npx chartreuse add sankey`, or registry item `/r/sankey.json`
- Example: **Fossil fuels still made 59% of the world's electricity in 2024** (Electricity generation by country and source, terawatt-hours, 2024)
- How to read it: Ribbons run from each country to the sources it burns or harnesses, then on to fossil or low-carbon; width is terawatt-hours.
- Phone: Adapts to mobile (Draws its own phone layout below 520px) · Video formats: 16:9 (best 16:9)

## Use it when
- one total splits into parts and those parts regroup at a later stage
- the volumes matter as much as the routes
- there are 2 to 4 stages with up to about 12 nodes in each
- any process or funnel with drop-offs (a pipeline, a budget, a sign-up flow): pass { nodes?, links } and the stages come from the links

## Avoid it when
- the flows loop back on themselves (use a chord or a network)
- you need exact comparisons between similar ribbons (use bars)
- there are dozens of tiny flows that turn into hair

## Fields (data.json)
- `year` (year): the year of the figures
- `sources` (category): the middle stage: six groups of generation sources, in ink order
- `lowCarbon` (category): the sources counted as low-carbon in the last stage
- `countries[].country` (place): the first stage: six largest generators and the rest of the world
- `countries[].<source>` (number, unit "TWh", format count): terawatt-hours generated from that source in that country

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 ribbon to read its terawatt-hours and share of the world
- hover a bar to light every ribbon through it
- Motion: The ribbons pour in from left to right when the chart comes into view; the bars of each stage appear as the flow reaches them.
- Sound: A pop pitched by source 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": "sankey",
  "title": "Fossil fuels still made 59% of the world's electricity in 2024",
  "subtitle": "Electricity generation by country and source, terawatt-hours, 2024",
  "data": "/charts/sankey.data.json"
}
```

## Source
Energy dataset (electricity generation by source), Our World in Data (Ember, Energy Institute Statistical Review of World Energy) (CC BY 4.0), retrieved 2026-12-01: https://github.com/owid/energy-data

Note: "Bioenergy and other" is OWID's other renewables including bioenergy; "Rest of world" is the world total minus the six countries shown.

Live: /charts/sankey · Manifest: /charts/sankey.json · Tags: flow, energy, electricity, stages, volume, alluvial, climate
