DocumentationNuxt Charts v3

Sankey Chart

Visualize flow relationships between nodes with the Sankey diagram component.

Show how values flow between categories. Sankey diagrams reveal relationships—like how website traffic moves through pages, or how budget allocations distribute across departments.

Basic Usage

Props

PropTypeDefaultDescription
data{ nodes: N[]; links: L[] }RequiredSankey data containing nodes and links arrays.
heightnumberRequiredHeight of the chart in pixels.
padding{ top: number; right: number; bottom: number; left: number }undefinedChart padding (top, right, bottom, left).
categoriesRecord<string, BulletLegendItemInterface>undefinedCategory colors and labels for the legend.
hideLegendbooleanfalseIf true, hides the chart legend.
legendPositionLegendPositionundefinedPosition of the legend.
legendStylestring | Record<string, string>undefinedCustom CSS style for the legend container.
label(node: N) => stringundefinedAccessor function for node labels.
subLabel(node: N) => stringundefinedAccessor function for node sub-labels.
nodeColor(node: N) => stringundefinedAccessor function or value for node colors.
linkColor(link: L) => stringundefinedAccessor function or value for link colors.
linkValue(link: L) => numberundefinedAccessor function for link values (flow amount).
nodeWidthnumber10Width of Sankey nodes in pixels.
nodeAlignSankeyNodeAlign'justify'Node alignment method: 'left', 'right', 'center', or 'justify'.
nodePaddingnumber10Vertical spacing between nodes in pixels.
nodeSort(node1: any, node2: any) => numberundefinedCustom sorting function for nodes.
linkSort(link1: any, link2: any) => numberundefinedCustom sorting function for links.
iterationsnumber32Sankey layout algorithm iterations.
hideTooltipbooleanfalseIf true, hides the tooltip.
tooltipTooltipConfigundefinedTooltip configuration (hideDelay, showDelay, followCursor).
highlightSubtreeOnHoverbooleanfalseHighlight the subtree when hovering a node or link.
labelFontSizenumberundefinedLabel font size in pixels.
labelColor(node: N) => stringundefinedAccessor function or value for label colors.
labelMaxWidthnumber70Maximum label width in pixels.
durationnumberundefinedAnimation duration in milliseconds.

Data Format

Provide an object with nodes and links arrays:

types.ts
interface SankeyNode {
  id: string;
  label?: string;
  [key: string]: any;
}

interface SankeyLink {
  source: string; // node id
  target: string; // node id
  value: number; // flow amount
}

interface SankeyData {
  nodes: SankeyNode[];
  links: SankeyLink[];
}

Node Alignment

Control how nodes align horizontally:

  • 'left' - Align all nodes to the left
  • 'right' - Align all nodes to the right
  • 'center' - Center nodes
  • 'justify' - Spread nodes across the width (default)

Events

EventPayloadDescription
click{ event: MouseEvent, values?: any }Fired when a node or link is clicked.

Slots

SlotPropsDescription
tooltip{ values: any }Custom tooltip content.
fallback{}Fallback content while chart loads.