Sankey.

PRO

Represent quantities moving between nodes through link widths.

Live preview23 feature examples

LIVE EXAMPLE

Conversion flow

Match the page theme
Interact with the chart to see selection and range-change results here.
OptionsChanges are reflected in the preview and code.
Appearance and style7
Legend and interaction11
Title and dimensions3

Show movement between stages using link widths. All values are sample data.

View code
Current preview
<div id="chart-container" style="width: 100%; min-width: 0;"></div>

<script type="module">
  import { defineCustomElement as define0 } from '@syidax/advanced-pro/components/sy-sankey.js';
  define0();

  // Pro: complete registerLicense at app startup using your issued certificate.
  // The website preview certificate is not for use in customer apps.
  const specs = [
    {
      "id": "example-chart",
      "tag": "sy-sankey",
      "props": {
        "data": {
          "links": [
            {
              "source": "Inflow",
              "target": "Product A",
              "value": 42
            },
            {
              "source": "Inflow",
              "target": "Product B",
              "value": 28
            },
            {
              "source": "Product A",
              "target": "Purchase",
              "value": 30
            },
            {
              "source": "Product A",
              "target": "Outflow",
              "value": 12
            },
            {
              "source": "Product B",
              "target": "Purchase",
              "value": 18
            },
            {
              "source": "Product B",
              "target": "Outflow",
              "value": 10
            }
          ]
        },
        "nodeAlign": "justify",
        "width": 640,
        "height": 360,
        "brandPosition": "bottom-right",
        "brandLogo": ""
      }
    }
  ];
  const container = document.querySelector('#chart-container');
  const elements = specs.map(({ tag, id, props }) => {
    const element = document.createElement(tag);
    element.id = id;
    Object.assign(element, props);
    element.setAttribute('aria-label', 'sankey example chart');
    return element;
  });
  container.replaceChildren(...elements);
  const chart = elements.at(-1);
  const onEvent = event => {
    console.log('nodeClick', event.detail);
  };
  chart.addEventListener('nodeClick', onEvent);
  const observer = new ResizeObserver(([entry]) => {
    const width = Math.max(160, Math.floor(entry.contentRect.width));
    elements.forEach(element => { element.width = width; });
  });
  observer.observe(container);

  // In an SPA, call this function when the view is disposed.
  function disposeChart() {
    observer.disconnect();
    chart.removeEventListener('nodeClick', onEvent);
    container.replaceChildren();
  }
</script>

Usage and data

#

Explain branching and merging flows of energy, users, or funds.

Keep link units consistent. Explain cases where inflow and outflow do not balance.

Data contract

PropertyInput format
data{ nodes?, links: [{ source, target, value }] }.
nodeAlignHow nodes align within stages.

Updating data

Assign a new array or object to the property instead of mutating values inside an array. Chart events provide selection results through event.detail. When disposing of the view, clean up ResizeObserver and event listeners registered by your app.

Feature examples

#

Try 23 interactive feature examples and inspect their code. Select “Edit in preview” to combine more options in the settings panel above.

Left alignmentPRO

Align stages to the starting nodes.

Interact with the chart to see results here.
View code

Flow width and opacityPRO

Adjust node spacing and link opacity.

Interact with the chart to see results here.
View code

Inspect values with the pointerPRO

Point to data to view the value at that location.

Interact with the chart to see results here.
View code

Drag to zoom and panPRO

Drag to zoom and hold Shift to pan. Use Ctrl + wheel to zoom in or out.

Interact with the chart to see results here.
View code

Replay animationPRO

Redraw the same example to inspect its initial display animation.

Interact with the chart to see results here.
View code

AnimationPRO

Compare 2 examples of Animation. Buttons and options update both the live result and source code.

Interact with the chart to see results here.
View code

Data inputPRO

Compare 1 examples of Data input. Buttons and options update both the live result and source code.

Interact with the chart to see results here.
View code

LabelPRO

Compare 4 examples of Label. Buttons and options update both the live result and source code.

Interact with the chart to see results here.
View code

LayoutPRO

Compare 7 examples of Layout. Buttons and options update both the live result and source code.

