@bwin/sankey-plus is an interactive React + TypeScript Sankey component with explicit stages, top/bottom nodes, independent totals and controlled selection. Runtime dependencies are React and React DOM only.
npm install @bwin/sankey-plusRequires React and React DOM 18.2 or later. The package is ESM and includes TypeScript declarations.
import { SankeyDiagram, type SankeyGraph } from '@bwin/sankey-plus';
import '@bwin/sankey-plus/style.css';
const graph: SankeyGraph = {
stages: ['input', 'output'],
nodes: [
{
key: 'source',
title: 'Available',
total: 1000,
placement: { stage: 'input' },
},
{ key: 'target', title: 'Allocated', placement: { stage: 'output' } },
],
links: [{ key: 'allocation', from: 'source', to: 'target', amount: 500 }],
};
export default function Example() {
return (
<SankeyDiagram
graph={graph}
accessibleName="Available and allocated amounts"
/>
);
}The source keeps its total of 1,000 while transferring only 500. Give the diagram a container with an available width.
- Ordered stage columns plus multiple top/bottom nodes, with wrapping on narrow canvases.
- One-hop hover highlighting, external
highlightemphasis with inspection callbacks for linked tables and cross-chart views, keyboard navigation, node/link clicks and externally controlled selection. - Read-only layout snapshots, a typed ref for SVG export and programmatic focus, plus non-interactive SVG overlays for annotations.
- Custom labels, tooltips with both connected nodes, typed metadata and light/dark theme tokens.
- Resolved source and target shares on link facts for percentage labels and tooltips, using each endpoint's own unit total.
- Optional crossfade between completed scenes when data changes, with reduced-motion support; geometry is not morphed or interpolated.
- Common value scaling and explicit totals larger than their connected transfers.
- Non-throwing
validateGraphpreflight for untrusted JSON and form data: it returns all semantic issues for structurally well-shaped graphs andinvalid-graphfor malformed structure before rendering. - Optional headroom hatching for declared partial source/sink capacity; mixed-direction relays stay unhatched.
| Guide | Covers |
|---|---|
| Getting started | Integration, click handlers, selection and sizing |
| API reference | Props, graph data, stages, callback contexts and validation |
| Customization | Labels, endpoint tooltips, formatting and themes |
| Layout and interaction | Routing, wrapping, hover, keyboard behavior and limits |
| Examples | What each interactive demo demonstrates |
| Development | Local setup, tests, builds and stress commands |
| Releasing | Changelog, dev → master, package verification, npm and GitHub releases |
Layout yields in main-thread chunks; individual helpers and SVG rendering can still block. Arbitrary graphs are not guaranteed to be crossing-free. See performance and verification for measurements and tested coverage. master contains the latest npm release; ongoing development happens on dev.
git clone https://github.com/bwin/sankey-plus.git
cd sankey-plus
npm ci
npm run devOpen localhost:5178. After editing, run npm run build and refresh; there is no watcher.
MIT · Copyright (c) 2026 Benjamin Winkler | bwin.
