AG Studio Launch Week 🚀🚀🚀 28 Sep - 2 Oct 2026 🚀🚀🚀 Join now

JavaScript ChartsSankey Series

Version 14.2.0

A Sankey Series visualises movement or change between different items, using nodes and links.

Simple Sankey Copy Link

To create a Sankey Series, use the sankey series type.

{
    series: [
        {
            type: 'sankey',
            fromKey: 'from',
            toKey: 'to',
            sizeKey: 'size',
        },
    ],
}

In this configuration:

  • fromKey defines the start node of each link.
  • toKey defines the end node of each link.
  • sizeKey defines the size of each link.

Circular loops are not allowed in Sankey diagrams, and links forming a circular loop will be removed.

Node Layout Copy Link

Horizontal Alignment Copy Link

The horizontal placement of the nodes can be customised using the alignment property on node.

{
    series: [
        {
            type: 'sankey',
            fromKey: 'from',
            toKey: 'to',
            sizeKey: 'size',
            node: {
                alignment: 'left',
            },
        },
    ],
}

There are four values supported:

  • left moves nodes as far left as possible.
  • right moves nodes as far right as possible.
  • center moves nodes as close to the centre as possible.
  • justify moves nodes as far left as possible, except for the last nodes, which are pushed right.

Vertical Alignment Copy Link

The vertical placement of the nodes can be customised using the verticalAlignment property on node.

{
    series: [
        {
            type: 'sankey',
            fromKey: 'from',
            toKey: 'to',
            sizeKey: 'size',
            node: {
                verticalAlignment: 'top',
            },
        },
    ],
}

There are three values supported:

  • top moves nodes as far up as possible.
  • bottom moves nodes as far down as possible.
  • center places the nodes in the middle and distributes evenly in each direction.

Sorting Copy Link

The order of the nodes can be customised using the sort property on node.

There are three values supported:

  • data sorts nodes in the same order as they first appear in the data array.
  • ascending and descending sort nodes alphanumerically by their displayed labels.
  • auto sorts nodes to reduce overlapping links and produce a cleaner layout.

Label Placement Copy Link

Labels can be placed to the left, right or centred over nodes using the placement property.

The optional edgePlacement property sets the first and last node labels to 'inside' or 'outside', defaulting to the placement value if unspecified.

Customisation Copy Link

Node Style Copy Link

The styling of all nodes can be customised using the node property.

{
    series: [
        {
            type: 'sankey',
            fromKey: 'from',
            toKey: 'to',
            sizeKey: 'size',
            node: {
                fill: '#34495e',
                stroke: '#2c3e50',
                strokeWidth: 2,
            },
        },
    ],
}

The styling of all links can be customised using the link property.

{
    series: [
        {
            type: 'sankey',
            fromKey: 'from',
            toKey: 'to',
            sizeKey: 'size',
            link: {
                fill: '#34495e',
                fillOpacity: 0.25,
                stroke: '#2c3e50',
                strokeWidth: 1,
                strokeOpacity: 0.25,
            },
        },
    ],
}

Sankey Chart Examples Copy Link

See more Sankey Chart examples in the AG Charts Gallery.

API Reference Copy Link

Properties available on the AgSankeySeriesOptions interface.

type required 'sankey'
Configuration for the Sankey Series.
getItemId Function
A callback to provide a stable identifier for each node, exposed as `itemId` in events and active state. The returned identifier must be unique across nodes and links, which share one `itemId` namespace (links default to `link-<index>`). If not supplied, the node name is used as its identifier.
id string default: auto-generated value
Primary identifier for the series. This is provided as `seriesId` in user callbacks to differentiate multiple series. Auto-generated ids are subject to future change without warning, if your callbacks need to vary behaviour by series please supply your own unique `id` value.
context ContextDefault
Context object to use in callbacks.
data DatumDefault[]
The data to use when rendering the series. If this is not supplied, data must be set on the chart instead.
visible boolean
Whether to display the series.
cursor string
The cursor to use for hovered markers. This config is identical to the CSS `cursor` property.
highlight AgHighlightOptions
Configuration for highlighting when a series or legend item is hovered over.
nodeClickRange InteractionRange
Range from a node that a click triggers the listener.
showInLegend boolean
Whether to include the series in the legend.
listeners AgSeriesListeners
A map of event names to event listeners.
fromKey string
The key containing the start node of each link.
toKey string
The key containing the end node of each link.
sizeKey string
The key containing the size of each link.
sizeName string
A human-readable description of the size values. If supplied, this will be shown in the default tooltip and passed to the tooltip renderer as one of the parameters.
label AgSankeySeriesLabelOptions
Options for the label for each node.
fills AgColorType[]
The colours to cycle through for the fills of the nodes and links. An array of colour strings, or fill objects for gradients, patterns, or images.
strokes CssColor[]
The colours to cycle through for the strokes of the nodes and links.
node AgSankeySeriesNodeOptions
Options for the nodes.
tooltip AgSeriesTooltip
Series-specific tooltip configuration.