Interact with the chart to see results here.
View code

LinksPRO

Compare 7 examples of Links. Buttons and options update both the live result and source code.

Interact with the chart to see results here.
View code

Large datasetsPRO

Compare 1 examples of Large datasets. Buttons and options update both the live result and source code.

Interact with the chart to see results here.
View code

SizePRO

Compare 1 examples of Size. Buttons and options update both the live result and source code.

Interact with the chart to see results here.
View code

TooltipPRO

Compare 12 examples of Tooltip. Buttons and options update both the live result and source code.

Interact with the chart to see results here.
View code

Zoom and panPRO

Compare 6 examples of Zoom and pan. Buttons and options update both the live result and source code.

Interact with the chart to see results here.
View code

Context menuPRO

Compare 1 examples of Context menu. Buttons and options update both the live result and source code.

Interact with the chart to see results here.
View code

HoverPRO

Compare 1 examples of Hover. Buttons and options update both the live result and source code.

Interact with the chart to see results here.
View code

Link ClickPRO

Compare 1 examples of Link Click. Buttons and options update both the live result and source code.

Interact with the chart to see results here.
View code

Node ClickPRO

Compare 1 examples of Node Click. Buttons and options update both the live result and source code.

Interact with the chart to see results here.
View code

Data context menuPRO

Compare 1 examples of Data context menu. Buttons and options update both the live result and source code.

Interact with the chart to see results here.
View code

Read coordinates and dataPRO

Compare 1 examples of Read coordinates and data. Buttons and options update both the live result and source code.

Interact with the chart to see results here.
View code

OptionalPRO

Compare 1 examples of Optional. Buttons and options update both the live result and source code.

Interact with the chart to see results here.
View code

OverviewPRO

Compare 8 examples of Overview. Buttons and options update both the live result and source code.

Interact with the chart to see results here.
View code

Streaming · Add and update live dataPRO

Compare 5 examples of Add and update live data. Buttons and options update both the live result and source code.

Interact with the chart to see results here.
View code

API reference

#

The full public API for sy-sankey. Pass objects and arrays as JavaScript properties. Select a name to view usage code and type definitions.

Key properties

