@graphysdk/geom-sankey
Beta. This geom is on a
0.xversion line: a minor release may change its aesthetics, params, style or look. Use a caret range (^0.1.0) to take only patches.
A sankey geom for the Graphy charting SDK. It draws flows between nodes, each flow as wide as its amount, so what runs through a system and where it ends up read at a glance.
Learn more at graphy.dev.
Install
npm install @graphysdk/geom-sankey @graphysdk/react
Requires React 19. Its only peer is @graphysdk/react.
Usage
Data is one row per flow. Map the node it leaves to source, the node it reaches to target and its amount to value. Each node takes its own color, and each flow the color of the node it leaves. Map color to the target column (color: 'to') to color a flow as the node it reaches instead:
import { createGraphyKit, GraphRenderer } from '@graphysdk/react';
import { sankey } from '@graphysdk/geom-sankey';
const kit = createGraphyKit({ plugins: [sankey] });
const spec = kit.pipe(kit.createSpec({ source: 'from', target: 'to', value: 'twh' }), kit.geom.sankey());
export function Energy({ data }) {
return (
<kit.GraphProvider spec={spec} data={data}>
<GraphRenderer />
</kit.GraphProvider>
);
}
The geom lays itself out, so it takes no scales and draws no axes. Style the flows with kit.style.geom.sankey(), the nodes with kit.style.geom.sankey.node() and their names with kit.style.geom.sankey.label().
Docs
Feedback
This geom is released early to hear what works. Tell us on Discord.
Licence
This package is available under PolyForm Noncommercial, Small Business, or a 32-day Free Trial. Free Trial is local or internal evaluation only — it does not cover a public page. See what you can do under the trial.