Usage
Sankey data points define directed flows between named nodes.
{ from: 'Coal', to: 'Electricity', flow: 42}Common Dataset Options
Section titled “Common Dataset Options”| Option | Description |
|---|---|
flowColor | Scriptable flow color. When set, it overrides colorMode for flows without changing node colors. |
colorFrom | Scriptable color for the source node side. |
colorTo | Scriptable color for the target node side. |
colorMode | Flow coloring mode: gradient, from, or to. |
labels | Optional display labels by node key. |
nodeLabels | Node label styling and placement. Positions are auto, left, top, right, bottom, or center. |
flowLabels | Optional flow-value labels with scriptable styling and placement. |
priority | Optional ordering priority by node key. |
column | Optional column assignment by node key. |
nodeWidth | Node rectangle width in pixels. |
nodePadding | Padding between nodes within a column. |
orientation | Flow direction: horizontal (left to right, the default) or vertical (top to bottom). |
size | Node size strategy: min or max. |
Node Labels
Section titled “Node Labels”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
Section titled “Flow Labels”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' }}