Attribute / PropertyType / DefaultDescription
SankeyDataDefault: undefined{ nodes?, links: [{ source, target, value }] }.
numberDefault: 900Chart width in pixels. Update with ResizeObserver when the container changes.
numberDefault: 400Chart height in pixels.
brandLogostringDefault: undefinedThe default is the Syidax logo. With the Pro chart.branding entitlement, use none or a PNG, JPEG, or WebP data URL.
brandPosition'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'Default: 'bottom-right'The corner where the logo is anchored. Applies equally to Community and Pro, on screen and in image exports.
nodeWidthnumberDefault: SANKEY_DEFAULT_NODE_WIDTHThe nodes' width and the gap between stacked nodes (CSS px).
nodePaddingnumberDefault: SANKEY_DEFAULT_NODE_PADDINGSet as an HTML attribute or JavaScript property. type: number.
nodeAlignSankeyAlignDefault: 'justify'How nodes align within stages.
linkOpacitynumberDefault: DEFAULT_LINK_OPACITYThe ribbons' opacity (0 … 1).
linkCurvaturenumberDefault: SANKEY_DEFAULT_CURVATURESet as an HTML attribute or JavaScript property. type: number.
nodeLabelsSankeyLabelModeDefault: 'auto'Allowed values: auto, show, hide. Default: 'auto'.
nodeLabelValuebooleanDefault: falseSet as an HTML attribute or JavaScript property. type: boolean.
chartTitlestringDefault: undefinedThe title inside the chart. Explain the data's unit and meaning alongside it.
chartSubtitlestringDefault: undefinedThe subtitle inside the chart.
CartesianTooltipInputDefault: undefinedTooltip settings for pointer-driven values, position, and content.
tooltipEnabledbooleanDefault: trueSet as an HTML attribute or JavaScript property. type: boolean.
animatedbooleanDefault: falseWhether to animate initial display and data changes.
animationDurationnumberDefault: 600Animation duration in milliseconds.
animationEasingSankeyEasingDefault: 'ease-out'Allowed values: linear, ease-out, ease-in, ease-in-out. Default: 'ease-out'.
animationTypeSankeyAnimationTypeDefault: undefinedAllowed values: initial, update. Default: undefined.
CartesianZoomInputDefault: undefinedSettings for zooming and the visible range.
Other properties 12
Attribute / PropertyType / DefaultDescription
layoutIterationsnumberDefault: SANKEY_DEFAULT_ITERATIONSSet as an HTML attribute or JavaScript property. type: number.
stringDefault: AUTO_COLORThe nodes' fill: `auto` (the palette by index) or a CSS colour; a node's own `color` wins.
linkColorstringDefault: 'source'The links' colour: `source` / `target` (the node's colour at that end) or a CSS colour; a link's own `color` wins.
neighbourDimnumberDefault: DEFAULT_NEIGHBOUR_DIMSet as an HTML attribute or JavaScript property. type: number.
activeColorstringDefault: DEFAULT_ACTIVE_COLORThe hovered / focused node or link.
enableMouseTrackingbooleanDefault: trueSet as an HTML attribute or JavaScript property. type: boolean.
tooltipFormat(detail: SankeyHitDetail) => stringDefault: undefinedPass as a JavaScript property. type: (detail: SankeyHitDetail) => string.
streamSourceSankeyStreamSourceDefault: undefinedA stream source for live data. Check the contract for the specific type.
streamMaxnumberDefault: undefinedThe maximum number of streaming data points to retain.
streamWindownumberDefault: undefinedThe streaming data range to keep visible.
SankeyEngineModeDefault: 'auto'Renderer selection: auto, standard, or pro. Engine selection is separate from permission to use a Pro chart type.
SankeyUnavailableBehaviourDefault: 'fallback'Allowed values: fallback, error. Default: 'fallback'.
Events 16
EventsDetail typeDescription
SankeyRenderResult & { tier: SankeyEngineTier }Emits rendering results in detail when chart drawing completes.
SankeyNodeEventDetailCustomEvent.detail type: SankeyNodeEventDetail. Event names are case-sensitive.
SankeyNodeEventDetail | nullCustomEvent.detail type: SankeyNodeEventDetail | null. Event names are case-sensitive.
SankeyLinkEventDetailCustomEvent.detail type: SankeyLinkEventDetail. Event names are case-sensitive.
SankeyLinkEventDetail | nullCustomEvent.detail type: SankeyLinkEventDetail | null. Event names are case-sensitive.
SankeySelectionChangeEventDetailCustomEvent.detail type: SankeySelectionChangeEventDetail. Event names are case-sensitive.
ChartPointContextMenuEventDetail<SankeyHitDetail>CustomEvent.detail type: ChartPointContextMenuEventDetail<SankeyHitDetail>. Event names are case-sensitive.
{ count: number; replaced: number }CustomEvent.detail type: { count: number; replaced: number }. Event names are case-sensitive.
{ dropped: number }CustomEvent.detail type: { dropped: number }. Event names are case-sensitive.
CartesianTooltipEventDetailWhether to display the built-in tooltip.
voidCustomEvent.detail type: void. Event names are case-sensitive.
CartesianTooltipActionEventDetailCustomEvent.detail type: CartesianTooltipActionEventDetail. Event names are case-sensitive.
voidCustomEvent.detail type: void. Event names are case-sensitive.
voidCustomEvent.detail type: void. Event names are case-sensitive.
voidCustomEvent.detail type: void. Event names are case-sensitive.
CartesianZoomChangeEventDetailFired after every zoom change (drag / pan / wheel / pinch / keyboard / api / reset) with the new state.
Methods 38

Stencil methods return Promises. Use await within an async function to read the result.

