Examples

Budget allocation

Preview
Budget allocation (k€)Sankey diagram of 6 flows between 6 nodes in 3 stages. Largest: Budget to Product 600; Product to People 450; Budget to Sales 400.
Use the arrow keys to move between data points, Home and End to jump to the first and last.
Example.tsx
import { Sankey } from '@reactloom/charts';

const nodes = [
  { id: 'budget', label: 'Budget' },
  { id: 'product', label: 'Product' },
  { id: 'sales', label: 'Sales' },
  { id: 'people', label: 'People' },
  { id: 'tools', label: 'Tools' },
  { id: 'events', label: 'Events' },
];
const links = [
  { source: 'budget', target: 'product', value: 600 },
  { source: 'budget', target: 'sales', value: 400 },
  { source: 'product', target: 'people', value: 450 },
  { source: 'product', target: 'tools', value: 150 },
  { source: 'sales', target: 'people', value: 250 },
  { source: 'sales', target: 'events', value: 150 },
];

export default function Example() {
  return <Sankey title="Budget allocation (k€)" nodes={nodes} links={links} />;
}

Visitor journeys

Preview
Visitor journeysSankey diagram of 5 flows between 5 nodes in 4 stages. Largest: Search to Home page 5,200; Social to Home page 2,400; Home page to Pricing 2,100.
Use the arrow keys to move between data points, Home and End to jump to the first and last.
Visitor journeys (data)
SearchHome page5,200
SearchPricing1,800
SocialHome page2,400
Home pagePricing2,100
PricingSign-up1,300
Example.tsx
import { Sankey } from '@reactloom/charts';

const nodes = [
  { id: 'search', label: 'Search' },
  { id: 'social', label: 'Social' },
  { id: 'home', label: 'Home page' },
  { id: 'pricing', label: 'Pricing' },
  { id: 'signup', label: 'Sign-up' },
];
const links = [
  { source: 'search', target: 'home', value: 5200 },
  { source: 'search', target: 'pricing', value: 1800 },
  { source: 'social', target: 'home', value: 2400 },
  { source: 'home', target: 'pricing', value: 2100 },
  { source: 'pricing', target: 'signup', value: 1300 },
];

export default function Example() {
  return <Sankey title="Visitor journeys" nodes={nodes} links={links} table="visible" />;
}

API reference

Sankey props
PropTypeDefault
nodesrequired
{ id, label }[]—
linksrequired
{ source, target, value }[]—
titlerequired
Names the figure.
string—
description
The takeaway; a factual summary is generated when omitted.
ReactNode—
table
The data table alternative.
'toggle' | 'visible' | 'none''toggle'
height · valueFormat · formatValue · messages
As on the other charts.
—

Customization

Extracted from the component’s source on every build, so it matches the code. How the layers fit together is explained in Customization.

State attributes

Target these in your CSS to style states without depending on class names.

AttributeValues
[data-active]present when on

Theme tokens it reads

--pl-color-fg-muted

Accessibility

  • The chart is a figure named by its title and described by a summary; the drawing is hidden from assistive technology.
  • The plot is one tab stop: arrow keys move between items and each is announced; the data table gives every value.
  • Flows are read as “from to to: value (share)”; the table lists every flow.
Keyboard interactions
KeyAction
← → ↑ ↓Move between flows
Home / EndFirst / last flow

Usage guidelines

Do

  • Keep to a handful of stages.

Don’t

  • Don't draw cycles: flows go one way.