Skip to content

Usage

Sankey data points define directed flows between named nodes.

{
from: 'Coal',
to: 'Electricity',
flow: 42
}
OptionDescription
flowColorScriptable flow color. When set, it overrides colorMode for flows without changing node colors.
colorFromScriptable color for the source node side.
colorToScriptable color for the target node side.
colorModeFlow coloring mode: gradient, from, or to.
labelsOptional display labels by node key.
nodeLabelsNode label styling and placement. Positions are auto, left, top, right, bottom, or center.
flowLabelsOptional flow-value labels with scriptable styling and placement.
priorityOptional ordering priority by node key.
columnOptional column assignment by node key.
nodeWidthNode rectangle width in pixels.
nodePaddingPadding between nodes within a column.
orientationFlow direction: horizontal (left to right, the default) or vertical (top to bottom).
sizeNode size strategy: min or max.

Use nodeLabels to place and style labels globally or by node. Position names follow Chart.js layout positions, with auto preserving Sankey’s automatic left/right placement.

nodeLabels: {
position: {
Coal: 'right',
Electricity: 'center',
Energy: 'left'
},
color: (node) => node.key === 'Electricity' ? 'white' : 'black',
backgroundColor: {
Electricity: 'blue'
},
borderRadius: 3,
padding: 4,
font: {
size: 11,
weight: 'normal'
}
}

Flow labels use the same visual options and display the numeric flow value. Since flows are Chart.js elements, these options use the standard scriptable context.

flowLabels: {
display: (context) => context.raw.flow >= 10,
position: 'center',
color: 'black',
backgroundColor: 'white',
borderRadius: 3,
padding: 4,
font: {
size: 11,
weight: 'normal'
}
}