apexsankey 1.5.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/.github/workflows/publish.yml +8 -5
  2. package/README.md +39 -29
  3. package/apexsankey.d.ts +472 -0
  4. package/apexsankey.es.min.js +1 -1
  5. package/apexsankey.min.js +1 -1
  6. package/demo/basic-sankey.html +2 -2
  7. package/demo/css-theming.html +438 -0
  8. package/demo/sankey-alternate-node.html +1 -2
  9. package/demo/sankey-custom-fonts.html +3 -2
  10. package/demo/sankey-edge-options.html +3 -2
  11. package/demo/sankey-node-customization.html +3 -3
  12. package/demo/sankey-node-overlapping.html +3 -2
  13. package/demo/sankey-path-highlight.html +199 -0
  14. package/package.json +8 -8
  15. package/CHANGELOG.md +0 -14
  16. package/LICENSE +0 -80
  17. package/index.d.ts +0 -4
  18. package/lib/layout/edgeOrdering/index.d.ts +0 -1
  19. package/lib/layout/edgeOrdering/linkDirection.d.ts +0 -1
  20. package/lib/layout/edgeOrdering/linkTypeOrder.d.ts +0 -1
  21. package/lib/layout/edgeOrdering/orderEdges.d.ts +0 -13
  22. package/lib/layout/edgePositioning/index.d.ts +0 -1
  23. package/lib/layout/edgePositioning/linkLayout.d.ts +0 -3
  24. package/lib/layout/edgePositioning/utils.d.ts +0 -8
  25. package/lib/layout/layout.d.ts +0 -44
  26. package/lib/layout/nodeOrdering/addDummyNodes.d.ts +0 -2
  27. package/lib/layout/nodeOrdering/countCrossings.d.ts +0 -30
  28. package/lib/layout/nodeOrdering/index.d.ts +0 -2
  29. package/lib/layout/nodeOrdering/initialOrdering.d.ts +0 -1
  30. package/lib/layout/nodeOrdering/ordering.d.ts +0 -11
  31. package/lib/layout/nodeOrdering/swapNodes.d.ts +0 -1
  32. package/lib/layout/nodeOrdering/weightedMedian.d.ts +0 -7
  33. package/lib/layout/nodePositioning/horizontal.d.ts +0 -2
  34. package/lib/layout/nodePositioning/index.d.ts +0 -2
  35. package/lib/layout/nodePositioning/justified.d.ts +0 -15
  36. package/lib/layout/rankAssignment/assignRanks.d.ts +0 -4
  37. package/lib/layout/rankAssignment/groupedGraph.d.ts +0 -10
  38. package/lib/layout/rankAssignment/index.d.ts +0 -1
  39. package/lib/layout/rankAssignment/initialRank.d.ts +0 -4
  40. package/lib/layout/rankAssignment/makeAcyclic.d.ts +0 -12
  41. package/lib/layout/utils.d.ts +0 -3
  42. package/lib/models/ColorPalette.d.ts +0 -4
  43. package/lib/models/Edge.d.ts +0 -2
  44. package/lib/models/Graph.d.ts +0 -36
  45. package/lib/models/Node.d.ts +0 -4
  46. package/lib/models/Options.d.ts +0 -38
  47. package/lib/models/Paper.d.ts +0 -20
  48. package/lib/sankey.d.ts +0 -13
@@ -5,6 +5,10 @@ on:
5
5
  branches:
6
6
  - main
7
7
 
8
+ permissions:
9
+ id-token: write
10
+ contents: read
11
+
8
12
  jobs:
9
13
  publish:
10
14
  runs-on: ubuntu-latest
@@ -12,9 +16,8 @@ jobs:
12
16
  - uses: actions/checkout@v4
13
17
  - uses: actions/setup-node@v4
14
18
  with:
15
- node-version: '20'
16
- registry-url: 'https://registry.npmjs.org' # Or your custom registry
19
+ node-version: "20"
20
+
21
+ - run: npm install -g npm@latest
17
22
  - run: npm install
18
- - run: npm publish
19
- env:
20
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
23
+ - run: npm publish --provenance
package/README.md CHANGED
@@ -44,7 +44,7 @@ To create a basic sankey with minimal configuration, write as follows:
44
44
  nodeWidth: 20,
45
45
  };
46
46
  const sankey = new ApexSankey(document.getElementById('sankey-container'), options);
47
- const graph = sankey.render(data);
47
+ const graph = sankey.render({ nodes: data.nodes, edges: data.edges, options: sankey.options });
48
48
  ```
49
49
 
50
50
  ## Setting the License
@@ -63,32 +63,41 @@ const graph = sankey.render(data);
63
63
 
64
64
  ## ApexSankey Options
65
65
 
66
- The layout can be configured by either setting the properties in the table below by passing a second arg to ApexSankey with these properties set. The latter takes precedence.
67
-
68
- | Options | Default | Description |
69
- | --- | --- | --- |
70
- | width | 800 | The width of graph container |
71
- | height | 800 | The height of graph container |
72
- | canvasStyle | None | The css styles for canvas root container |
73
- | spacing | 100 | The spacing from top and left of graph container |
74
- | nodeWidth | 20 | The width of graph nodes |
75
- | nodeBorderWidth | 1 | The border width of the nodes in pixels |
76
- | nodeBorderColor | none | The border color of the nodes |
77
- | onNodeClick | empty function | The callback function for node click. Node object will be parameter for callback. |
78
- | edgeOpacity | 0.4 | The opacity value for edges. Values must be between 0 to 1 and in fraction. |
79
- | edgeGradientFill | true | Enable gradient fill based on source and target node colors. |
80
- | edgeGap | 2 | The gap in pixels between edges at node connection points. |
81
- | whitespace | 0.18 | Fraction of vertical space used for margins between nodes (0-1). Lower values make nodes taller. |
82
- | enableTooltip | false | Enable tooltip on hover of nodes |
83
- | enableToolbar | false | Enable/disable graph toolbar |
84
- | tooltipId | `sankey-tooltip-container` | The tooltip HTML element id |
85
- | tooltipTemplate | tooltipTemplate | The HTML template for tooltip |
86
- | tooltipBorderColor | `#BCBCBC` | The border color of tooltip |
87
- | tooltipBGColor | `#FFFFFF` | The background color of tooltip |
88
- | fontSize | `14px` | The size of font of nodes |
89
- | fontFamily | None | The font family of nodes |
90
- | fontWeight | 400 | The font weight of nodes |
91
- | fontColor | `#000000` | The font color of nodes |
66
+ The layout can be configured by passing a second argument to `ApexSankey` with the properties listed below.
67
+
68
+ | Option | Type | Default | Description |
69
+ | --- | --- | --- | --- |
70
+ | `width` | `number \| string` | `'100%'` | Width of the canvas. Accepts a pixel number or CSS percentage string. |
71
+ | `height` | `number \| string` | `'auto'` | Height of the canvas. `'auto'` derives height from width at a 1.6:1 ratio. |
72
+ | `canvasStyle` | `string` | built-in border | Arbitrary CSS injected onto the SVG root container element. |
73
+ | `spacing` | `number` | `20` | Horizontal spacing between node columns in pixels. |
74
+ | `nodeWidth` | `number` | `20` | Width of each node rectangle in pixels. |
75
+ | `nodeBorderWidth` | `number` | `1` | Border width of each node in pixels. |
76
+ | `nodeBorderColor` | `string \| null` | `null` | CSS color for the node border. `null` disables the border. |
77
+ | `onNodeClick` | `(node: SankeyNode) => void` | `undefined` | Callback fired when the user clicks a node. |
78
+ | `edgeOpacity` | `number` | `0.4` | Opacity of edges (0–1). |
79
+ | `edgeGradientFill` | `boolean` | `true` | Fill edges with a gradient between source and target node colors. |
80
+ | `edgeGap` | `number` | `2` | Gap in pixels between adjacent edges at node connection points. |
81
+ | `whitespace` | `number` | `0.18` | Fraction of vertical space used as margins between nodes (0–1). Lower = taller nodes. |
82
+ | `viewPortWidth` | `number` | `800` | Internal SVG viewport width in pixels. |
83
+ | `viewPortHeight` | `number` | `500` | Internal SVG viewport height in pixels. |
84
+ | `highlightConnectedPath` | `boolean` | `true` | Highlight the connected flow path when hovering a node or edge. |
85
+ | `dimOpacity` | `number` | `0.15` | Opacity for dimmed (unrelated) elements when path highlighting is active. |
86
+ | `animation` | `{ enabled: boolean, duration: number }` | `{ enabled: true, duration: 800 }` | Entrance animation. Automatically disabled when `prefers-reduced-motion` is set. |
87
+ | `enableTooltip` | `boolean` | `true` | Show edge tooltips on hover. |
88
+ | `enableToolbar` | `boolean` | `true` | Show the zoom/pan toolbar. |
89
+ | `tooltipId` | `string` | `'apexsankey-tooltip-container'` | HTML `id` for the tooltip container element. |
90
+ | `tooltipTemplate` | `(content: TooltipContent) => string` | built-in | Custom function returning an HTML string for the edge (source→target) tooltip. |
91
+ | `nodeTooltipTemplate` | `(content: NodeTooltipContent) => string` | built-in | Custom function returning an HTML string for the per-node tooltip. |
92
+ | `tooltipTheme` | `'light' \| 'dark'` | `undefined` | Overrides `tooltipBGColor`/`tooltipBorderColor`/`tooltipFontColor` with a preset. |
93
+ | `tooltipBorderColor` | `string` | `'#E2E8F0'` | Border color of the tooltip. |
94
+ | `tooltipBGColor` | `string` | `'#FFFFFF'` | Background color of the tooltip. |
95
+ | `tooltipFontColor` | `string` | `'#1a1a1a'` | Font color inside the tooltip. |
96
+ | `fontColor` | `string` | `'#212121'` | CSS color for node labels. |
97
+ | `fontFamily` | `string` | `''` | CSS font-family for node labels. Falls back to the page default when empty. |
98
+ | `fontSize` | `string` | `'14px'` | CSS font-size for node labels. |
99
+ | `fontWeight` | `string` | `'400'` | CSS font-weight for node labels. |
100
+ | `a11y` | `{ enabled?: boolean, diagramLabel?: string, description?: string }` | `{ enabled: true }` | WCAG 2.1 AA accessibility options. |
92
101
 
