Skip to content

About

An interactive React Sankey component with four-sided node placement, partial allocations and controlled selection.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

154 Commits

Folders and files

Repository files navigation

Sankey Plus

@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.

Live demo →

Changelog

Distribution chart at 960 pixels wide, with partial totals and top/bottom nodes

Quick start

npm install @bwin/sankey-plus

Requires 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.

Features

  • Ordered stage columns plus multiple top/bottom nodes, with wrapping on narrow canvases.
  • One-hop hover highlighting, external highlight emphasis 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 validateGraph preflight for untrusted JSON and form data: it returns all semantic issues for structurally well-shaped graphs and invalid-graph for malformed structure before rendering.
  • Optional headroom hatching for declared partial source/sink capacity; mixed-direction relays stay unhatched.

Guides

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.

Run the demo locally

git clone https://github.com/bwin/sankey-plus.git
cd sankey-plus
npm ci
npm run dev

Open localhost:5178. After editing, run npm run build and refresh; there is no watcher.

License

MIT · Copyright (c) 2026 Benjamin Winkler | bwin.

About

An interactive React Sankey component with four-sided node placement, partial allocations and controlled selection.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages