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).
nodesare the nodes ({ key, label, tone? }) andlinksthe 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:
DonutChartorTreemapChart. - Relations without quantity: a
WorkflowBuilderdiagram.
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
| From | To | Value |
|---|---|---|
| Visits | Drop-off | 8,900 |
| Cart | Drop-off | 1,200 |
| Web | Visits | 4,200 |
| Social media | Visits | 2,600 |
| Search field | Visits | 5,200 |
| Visits | Cart | 3,100 |
| Cart | Purchase | 1,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.
| Prop | Type | What it does |
|---|---|---|
labelrequired | string | What is being measured. Required: a chart without a title tells nothing. |
linksrequired | readonly 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. |
nodesrequired | readonly SankeyNode[] | The nodes: `{ key, label, tone? }`. |
className | string | Merged with the library classes; it does not replace them. |
error | ReactNode | — |
format | (value: number) => string | — |
height | number | Height of the drawing in pixels. 320 by default. |
loading | boolean | — |
tableVisible | boolean | — |
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.
| Variable | Default |
|---|---|
--amset-sankey-band | var(--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:
