SankeyChart
SankeyChart, SankeyChartProps, SankeyLinkColor, SankeyNodeAlignment and 1 more: generated from the source of active-charts.
Exported by @workspace/. Generated from the package source; part of the index of every export.
Sankey Chart#
Generic over TNode, TLink; the props below name them.
Props
- Type
number
Container height in pixels. Width is always responsive.
- Type
LinkDatum<TLink Extra>[]
Graph links. source and target reference node ids.
- Type
NodeDatum<TNode Extra>[]
Graph nodes. Each id must be unique.
- Type
StandaloneAccessibility Options
Accessible name, description, data table and keyboard navigation. No announcements: it switches <Chart>'s interaction announcements, which this family does not make.
- Type
InteractionAnimation Option
How the tooltip and the context's attention move; the family has no entrance. false turns every interpolation off.
- Type
string
Optional className applied to the outer container.
- Type
string[]
Categorical palette for this chart only: replaces the host palette (--chart- … --chart-) in the chart's colour assignment, and nothing else. It is a data encoding, not a theme: surfaces, text, grid and semantic roles keep coming from the CSS token contract, and a series, datum or annotation that sets its own colour keeps it. Any CSS colour string (a public token reference such as var(--chart-, hex, oklch).
- Type
readonly ChartItem Ref[]
The initial selection of an uncontrolled chart.
- Type
"ltr""rtl"
The chart's UI direction: the reading direction of its HTML text and chrome (tooltip, legend, menus, the accessible table), and the direction the context menu carries under <body>.
Left out, the chart inherits the direction of the page around it (the nearest dir attribute, else the computed CSS direction) and follows a later change of that attribute. It is never inferred from locale, and it never reverses an axis or reorders data: reversed stays an explicit axis choice. Under rtl the chrome mirrors (legend flow, tooltip side, context menu and submenus, report text in exports), a title-like label starts at the inline start, and a label placed by geometry (an axis tick, a slice or bar label) keeps its physical side; plot arrow keys stay spatial while legend and menu arrows follow the reading direction.
- Type
(Omit<ChartEvents, "on Legend Chang…
The chart's events, and the selection events (T8): an item is a node ({kind: 'node', id}) or a link ({kind: 'link', id?, source, target}). Space selects the keyboard's node or link and Shift+Enter activates it; Enter keeps moving between nodes and links.
- Type
number
Horizontal space reserved on each side for the labels of the first and the last column, in pixels. Default: measured from those labels (VQ5), up to a quarter of the width per side.
- Type
SankeyLink Color
The colour of a flow (T6). Default 'source': its source node's; 'target': its target node's; 'gradient': from the source's colour to the target's along the flow. A link's own color wins in every mode. Colour carries a node's identity along its flows only: the tooltip, the table and the keyboard name both ends.
- Type
ValuePresentation
Presentation input for axis labels, tooltips, labels and accessibility announcements: a locale code (notation follows the language), or a presentation-context object ({language) carrying language and notation independently. date is the normal human date shape a plain date consumer inherits; an axis that declares its own preset for readability keeps it. Forwarded untouched to the central @workspace/; the package never resolves tenant or application settings itself. When omitted, <Chart supplies it; with neither, the chart throws a configuration error (no 'en' fallback, active-format D14). Object inputs must be referentially stable across renders.
- Type
SankeyNode Alignment
The column of a node (T6). Default 'justify': every node at its distance from the sources, and every sink in the last column. 'source': every node at its distance from the sources (a sink can stand in a middle column). 'sink': every node at its distance to the sinks (a source can stand in a middle column). 'center': as 'source', with a source drawn just before its first target. Flow terms, not left and right: the sankey does not mirror in rtl.
- Type
SankeyNode Order
The order of the nodes within a column (T6). Default 'auto': the layout's own order, which reduces crossing flows. 'input': the order of nodes, so comparable charts keep every node in its place. The data table keeps the order of links either way.
- Type
number
Vertical padding between nodes in pixels. Default: 16.
- Type
number
Node width in pixels. Default: 20.
- Type
Ref<ChartExport Handle>
Imperative handle: exports and element access. A family built on this type has no data-range zoom, so its handle has no set. Allows getting a ref to the component instance. Once the component unmounts, React will set ref. to null (or call the ref with null if you passed a callback ref).
- Type
readonly ChartItem Ref[]
The selection, controlled by the host. The chart draws, announces and lists the items it resolves to and never changes it; the host updates it from on. A request the host applies is announced when the host passes it back; one it ignores is never announced. A reference to an item that is hidden, zoomed or drilled out of view, or not in the data stays in the host's selection and is not shown as selected.
- Type
ChartTranslate Fn
The host translator for every text the chart shows or announces. When omitted, <Chart supplies it; with neither, the chart throws a configuration error (no English fallback, ADR-028).
- Type
StandaloneTooltip Option<never>
Tooltip of the node or link under the pointer: enabled, renderer, value and style (ADR-082, LAB-AT17).
- Type
ChartValue Semantics
What the flow values mean (BC1): unit and precision, declared once with the type the Cartesian charts read (Chart). The tooltip of a link and of a node (its fixed value, else the larger of its in- and outflow, as today), the data table and the announcement write the value in it; tooltip. still wins in the tooltip. The node labels keep their names. Without a declaration the chart presentation's number applies. CSV and Copy value keep the raw number.
- Type
number
Optional fixed width in pixels. Default: fill container.
Events
Called by the component when something happens.
- Type
(selection, change) => void
Fired when the reader changes the selection (pointer, touch or keyboard), and when an uncontrolled selection drops items the data no longer contains. selection is the complete selection the change makes; it keeps every reference the selection held, of whatever form. On a controlled chart it is a proposal (change.), computed from the current selected and never from an earlier proposal; the host applies it, changes it or ignores it.
- Type
(event) => void
Fired when a chart animation completes.
'load': initial mount animation finished (or immediately if animation disabled / prefers-reduced-motion is active).'update': data-update transition finished.
Not triggered by zoom animations (use on) or tooltip fades.
- Type
(result) => void
Fired after a successful export action (PNG/SVG/CSV/PDF), including from the context menu and from imperative Chart calls.
- Type
(format, error) => void
Fired when an export could not produce its file (W11), from the handle as well as from the context menu. Without it a failed context-menu export is reported as an error diagnostic (<Chart).
- Type
(item, source) => void
Fired when the reader activates an item: a click or tap on it, or Enter on the focused item (Shift+Enter on a sankey, whose Enter moves between nodes and links). With a handler, Enter activates instead of opening the context menu (Shift+F10 and the context-menu key still open it).
- Type
() => void
Fired exactly once per chart instance, after the first successful mount with valid dimensions and before any entrance animation starts. "Ready" means: the SVG is in the DOM, layout has run with real dimensions, and the chart can be queried by integration tests.
Distinct from on with type: 'load', which fires *after* the load animation finishes. A chart with animation={false} still fires on — animation state has no effect on readiness.
A new React key on the host produces a new component instance and on fires again. Identity changes of the callback itself after the first fire are ignored (latch is per-instance).
Consumer requirement — stable from first render. The latch closes on the first effect run regardless of whether on was defined at that moment. If on is initially undefined and later resolves to a function, the callback will never fire — the latch has already closed with a no-op. Pass a stable reference (typically via use) or pass the final function unconditionally from the first render.
Other props, such as the standard attributes of the underlying element, className and ref, are passed through.
Types#
The props of Sankey, each described in its prop list on this page.
interface SankeyChartProps<
TNodeExtra extends Record<string, unknown> = Record<string, unknown>,
TLinkExtra extends Record<string, unknown> = Record<string, unknown>,
>
extends
Omit<GraphChartProps<TNodeExtra, TLinkExtra>, 'events'>,
ChartSelectionProps<
never,
| ChartNodeItem<NodeDatum<TNodeExtra>>
| ChartLinkItem<LinkDatum<TLinkExtra>>,
Omit<ChartSelectionOptions, 'itemKey'>
> {
events?: NonNullable<GraphChartProps<TNodeExtra, TLinkExtra>['events']> &
ChartSelectionEvents<
never,
| ChartNodeItem<NodeDatum<TNodeExtra>>
| ChartLinkItem<LinkDatum<TLinkExtra>>
>;
nodeWidth?: number;
nodePadding?: number;
labelPadding?: number;
valueSemantics?: ChartValueSemantics;
nodeAlignment?: SankeyNodeAlignment;
linkColor?: SankeyLinkColor;
nodeOrder?: SankeyNodeOrder;
}Whose colour a flow takes (T6).
type SankeyLinkColor = 'source' | 'target' | 'gradient';The column rule of a sankey's nodes (T6).
type SankeyNodeAlignment = 'justify' | 'source' | 'sink' | 'center';- Type
type SankeyNode Order = 'auto' | 'input';
The order of a sankey's nodes within a column (T6).