Skip to main content

SankeyChart

Every example on this page is live, drawn by the library's Storybook, where you can also change its props and see the result.

A flow diagram that visualizes quantities between nodes using proportional-width bands. Each node sits one column to the right of the furthest node that flows into it, and every node in a column shares that column's pattern. Each flow is drawn as the outline of a band as thick as the quantity it carries, so flows that cross stay visible through each other.

Labels sit beside their nodes, on the left of the nodes in the last column so they stay on the chart. A node too short for its label is left unlabelled.

Links to or from a node that is not in nodes, links worth nothing, and links that would loop back to a node they came from are left out. Nodes that share a label are drawn once.

The diagram stretches to fill whatever box it is laid out in, including a widget's stored preview. Its labels keep their size.

Import​

import { SankeyChart } from "~lib/charts/sankey-chart";

Props​

NameTypeRequiredDefaultDescription
nodes{ label: string }[]YesN/ANodes to display
links{ source: string; target: string; value: number }[]YesN/AFlows between nodes
showLabelsbooleanNotrueShow node labels
showValuesbooleanNofalseShow flow totals next to labels
nodeWidthnumberNo12Width of node bars, in pixels
nodePaddingnumberNo8Gap between nodes in a column, in pixels
widthnumber | stringNo300Chart width
heightnumber | stringNo300Chart height

Examples​

Simple​

Open Simple in Storybook

With Values​

Open With Values in Storybook

Two Columns​

Open Two Columns in Storybook

Many Layers​

Open Many Layers in Storybook

Unequal Flows​

Open Unequal Flows in Storybook

See Also​