93
102
  Default tooltip template
94
103
 
@@ -115,8 +124,9 @@ Passed data should be an object containing nodes, edges and options. Nodes, edge
115
124
 
116
125
  ```json
117
126
  {
118
- "id": "1", // required
119
- "title": "A" // required
127
+ "id": "1", // required
128
+ "title": "A", // required
129
+ "color": "#e74c3c" // optional — overrides the auto-assigned palette color
120
130
  }
121
131
  ```
122
132
 
@@ -0,0 +1,472 @@
1
+ declare abstract class BaseChart {
2
+ /** @internal */
3
+ protected element: HTMLElement;
4
+ /** Destroys the chart instance and cleans up DOM resources. */
5
+ destroy(): void;
6
+ /** Returns the unique identifier for this chart instance. */
7
+ getInstanceId(): string;
8
+ }
9
+ /** @internal */
10
+ declare class ChartContext {
11
+ constructor(element: HTMLElement, instanceId?: string);
12
+ isShadowDOM(): boolean;
13
+ getInstanceId(): string;
14
+ destroy(): void;
15
+ }
16
+ /** @internal */
17
+ declare class G extends WrappedEl {}
18
+ /** @internal */
19
+ declare class SvgCanvas {}
20
+ /** @internal */
21
+ declare class WrappedEl {}
22
+
23
+
24
+
25
+
26
+
27
+
28
+ /** Options for WCAG 2.1 AA accessibility support */
29
+ export declare interface A11yOptions {
30
+ readonly a11y?: {
31
+ /** Whether accessibility features are enabled. Default: true */
32
+ readonly enabled?: boolean;
33
+ /** Overrides the auto-generated aria-label on the SVG root */
34
+ readonly diagramLabel?: string;
35
+ /** Populates the <desc> element for a longer optional description */
36
+ readonly description?: string;
37
+ };
38
+ }
39
+
40
+ /** Options for entrance animation */
41
+ export declare interface AnimationOptions {
42
+ readonly animation: {
43
+ /** Whether entrance animation is enabled. Automatically disabled when prefers-reduced-motion is set. Default: true */
44
+ readonly enabled: boolean;
45
+ /** Total duration of the animation in milliseconds. Default: 800 */
46
+ readonly duration: number;
47
+ };
48
+ }
49
+
50
+ declare class ApexSankey extends BaseChart {
51
+ graph: SankeyGraph;
52
+ options: SankeyOptions;
53
+ /**
54
+ * Create a new ApexSankey instance.
55
+ *
56
+ * Dimensions are applied to the host element immediately. Call `render()` to
57
+ * build the SVG diagram after construction.
58
+ *
59
+ * @param element - The `HTMLElement` that will contain the Sankey SVG.
60
+ * @param options - Partial `SankeyOptions` to override defaults. Any omitted
61
+ * field falls back to its default value (see `DefaultOptions`).
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * import { ApexSankey } from 'apexsankey';
66
+ * const sankey = new ApexSankey(document.getElementById('chart')!, {
67
+ * width: 800,
68
+ * height: 500,
69
+ * });
70
+ * ```
71
+ */
72
+ constructor(element: HTMLElement, options?: Partial<SankeyOptions>);
73
+ /**
74
+ * Set the global ApexCharts license key.
75
+ *
76
+ * Call this once before creating any chart instance, typically at app startup.
77
+ * Without a valid license the chart renders with a watermark.
78
+ *
79
+ * @param key - The license key string provided by ApexCharts.
80
+ *
81
+ * @example
82
+ * ```ts
83
+ * import { ApexSankey } from 'apexsankey';
84
+ * ApexSankey.setLicense('YOUR_LICENSE_KEY');
85
+ * ```
86
+ */
87
+ static setLicense(key: string): void;
88
+ private setupElementDimensions;
89
+ private handleWatermark;
90
+ /**
91
+ * Render the Sankey diagram into the element supplied in the constructor.
92
+ *
93
+ * Constructs the internal graph layout and writes the SVG to the DOM.
94
+ * If `options.enableToolbar` is `true`, the export toolbar is also rendered.
95
+ *
96
+ * @param data - A `GraphData` object containing three fields:
97
+ * - `nodes` — array of `{ id, title }` objects representing each entity.
98
+ * - `edges` — array of `{ source, target, value, type }` objects representing
99
+ * flow connections between nodes. `value` determines link width.
100
+ * - `options` — the full resolved `SankeyOptions` for this render.
101
+ * @returns The internal `SankeyGraph` instance, which exposes `exportToSvg()`
102
+ * for programmatic SVG export after render.
103
+ *
104
+ * @throws {Error} If the container element is not found.
105
+ *
106
+ * @example
107
+ * ```ts
108
+ * sankey.render({
109
+ * nodes: [
110
+ * { id: 'a', title: 'Source A' },
111
+ * { id: 'b', title: 'Target B' },
112
+ * ],
113
+ * edges: [
114
+ * { source: 'a', target: 'b', value: 42, type: 'flow' },
115
+ * ],
116
+ * options: sankey.options,
117
+ * });
118
+ * ```
119
+ */
120
+ render(data: GraphData): SankeyGraph;
121
+ }
122
+ export { ApexSankey }
123
+ export default ApexSankey;
124
+
125
+ /**
126
+ * Layout, canvas, and general behaviour options for the Sankey diagram.
127
+ *
128
+ * Controls canvas dimensions, column spacing, the zoom/pan toolbar, and the
129
+ * internal SVG viewport. Compose with the other sub-option interfaces via
130
+ * `SankeyOptions`.
131
+ */
132
+ export declare interface CommonOptions {
133
+ /** Arbitrary CSS injected onto the SVG root container element. */
134
+ readonly canvasStyle: string;
135
+ /** Show the zoom/pan toolbar. @default true */
136
+ readonly enableToolbar: boolean;
137
+ /** Height of the canvas. Use `'auto'` to derive height from width at a 1.6:1 ratio. @default 'auto' */
138
+ readonly height: number | string;
139
+ /** Horizontal spacing between node columns in pixels. @default 20 */
140
+ readonly spacing: number;
141
+ /** Internal SVG viewport height in pixels. @default 500 */
142
+ readonly viewPortHeight: number;
143
+ /** Internal SVG viewport width in pixels. @default 800 */
144
+ readonly viewPortWidth: number;
145
+ /** Width of the canvas. Accepts a pixel number or CSS percentage string. @default '100%' */
146
+ readonly width: number | string;
147
+ }
148
+
149
+ /** Label attached to a graph edge during the layout pipeline */
150
+ declare interface EdgeLabel {
151
+ value?: number;
152
+ dy?: number;
153
+ x0?: number;
154
+ y0?: number;
155
+ x1?: number;
156
+ y1?: number;
157
+ d0?: string;
158
+ d1?: string;
159
+ r0?: number;
160
+ r1?: number;
161
+ Rmax?: number;
162
+ points?: EdgePoint[];
163
+ data?: Record<string, unknown> | null;
164
+ origEdge?: GraphEdge;
165
+ origLabel?: EdgeLabel;
166
+ source?: NodeLabel;
167
+ target?: NodeLabel;
168
+ delta?: number;
169
+ temp?: boolean;
170
+ reversed?: boolean;
171
+ reverse?: boolean;
172
+ id?: string;
173
+ }
174
+
175
+ /**
176
+ * Visual options for the curved flow bands (edges) between nodes.
177
+ *
178
+ * Controls opacity, gradient fill, and the gap between adjacent edges
179
+ * at each node connection point.
180
+ */
181
+ export declare interface EdgeOptions {
182
+ /** Gap in pixels between adjacent edges at their node connection points. @default 2 */
183
+ readonly edgeGap: number;
184
+ /** When true, edges are filled with a gradient between source and target node colors. @default true */
185
+ readonly edgeGradientFill: boolean;
186
+ /** Opacity of edges (0–1). @default 0.4 */
187
+ readonly edgeOpacity: number;
188
+ }
189
+
190
+ /** A single waypoint along an edge path */
191
+ declare interface EdgePoint {
192
+ d?: string;
193
+ ro?: number;
194
+ ri?: number;
195
+ r0?: number;
196
+ r1?: number;
197
+ x?: number;
198
+ y?: number;
199
+ style?: string;
200
+ }
201
+
202
+ /**
203
+ * Typography options for the node label text.
204
+ *
205
+ * These map directly to CSS font properties. Applied to all node labels;
206
+ * per-node overrides are not currently supported.
207
+ */
208
+ export declare interface FontOptions {
209
+ /** CSS color for node labels. @default '#212121' */
210
+ readonly fontColor: string;
211
+ /** CSS font-family for node labels. Falls back to the page default when empty. */
212
+ readonly fontFamily: string;
213
+ /** CSS font-size for node labels, e.g. `'14px'`. @default '14px' */
214
+ readonly fontSize: string;
215
+ /** CSS font-weight for node labels. @default '400' */
216
+ readonly fontWeight: string;
217
+ }
218
+
219
+ /**
220
+ * Input data object passed to `ApexSankey.render()`.
221
+ *
222
+ * @example
223
+ * ```ts
224
+ * sankey.render({
225
+ * nodes: [
226
+ * { id: 'a', title: 'Source A' },
227
+ * { id: 'b', title: 'Target B' },
228
+ * ],
229
+ * edges: [
230
+ * { source: 'a', target: 'b', value: 42, type: 'revenue' },
231
+ * ],
232
+ * options: sankey.options,
233
+ * });
234
+ * ```
235
+ */
236
+ export declare interface GraphData {
237
+ /** Array of edges (flows) connecting nodes. */
238
+ readonly edges: SankeyGraphEdge[];
239
+ /** Array of nodes (entities) in the diagram. */
240
+ readonly nodes: SankeyGraphNode[];
241
+ /** Resolved `SankeyOptions` for this render pass. Typically `sankey.options`. */
242
+ readonly options: SankeyOptions;
243
+ }
244
+
245
+ /**
246
+ * Shared structural types for the Sankey layout pipeline.
247
+ * These mirror the subset of Graph methods used across layout modules.
248
+ */
249
+ declare interface GraphEdge {
250
+ v: string;
251
+ w: string;
252
+ name?: string;
253
+ }
254
+
255
+ /** Options for connected path highlighting on hover */
256
+ export declare interface InteractionOptions {
257
+ /** When true, hovering a node or edge highlights the connected flow path. Default: true */
258
+ readonly highlightConnectedPath: boolean;
259
+ /** Opacity for dimmed (unrelated) elements when path highlighting is active. Default: 0.15 */
260
+ readonly dimOpacity: number;
261
+ }
262
+
263
+ /**
264
+ * Controls how much vertical whitespace is distributed between node rectangles.
265
+ *
266
+ * Lower `whitespace` values produce taller, more compact nodes; higher values
267
+ * add more padding between them.
268
+ */
269
+ export declare interface LayoutOptions {
270
+ /** Fraction of vertical space used as margins between nodes (0–1). Lower values produce taller nodes. @default 0.18 */
271
+ readonly whitespace: number;
272
+ }
273
+
274
+ /** Shape of node user data attached to a graph node */
275
+ export declare interface NodeData {
276
+ id?: string;
277
+ title?: string;
278
+ color?: string;
279
+ direction?: string;
280
+ forceY?: number;
281
+ }
282
+
283
+ /** Label attached to a graph node during the layout pipeline */
284
+ declare interface NodeLabel {
285
+ rank?: number;
286
+ value?: number;
287
+ dy?: number;
288
+ y?: number;
289
+ x?: number;
290
+ id?: string;
291
+ direction?: string;
292
+ dummy?: boolean;
293
+ spaceAbove?: number;
294
+ spaceBelow?: number;
295
+ data?: NodeData | null;
296
+ incoming?: GraphEdge[];
297
+ outgoing?: GraphEdge[];
298
+ nodes?: string[];
299
+ type?: string;
300
+ depth?: number;
301
+ thread?: string;
302
+ }
303
+
304
+ /**
305
+ * Visual options for the node rectangles.
306
+ *
307
+ * Controls node width, border, and the `onNodeClick` callback.
308
+ * Node colors are derived from the palette by default; override per-node
309
+ * by setting `color` on the `SankeyGraphNode`.
310
+ */
311
+ export declare interface NodeOptions {
312
+ /** CSS color for the node border. Set to `null` to disable. @default null */
313
+ readonly nodeBorderColor: string | null;
314
+ /** Border width of each node in pixels. @default 1 */
315
+ readonly nodeBorderWidth: number;
316
+ /** Width of each node rectangle in pixels. @default 20 */
317
+ readonly nodeWidth: number;
318
+ /** Callback fired when the user clicks a node. Receives a `SankeyNode` object. */
319
+ readonly onNodeClick?: (node: SankeyNode) => void;
320
+ }
321
+
322
+ /** Data passed to the nodeTooltipTemplate callback */
323
+ export declare interface NodeTooltipContent {
324
+ node?: NodeData | null;
325
+ value?: number;
326
+ }
327
+
328
+ declare class Paper {
329
+ element: HTMLElement;
330
+ options: SankeyOptions;
331
+ protected chartContext: ChartContext;
332
+ canvas: SvgCanvas;
333
+ constructor(element: HTMLElement, options: SankeyOptions, chartContext: ChartContext);
334
+ private getYShift;
335
+ add(element: WrappedEl): void;
336
+ clear(): void;
337
+ exportToSvg(): void;
338
+ resetViewBox(): void;
339
+ updateViewBox(x: number, y: number, width: number, height: number): void;
340
+ get height(): number;
341
+ get spacing(): number;
342
+ get width(): number;
343
+ }
344
+
345
+ declare class SankeyGraph extends Paper {
346
+ graph: SankeyGraph_2;
347
+ maxRank: number;
348
+ /** Options resolved with CSS custom property overrides for the current render pass. */
349
+ private renderOptions;
350
+ /** Accessibility helper — re-created on each render pass. */
351
+ private a11yHelper;
352
+ /** Path highlighter — re-created on each render pass when feature is enabled. */
353
+ private pathHighlighter;
354
+ /** Guard: entrance animation plays only on the first render. */
355
+ private _hasAnimated;
356
+ constructor(element: HTMLElement, options: SankeyOptions, chartContext: ChartContext);
357
+ construct(data: GraphData): void;
358
+ render({ keepOldPosition }?: {
359
+ keepOldPosition?: boolean | undefined;
360
+ }): void;
361
+ renderEdge(edgeObj: GraphEdge, group: G): void;
362
+ }
363
+
364
+ /** Generic graph interface for layout algorithms that only need basic traversal. */
365
+ declare interface SankeyGraph_2 {
366
+ nodes(): string[];
367
+ node(id: string): NodeLabel;
368
+ setNode(id: string, label: NodeLabel): void;
369
+ edges(): GraphEdge[];
370
+ edge(e: GraphEdge | string): EdgeLabel;
371
+ edge(v: string, w: string, name?: string): EdgeLabel;
372
+ setEdge(v: string, w: string, label: EdgeLabel, name?: string): void;
373
+ setEdge(e: GraphEdge, label: EdgeLabel): void;
374
+ removeEdge(e: GraphEdge): void;
375
+ removeNode(id: string): void;
376
+ hasEdge(v: string, w: string): boolean;
377
+ hasNode(id: string): boolean;
378
+ inEdges(id: string): GraphEdge[];
379
+ outEdges(id: string): GraphEdge[];
380
+ nodeEdges(u: string, v: string): GraphEdge[];
381
+ sources(): string[];
382
+ successors(id: string): string[];
383
+ setGraph(label: unknown): void;
384
+ }
385
+
386
+ /**
387
+ * A single edge (flow) between two nodes in the Sankey diagram.
388
+ *
389
+ * Edges are rendered as curved bands whose width is proportional to `value`.
390
+ */
391
+ export declare interface SankeyGraphEdge {
392
+ /** `id` of the source (upstream) node. */
393
+ readonly source: string;
394
+ /** `id` of the target (downstream) node. */
395
+ readonly target: string;
396
+ /** Category label for this edge. Used for grouping and tooltip display. */
397
+ readonly type: string;
398
+ /** Numeric flow value. Determines the visual width of the edge band. */
399
+ readonly value: number;
400
+ }
401
+
402
+ /**
403
+ * A single node (entity) in the Sankey diagram.
404
+ *
405
+ * Nodes are rendered as vertical rectangles. Use `color` to override
406
+ * the auto-assigned palette color for this node.
407
+ */
408
+ export declare interface SankeyGraphNode {
409
+ /** Override the auto-assigned fill color for this node rectangle. */
410
+ readonly color?: string;
411
+ /** Unique identifier for this node. Referenced by `Edge.source` and `Edge.target`. */
412
+ readonly id: string;
413
+ /** Display label rendered beside or inside the node. */
414
+ readonly title: string;
415
+ }
416
+
417
+ /** Data passed to the onNodeClick callback */
418
+ export declare interface SankeyNode {
419
+ value?: number;
420
+ dy?: number;
421
+ y?: number;
422
+ x?: number;
423
+ rank?: number;
424
+ spaceAbove?: number;
425
+ spaceBelow?: number;
426
+ direction?: string;
427
+ data?: NodeData | null;
428
+ }
429
+
430
+ /**
431
+ * Full configuration type for `ApexSankey`. An intersection of all sub-option
432
+ * interfaces: `CommonOptions & EdgeOptions & FontOptions & InteractionOptions &
433
+ * AnimationOptions & LayoutOptions & NodeOptions & TooltipOptions & A11yOptions`.
434
+ *
435
+ * Pass a `Partial<SankeyOptions>` to the constructor — all fields have defaults.
436
+ */
437
+ export declare type SankeyOptions = CommonOptions & EdgeOptions & FontOptions & InteractionOptions & AnimationOptions & LayoutOptions & NodeOptions & TooltipOptions & A11yOptions;
438
+
439
+ /** Data passed to the tooltipTemplate callback */
440
+ export declare interface TooltipContent {
441
+ source?: NodeData | null;
442
+ target?: NodeData | null;
443
+ value?: number;
444
+ }
445
+
446
+ /**
447
+ * Options for the hover tooltip shown over edges and nodes.
448
+ *
449
+ * Show/hide independently for edges (`enableTooltip`) and supply custom
450
+ * `tooltipTemplate` / `nodeTooltipTemplate` functions to render arbitrary HTML.
451
+ * Use `tooltipTheme` as a shortcut for dark/light color presets.
452
+ */
453
+ export declare interface TooltipOptions {
454
+ /** Show edge tooltips on hover. @default true */
455
+ readonly enableTooltip: boolean;
456
+ /** Background color of the tooltip. @default '#FFFFFF' */
457
+ readonly tooltipBGColor: string;
458
+ /** Border color of the tooltip. @default '#E2E8F0' */
459
+ readonly tooltipBorderColor: string;
460
+ /** Font color inside the tooltip. @default '#1a1a1a' */
461
+ readonly tooltipFontColor: string;
462
+ /** HTML `id` for the tooltip container element. @default 'apexsankey-tooltip-container' */
463
+ readonly tooltipId: string;
464
+ /** `'light'` | `'dark'` — overrides `tooltipBGColor`/`tooltipBorderColor`/`tooltipFontColor` with built-in presets. */
465
+ readonly tooltipTheme?: 'dark' | 'light';
466
+ /** Custom function returning an HTML string for the edge (source→target) tooltip. */
467
+ readonly tooltipTemplate?: (content: TooltipContent) => string;
468
+ /** Custom function returning an HTML string for the per-node tooltip. */
469
+ readonly nodeTooltipTemplate?: (content: NodeTooltipContent) => string;
470
+ }
471
+
472
+ export { }