Method / ArgumentsReturn typeDescription
Promise<SankeyRenderResult>An asynchronous method. Check the argument and return types below.
Promise<SankeyEngineTier>An asynchronous method. Check the argument and return types below.
Promise<string | undefined>An asynchronous method. Check the argument and return types below.
data: SankeyDataPromise<void>An asynchronous method. Check the argument and return types below.
link: SankeyLinkInputPromise<void>Upsert one link (a tracked source → target pair replaces its link).
links: ReadonlyArray<SankeyLinkInput>Promise<void>An asynchronous method. Check the argument and return types below.
count: numberPromise<void>Drop the oldest streamed links (the `data` links are not the stream).
links: ReadonlyArray<SankeyLinkInput>Promise<void>An asynchronous method. Check the argument and return types below.
Promise<SankeyStreamSource | undefined>An asynchronous method. Check the argument and return types below.
Promise<ChartEngineStatus>Requested vs effective engine and why (CHART-ADD-08), with the chart.type.sankey license state.
options: { duration?: number; easing?: SankeyEasing; enabled?: boolean; type?: SankeyAnimationType }Promise<void>An asynchronous method. Check the argument and return types below.
Promise<void>An asynchronous method. Check the argument and return types below.
Promise<void>An asynchronous method. Check the argument and return types below.
Promise<void>An asynchronous method. Check the argument and return types below.
cssX: number, cssY: numberPromise<SankeyHitDetail | null>The node or link under a host-local CSS point (a node first, else the topmost ribbon), or null (always without a valid license).
index: numberPromise<SankeyNode | null>An asynchronous method. Check the argument and return types below.
id: stringPromise<SankeyNode | null>An asynchronous method. Check the argument and return types below.
Promise<SankeyNode[]>An asynchronous method. Check the argument and return types below.
Promise<SankeyLink[]>An asynchronous method. Check the argument and return types below.
Promise<number>An asynchronous method. Check the argument and return types below.
Promise<number>An asynchronous method. Check the argument and return types below.
Promise<SankeyExtent>An asynchronous method. Check the argument and return types below.
Promise<{ iterations: number; crossings: number; energy: number; curvature: number; crossingsComputed: boolean }>An asynchronous method. Check the argument and return types below.
Promise<SankeyNodeLabel[]>An asynchronous method. Check the argument and return types below.
Promise<SankeyLayoutResult>The layout in HOST-local CSS px as shown (the plot offset added; under a zoom, the viewport transform applied; while an update morph runs, its current frame): the node rects, the ribbons, the scale.
index: numberPromise<CartesianTooltipEventDetail | null>Open a tooltip by point index: nodes first, then directed links; null outside the graph or with the tooltip off.
Promise<void>Close every tooltip.
index: numberPromise<SankeyNodeEventDetail | null>Move the keyboard focus ring to a node (null off the nodes); emits nodeHover like the walk.
index: numberPromise<SankeyNodeEventDetail | null>Select (pin) a node: its neighbourhood stays highlighted after the pointer leaves; a negative or unknown index releases the selection. Emits selectionChanged when it changes.
index: numberPromise<SankeyLinkEventDetail | null>Select (pin) a link: its ribbon keeps the accent after the pointer leaves; a negative or unknown index releases the selection.
Promise<void>Release the selection (emits selectionChanged when there was one).
Promise<SankeySelection>The selection: the selected node's / link's detail (`null` = none); its anchors are Pro-derived, refused without a valid license.
request: CartesianZoomRequestPromise<CartesianZoomChangeEventDetail | null>Zoom to explicit windows over the unit extents: `x` / `y` as `{ min, max }` or `[min, max]` (`null` clears that orientation).
factor: number, anchorFraction?: numberPromise<CartesianZoomChangeEventDetail | null>Scale the current windows by `factor` (< 1 zooms in) around `anchorFraction` (0..1, default centre).
delta: { x?: number; y?: number }Promise<CartesianZoomChangeEventDetail | null>Slide the zoomed windows by unit-extent units (`{ x?, y? }`); a no-op at the full extent.
Promise<CartesianZoomChangeEventDetail | null>Back to the full diagram.
Promise<CartesianZoomState | null>The current zoom state (`null` = the full diagram).
request?: CartesianZoomExtentRequestPromise<CartesianZoomExtentDetail | null>The full extent (0 … 1) and key of the diagram's orientations (`null` before the first layout).