Sankey

@nivo/sankeyrelationalflow

Computes a sankey diagram from nodes and links, built on top of d3-sankey. The responsive alternative of this component is ResponsiveSankey.

Please be careful with the data you use for this chart as it does not support cyclic dependencies. For example, something like A —> A or A —> B —> C —> A will crash.

This component is available in the @nivo/api, see sample or try it using the API client. You can also see more example usages in the storybook.

See the dedicated guide on how to setup legends for this component.

Actions Logs
Start interacting with the chart to log actions
Base
{ nodes: object[], links: object[] }required

Chart data defining nodes and links.

string | (value: number) => stringoptional
open editor

Optional formatter for values.

stringoptionaldefault:'horizontal'

Control sankey layout direction.

stringoptionaldefault:'center'
justify

Node alignment method.

string | Functionoptionaldefault:'auto'
auto

Node sorting method.

numberrequired

Chart width.

numberrequired

Chart height.

objectoptional
px
px
px
px

Chart margin.

Style
Themeoptional

Define style for common elements such as labels, axes…

OrdinalColorScaleConfigoptionaldefault:{"scheme":"nivo"}
Categorical: Category 10

Define chart's colors.

Nodes
numberoptionaldefault:12
px

Node thickness.

numberoptionaldefault:0.75

Node opacity (0~1).

numberoptionaldefault:1

Node opacity on hover (0~1).

supportsvgapi
numberoptionaldefault:0.15

Other nodes opacity on hover (0~1).

supportsvgapi
numberoptionaldefault:12
px

Spacing between nodes at an identical level.

numberoptionaldefault:0
px

Node inner padding, distance from link, substracted from nodeThickness.

numberoptionaldefault:1
px

Node border width.

string | object | Functionoptionaldefault:{"from":"color","modifiers":[["darker",0.5]]}
inheritthemecustom
inherited property
color
modifiers
darker

Method to compute node border color.

numberoptionaldefault:0
px

Node border radius.

Links
Labels
booleanoptionaldefault:true
   

Enable/disable labels.

stringoptionaldefault:'inside'

Label position.

numberoptionaldefault:9
px

Label padding from node.

string | object | Functionoptionaldefault:{"from":"color","modifiers":[["darker",0.8]]}
inheritthemecustom
inherited property
color
modifiers
darker

Method to compute label text color.

stringoptionaldefault:'horizontal'

Label orientation.

Interactivity
booleanoptionaldefault:true
   

Enable/disable interactivity.

supportsvgapi
FunctionComponent<{ node: SankeyNodeDatum }>optional

Tooltip custom component for nodes.

supportsvgapi
FunctionComponent<{ link: SankeyLinkDatum }>optional

Tooltip custom component for links.

supportsvgapi
(target: SankeyNodeDatum | SankeyLinkDatum, event) => voidoptional

onClick handler, it receives target node or link data and mouse event.

supportsvgapi
Motion
booleanoptionaldefault:true
   

Enable/disable transitions.

supportsvgapi
string | objectoptionaldefault:'gentle'
gentle

Motion config for react-spring, either a preset or a custom configuration.

supportsvgapi