Sankey diagram reference
Contents: Use cases, Chart IDs, Minimal spec, Data, Options, Annotations, Sizing, Fixtures, Not for.
Flows from sources to targets in stages (channel to page to purchase, budget to departments, segment moves month to month): rows of source, target and value; node height and ribbon width are the flow. Deterministic crossing reduction, links colored by source or target, small nodes folded into Other, stage-qualified nodes for repeat visits. Type sankey.
Use cases
- Channel to landing page to purchase
- Budget to departments
- Customers moving between segments month to month
Chart IDs
One form; its chart ID is sankey.
Minimal spec
{
"type": "sankey",
"data": {
"links": [
{ "source": "search", "target": "product", "value": 420 },
{ "source": "search", "target": "home", "value": 180 },
{ "source": "social", "target": "home", "value": 260 },
{ "source": "email", "target": "product", "value": 140 },
{ "source": "product", "target": "purchase", "value": 210 },
{ "source": "home", "target": "purchase", "value": 90 }
],
"nodes": [
{ "id": "search", "label": "Search" },
{ "id": "social", "label": "Social" },
{ "id": "email", "label": "Email" },
{ "id": "product", "label": "Product page" },
{ "id": "home", "label": "Home page" },
{ "id": "purchase", "label": "Purchase" }
],
"stages": [
{ "id": "channel", "label": "Channel" },
{ "id": "page", "label": "Landing page" },
{ "id": "outcome", "label": "Outcome" }
]
},
"options": {
"title": "Search brings most visits that end in a purchase",
"unit": "k visits",
"source": "Illustrative data"
}
}Data
| Path | Type | Required | Meaning |
|---|---|---|---|
| links | array | yes | Flows as rows of source, target and value: the shape of a GROUP BY source, target result. Columns follow from the graph: sources left, ends right. A cycle is refused unless stages separate the visits. |
| links[].source | string | yes | Id of the node the flow leaves. |
| links[].target | string | yes | Id of the node the flow enters. |
| links[].value | number | yes | The flow, 0 or more: the link width. A zero link draws nothing and warns sankey-zero-link; a negative value is refused. Links with the same ends (and stages) add up. |
| links[].sourceStage | string | Stage of the source node. With stages, a node is the pair (stage, id): 'gold' in '2026-01' and 'gold' in '2026-02' are two nodes that share the label and color of 'gold'. Set both stages on every link or on none. | |
| links[].targetStage | string | Stage of the target node; it comes after sourceStage in the stage order and may skip stages. | |
| nodes | array | Labels and colors per node id, in the order the nodes take under order "data" and the order colors follow. A link may name an id this list does not hold. | |
| nodes[].id | string | yes | Node id that links name in source and target. |
| nodes[].label | string | Name beside the node; defaults to the id. | |
| nodes[].colorRole | string | Theme color role of the node and the links it colors. One of good, bad, warn, neutral, neutralLight, highlight, total, others; series-N for step N of the theme ramp, 1-based (series-2 is color.series[1]); or status-<key> for a theme status color. A hex color goes in fill. | |
| nodes[].fill | string | Authored fill of the node and the links it colors. | |
| stages | array | Stage order and column headers. With stage-qualified links it sets the stage order. Without, it names the drawn columns left to right and must have one entry per column. | |
| stages[].id | string | yes | Stage id that links name in sourceStage and targetStage. |
| stages[].label | string | Header above the stage column; defaults to the id. |
Options
| Path | Type | Values | Default | Meaning |
|---|---|---|---|---|
| linkColor | string | 'source', 'target' | Which end's node color a ribbon takes. Unset: every node and ribbon draws neutral, and a node with fill, colorRole or a highlight colors the ribbons it touches. 'source' shows where flows come from and 'target' where they go, each with one palette step per node; with a highlight, only the highlighted nodes keep a color. Nodes that color no link draw in the neutral mark color. Ribbons are translucent so crossings and node bars show through: on a light page the alpha rises from surface.ribbonAlpha (default 0.35) until a ribbon reaches the 1.4:1 mark floor; on a dark page it stays at surface.ribbonAlpha, under 3:1 against the page, and the node bars and values carry the flow. | |
| order | string | 'flow', 'data' | 'flow' orders the nodes of each column for the fewest weighted ribbon crossings. 'data' keeps the order of data.nodes, then first seen in links. Default 'flow', and 'data' when stage-qualified ids repeat across stages, so segments keep one order every month. | |
| other | false | object | false (or another value of its type) | Small nodes folded into one Other node per column, so a long tail stays readable; the note lists every folded node with its value. A column folds only when at least two nodes qualify. The Other node is as tall as its members together, so each column keeps its total. Default { share: 0.02 } without stages; off with stage-qualified links, where an object folds an id in every stage or in none. false keeps every node. | |
| other.share | number | Fold nodes under this share of their column's total; default 0.02. | ||
| other.label | string | Name of the folded node; default strings.others, else 'Others'. | ||
| nodeValue | string | false | 'value', 'share', 'value-share', false | What a node prints in bold after its name: 'value' (default), 'share' of its column's total, or 'value-share' as "420 (38%)". A percent format applies to the shares. false prints the name only; the marks, hover and records keep the value, and linkValue still decides the ribbon values. | |
| columnOverrides | object | Settings per generated column. Ids: first, last. | ||
| columnOverrides.*.width | number | Track width in px. It beats the width the type would pick. | ||
| linkValue | string | 'none', 'large' | 'large' | Flow values on the ribbons: 'large' (default) prints the value of every ribbon at least one line high at its arriving end, right aligned to the next bar; thinner ribbons print nothing, and a value that would cover a node label is left out. 'none' prints node values only. |
Plus the shared options. This type does not accept detailFields, labels, labelPosition, valueAxis, story, hatchStrength, rounding, annotations. This type ignores animate, debug, rowLabels, categoryAxis, categoryLabels, secondaryAxis, sort, topN, bandFraction, legend, valueAxis.show, valueAxis.gridlines with an option-ignored warning.
Annotations
This type takes no annotations.
Sizing
Floor 280 × 270 px; fit fill.
Below the floor a render is refused with size-below-floor and the pixels it needs. measure returns the natural and comfortable size for a given spec; see Sizing in the manual.
Fixtures
| ID | Kind | Use case |
|---|---|---|
| channel-journeys | example | Channel to landing page to outcome: stage headers, two small channels folded into Others and listed in the note, Purchase highlighted |
| channel-journeys-node-values | example | Channel journeys with linkValue none: node values only, no value on the ribbons |
| budget-departments | example | Budget to departments to cost types, links colored by target |
| segment-migration | example | Customers moving between segments month to month: stage-qualified nodes, one segment order in every month |
| sales-stages | torture | Six stages with drop-outs that skip columns as long links |
| long-names-phone | torture | Long node names on a 280 px phone card: names wrap and break with a hyphen |
| unbalanced-nodes | torture | Nodes whose inflow and outflow differ, duplicate rows that add up and a zero row |
| no-node-values | example | Nodes print their names only |
| column-overrides | example | Authored widths for the label gutters of the first and last stage |
Not for
Flows that loop back without stages (refused as a cycle; give links sourceStage and targetStage), or parts of one total (use treemap or bar). Pairwise rows do not say which channel a purchase came from once flows merge at a page: for that, build path-qualified nodes from journey data.