Skip to content

SankeyChart

Defined in: charts/sankey.ts:23

Canvas 2D Sankey diagram. Pass a {nodes, links} object directly via setSankey() (or via setData([], { nodes, links } as any) from React).

Layout is delegated to layoutSankey (column-DAG + iterative relaxation), keeping draw passes O(nodes + links).

const chart = new SankeyChart('#chart');
chart.setSankey(
[{ id: 'A' }, { id: 'B' }, { id: 'C' }],
[{ source: 'A', target: 'B', value: 10 }, { source: 'A', target: 'C', value: 5 }],
);

new SankeyChart(container, config?): SankeyChart

Defined in: charts/sankey.ts:33

string | HTMLElement

SankeyChartConfig = {}

SankeyChart

BaseChart.constructor

animator: Animator

Defined in: core/base.ts:63

BaseChart.animator


animProgress: number = 1

Defined in: core/base.ts:74

BaseChart.animProgress


canvas: HTMLCanvasElement

Defined in: core/base.ts:60

BaseChart.canvas


config: SankeyChartConfig & Required<Pick<BaseChartConfig, "title" | "animate" | "animDuration" | "animEasing" | "responsive" | "showGrid" | "showTooltip" | "showLegend" | "legendPosition" | "subtitle">> & BaseChartConfig

Defined in: charts/sankey.ts:24

BaseChart.config


container: HTMLElement

Defined in: core/base.ts:51

Host element the canvas was mounted into.

BaseChart.container


ctx: CanvasRenderingContext2D

Defined in: core/base.ts:61

BaseChart.ctx


height: number = 0

Defined in: core/base.ts:89

BaseChart.height


hoverIndex: number = -1

Defined in: core/base.ts:65

BaseChart.hoverIndex


hoverSeriesIndex: number = -1

Defined in: core/base.ts:73

Index of the series under the cursor, or -1 when the hover is not series-specific (e.g. a column hit on a multi-series line chart). Charts that can pinpoint a series — bubble, scatter, network, sankey, marimekko, treemap — set this in their _onMouse. Single-series charts report 0 automatically via _buildClickEvent.

BaseChart.hoverSeriesIndex


padding: Padding

Defined in: core/base.ts:90

BaseChart.padding


resolved: ResolvedData

Defined in: core/base.ts:75

BaseChart.resolved


theme: Theme

Defined in: core/base.ts:62

BaseChart.theme


tooltip: Tooltip | null

Defined in: core/base.ts:64

BaseChart.tooltip


width: number = 0

Defined in: core/base.ts:88

BaseChart.width

get plotArea(): PlotArea

Defined in: core/base.ts:328

PlotArea

BaseChart.plotArea

_draw(): void

Defined in: charts/sankey.ts:120

void

BaseChart._draw


_onMouse(e): void

Defined in: charts/sankey.ts:93

MouseEvent

void

BaseChart._onMouse


destroy(): void

Defined in: core/base.ts:461

void

BaseChart.destroy


resize(): void

Defined in: core/base.ts:432

void

BaseChart.resize


setData(_data, mapping?): void

Defined in: charts/sankey.ts:51

React passes the graph through mapping; we forward to setSankey.

any

any

void

BaseChart.setData


setSankey(nodes, links): void

Defined in: charts/sankey.ts:42

Set the Sankey graph and trigger an entry animation.

SankeyNode[]

SankeyLink[]

void


setTheme(theme): void

Defined in: core/base.ts:389

Switch theme. Accepts a registered theme name ('midnight', 'arctic', 'ember', 'forest', or any name passed to addTheme) or a full Theme object — same surface that the constructor accepts via config.theme.

Theme | ThemeName

void

BaseChart.setTheme


toDataURL(type?, quality?, options?): string

Defined in: core/base.ts:446

Export the current chart as a data URL.

canvas.toDataURL() always returns the backing-store bitmap, which is DPR-multiplied — a 400×300 chart on a DPR=2 display exports as 800×600. Pass { scale: 'css' } to downscale the export to on-screen CSS dimensions (typical for “Save as PNG” buttons); the default 'native' keeps the full backing-store resolution.

string = 'image/png'

number = 0.92

"native" | "css"

string

BaseChart.toDataURL


update(arg, mapping?): void

Defined in: charts/sankey.ts:65

update({ nodeWidth: ... }) etc. — invalidate so the next draw re-lays out.

any

any

void

BaseChart.update