Sankey diagram
Ribbons as wide as what flows through them. Good for money, energy or visitors from step to step.
The smallest code that works. change the code, then press Run
In your framework
import { Chart } from 'nervure/react';
const spec = {
type: 'sankey',
links: [
{ source: 'Search', target: 'Home', value: 31 },
{ source: 'Social', target: 'Home', value: 21 },
{ source: 'E-mail', target: 'Product', value: 40 },
{ source: 'Search', target: 'Product', value: 33 },
{ source: 'Home', target: 'Product', value: 28 },
{ source: 'Home', target: 'Exit', value: 13 },
{ source: 'Product', target: 'Basket', value: 13 },
{ source: 'Product', target: 'Exit', value: 39 },
{ source: 'Basket', target: 'Order', value: 45 },
{ source: 'Basket', target: 'Exit', value: 30 },
],
};
export default function Example() {
return <Chart spec={spec} style={{ height: 340 }} />;
}Or import this chart alone: what each import weighs.
Options
Beside the fields shared by every chart (title, format, heading, export…), type sankey takes:
interface SankeySpec extends Base {
type: 'sankey';
links: SankeyLink[];
colors?: Record<string, string>;
}
interface SankeyLink {
source: string;Style it
- Colours:
theme.palette,chart.setColor(name, colour), or--nervure-palettein your CSS. More - Marks:
[data-series="name"], parts:[data-part="axes"],legend,series. What you change is kept in exports. - Movement:
animation: falsedraws at once. More - Files:
chart.download('png'),svg,csv. More