Skip to content
EspañolEnglish
All components (283)

Sankey

Data · SankeyChart · .amset-sankey

What it is and when to use it

Where what comes in goes: where the traffic comes from and where it ends up, which items an expense comes out of. The bands are as wide as their value, so you see at a glance which path weighs most.

When to use it

  • Flows between stages or categories, with quantities (visits that reach the cart, euros that pass from one item to another).
  • nodes are the nodes ({ key, label, tone? }) and links the flows ({ source, target, value }). Each node is placed one column to the right of its furthest source and is as tall as the larger of what comes in and what goes out.
  • A flow that would close a cycle, that points to a node that does not exist or that is worth nothing is not drawn.
  • When pointing at or focusing a node, whatever does not go through it is dimmed. In a narrow slot the drawing scrolls inside its box and follows the focus.

When not to

  • Steps of a process in order, from more to less: FunnelChart.
  • Parts of a total: DonutChart or TreemapChart.
  • Relations without quantity: a WorkflowBuilder diagram.

Keyboard: Tab goes to the drawing and the arrows go first through the nodes and then through the flows, with a spoken notice ("From Visits to Cart: 3,100").

Accessibility: it is an image (role="img") with a written summary and underneath goes a real table with the source, destination and value of each flow. The names of the nodes are text of the page and do not shrink on a phone.

Fine-tuning: --amset-sankey-band is the colour of the bands. height fixes the height of the drawing.

What it looks like

Use the arrow keys to move through the values, Home and End to jump to the first and last, and Escape to leave.
Where the purchase comes from
FromToValue
VisitsDrop-off8,900
CartDrop-off1,200
WebVisits4,200
Social mediaVisits2,600
Search fieldVisits5,200
VisitsCart3,100
CartPurchase1,900

<SankeyChart
  label="Where the purchase comes from"
  nodes={[{ key: "web", label: "Web" }, { key: "visitas", label: "Visits" }, { key: "compra", label: "Purchase" }]}
  links={[
    { source: "web", target: "visitas", value: 4200 },
    { source: "visitas", target: "compra", value: 1900 },
  ]}
/>

Props

Import it with import { SankeyChart } from '@amset/ui'. Required props are marked.

PropTypeWhat it does
labelrequiredstringWhat is being measured. Required: a chart without a title tells nothing.
linksrequiredreadonly SankeyLink[]The flows from one node to another: `{ source, target, value }`. Those that would close a cycle or point to a node that does not exist are not drawn.
nodesrequiredreadonly SankeyNode[]The nodes: `{ key, label, tone? }`.
classNamestringMerged with the library classes; it does not replace them.
errorReactNode—
format(value: number) => string—
heightnumberHeight of the drawing in pixels. 320 by default.
loadingboolean—
tableVisibleboolean—

It also accepts the attributes of the element it renders: className, style, data-*, aria-* and its events.

CSS variables

These CSS variables are how you adapt it. Declare them on the component's selector, not on :root: the stylesheet redeclares them in the rule itself, and a declaration on the same element always wins.

VariableDefault
--amset-sankey-bandvar(--amset-ink-3)

How to change it

.amset-sankey {
  --amset-sankey-band: ...;
}

In the test bench

Every state and variant, to try one at a time, on its page at storybook.amsetui.com: