apexsankey 1.12.4 → 1.14.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.
- package/LICENSE.md +2 -1
- package/README.md +49 -7
- package/apexsankey.d.ts +75 -3
- package/apexsankey.es.min.js +1 -1
- package/apexsankey.ignite-ui.es.min.js +1 -0
- package/apexsankey.ignite-ui.min.js +1 -0
- package/apexsankey.min.js +1 -1
- package/ignite-ui.d.ts +1 -0
- package/package.json +11 -2
package/LICENSE.md
CHANGED
|
@@ -46,10 +46,11 @@ Required if you are **embedding ApexSankey into a product or platform used by ot
|
|
|
46
46
|
✅ What's included:
|
|
47
47
|
|
|
48
48
|
- Redistribution rights for **one application or product**
|
|
49
|
-
- **Unlimited developer seats** on that application, with no separate per-developer license to buy
|
|
50
49
|
- **Every licensed feature**, at the highest tier
|
|
51
50
|
- 12-month subscription with updates & support
|
|
52
51
|
|
|
52
|
+
⚠️ **Developer licenses are purchased separately.** The OEM License grants redistribution rights and carries no developer seats. Each developer who works with ApexSankey in that application also needs a **Community + Commercial** license of their own. That is the tier whatever features your product uses, because the license key comes from the OEM License and already renders every licensed feature.
|
|
53
|
+
|
|
53
54
|
Your end users need no license of their own. A second application needs a second OEM license. White-label, resale, and affiliate arrangements are quoted separately.
|
|
54
55
|
|
|
55
56
|
✅ OEM **not required** if your app simply renders static diagrams and users **cannot** configure or interact with them.
|
package/README.md
CHANGED
|
@@ -69,6 +69,7 @@ Methods available on an `ApexSankey` instance:
|
|
|
69
69
|
| --- | --- |
|
|
70
70
|
| `render(data)` | Build the diagram from `data` (`{ nodes, edges }`) and write the SVG into the container. Returns the internal graph renderer, which exposes `exportToSvg()`. |
|
|
71
71
|
| `update(data)` | Transition an already-rendered instance to new `data`. When the new layout shares the current topology (same nodes and flows, only different values or positions), the nodes and ribbons spring smoothly to their new places. When the topology differs, it morphs through the change: entering flows grow out of their source node, survivors slide to their new places, and removed flows retract and dissolve. When animation is disabled or the user prefers reduced motion, it redraws instantly. |
|
|
72
|
+
| `refreshTokens()` | Re-read the theme (the `--apex-sankey-*` variables, the `--apx-*` tokens, the named or registered theme and the page's design system) and repaint the diagram: node colours follow the palette as it resolves now (a node's own `color` stays), and so do the labels, the tooltip, the focus ring and the particles. The diagram reads its theme on every render and `update()` takes only data, so call this after a stylesheet swap (an Ignite UI light/dark switch, say), a class that sets the variables, or the `apexsankey/ignite-ui` add-on loaded after the first render. Nodes stay where they are, dragged ones included, and the view does not move. A no-op before `render()`. |
|
|
72
73
|
| `ApexSankey.setLicense(key)` | Static. Set the commercial license key before creating any chart instances. |
|
|
73
74
|
| `ApexSankey.registerTheme(name, theme)` | Static. Register (or override) a named theme (a `SankeyTheme`), then reference it by name via the `theme` option. Use for brand presets. |
|
|
74
75
|
| `ApexSankey.collapseGroups(data, groups, collapsed)` | Static. Project a detailed `{ nodes, edges }` to an aggregated one by collapsing the listed groups into super-nodes (re-routing and merging their flows). The pure transform behind the `drillDown` plugin; use it to seed the initial collapsed render. |
|
|
@@ -90,6 +91,8 @@ The layout can be configured by passing a second argument to `ApexSankey` with t
|
|
|
90
91
|
| `type` | `'sankey' \| 'chord'` | `'sankey'` | Which projection of the flow model to draw. `'chord'` renders a radial diagram (nodes as arcs on a ring, flows as ribbons across the interior) for dense many-to-many relationships. See [Chord](#chord). |
|
|
91
92
|
| `arcCornerRadius` | `number` | `6` | Chord only. Corner radius (px) for the rounded outer corners of each node arc (the inner edge, where ribbons meet, stays flush). `0` gives sharp corners; clamped to the ring band width. |
|
|
92
93
|
| `theme` | `string \| SankeyTheme` | `undefined` | A named built-in theme (`'light'`, `'dark'`, `'midnight'`, `'mint'`, `'sunset'`), a name registered via `ApexSankey.registerTheme`, or an inline `SankeyTheme`. Seeds coordinated visual defaults (palette, colors, background); options you set explicitly still win. See [Themes](#themes). |
|
|
94
|
+
| `tokens` | `boolean` | `true` | `false` stops the diagram reading the `--apx-*` family tokens and the page's design system (including its variant). |
|
|
95
|
+
| `designSystem` | `boolean` | `true` | `false` stops the diagram reading the page's design system (Ignite UI's `--ig-*` tokens, including its variant). The `--apx-*` tokens still apply. Has an effect only while the `apexsankey/ignite-ui` add-on is loaded; see [Design systems](#design-systems-ignite-ui). |
|
|
93
96
|
| `spacing` | `number` | `20` | Horizontal spacing between node columns in pixels. |
|
|
94
97
|
| `nodeWidth` | `number` | `20` | Width of each node rectangle in pixels. |
|
|
95
98
|
| `nodeBorderWidth` | `number` | `1` | Border width of each node in pixels. |
|
|
@@ -114,7 +117,7 @@ The layout can be configured by passing a second argument to `ApexSankey` with t
|
|
|
114
117
|
| `tooltipId` | `string` | `'apexsankey-tooltip-container'` | HTML `id` for the tooltip container element. |
|
|
115
118
|
| `tooltipTemplate` | `(content: TooltipContent) => string` | built-in | Custom function returning an HTML string for the edge (source→target) tooltip. |
|
|
116
119
|
| `nodeTooltipTemplate` | `(content: NodeTooltipContent) => string` | built-in | Custom function returning an HTML string for the per-node tooltip. |
|
|
117
|
-
| `tooltipTheme` | `'light' \| 'dark'` | `undefined` |
|
|
120
|
+
| `tooltipTheme` | `'light' \| 'dark'` | `undefined` | `'dark'` replaces the default `tooltipBGColor`/`tooltipBorderColor`/`tooltipFontColor` with a dark preset, which ranks as a named theme: colours you pass yourself still win, and so do the `--apex-sankey-tooltip-*` variables and the `--apx-*` tokens for any colour you did not pass. Left unset, it follows a design system that declares a dark variant. |
|
|
118
121
|
| `tooltipBorderColor` | `string` | `'#E2E8F0'` | Border color of the tooltip. |
|
|
119
122
|
| `tooltipBGColor` | `string` | `'#FFFFFF'` | Background color of the tooltip. |
|
|
120
123
|
| `tooltipFontColor` | `string` | `'#1a1a1a'` | Font color inside the tooltip. |
|
|
@@ -281,7 +284,7 @@ const cmp = ApexSankey.compare(el, {
|
|
|
281
284
|
|
|
282
285
|
### Themes
|
|
283
286
|
|
|
284
|
-
Pass `theme` to seed a coordinated set of visual defaults in one shot. Built-in themes: `'light'` (the default look), `'dark'`, `'midnight'`, `'mint'`, and `'sunset'`. A theme
|
|
287
|
+
Pass `theme` to seed a coordinated set of visual defaults in one shot. Built-in themes: `'light'` (the default look), `'dark'`, `'midnight'`, `'mint'`, and `'sunset'`. A theme ranks as a named theme: anything you set yourself still wins, and so do the `--apex-sankey-*` variables and the `--apx-*` family tokens (see [Family theme tokens](#family-theme-tokens---apx-)).
|
|
285
288
|
|
|
286
289
|
```js
|
|
287
290
|
const sankey = new ApexSankey(el, {theme: 'dark'});
|
|
@@ -426,6 +429,29 @@ const data = {
|
|
|
426
429
|
};
|
|
427
430
|
```
|
|
428
431
|
|
|
432
|
+
### CSS variables
|
|
433
|
+
|
|
434
|
+
Set these on the container or any ancestor. Each ranks below an option you pass and above the `--apx-*` tokens, a named theme and the defaults.
|
|
435
|
+
|
|
436
|
+
| Variable | Sets |
|
|
437
|
+
| --- | --- |
|
|
438
|
+
| `--apex-sankey-label-color` | `fontColor` |
|
|
439
|
+
| `--apex-sankey-label-font-size` | `fontSize` |
|
|
440
|
+
| `--apex-sankey-font-family` | `fontFamily` |
|
|
441
|
+
| `--apex-sankey-node-width` | `nodeWidth` |
|
|
442
|
+
| `--apex-sankey-node-border-color` | `nodeBorderColor` |
|
|
443
|
+
| `--apex-sankey-node-border-width` | `nodeBorderWidth` |
|
|
444
|
+
| `--apex-sankey-edge-opacity` | `edgeOpacity` |
|
|
445
|
+
| `--apex-sankey-edge-gradient` | `edgeGradientFill` (`true` or `false`) |
|
|
446
|
+
| `--apex-sankey-tooltip-bg` | `tooltipBGColor` |
|
|
447
|
+
| `--apex-sankey-tooltip-border-color` | `tooltipBorderColor` |
|
|
448
|
+
| `--apex-sankey-tooltip-font-color` | `tooltipFontColor` |
|
|
449
|
+
| `--apex-sankey-tooltip-theme` | `tooltipTheme` (`light` or `dark`) |
|
|
450
|
+
| `--apex-sankey-focus-color` | The keyboard focus ring (default `#005FCC`; with the [Ignite UI add-on](#design-systems-ignite-ui) loaded, `--apx-accent` or the design system's primary below it) |
|
|
451
|
+
| `--apex-sankey-particle-color` | The `particleFlow` particles (default `rgba(255,255,255,0.9)`) |
|
|
452
|
+
|
|
453
|
+
After changing them without a render, call `refreshTokens()`.
|
|
454
|
+
|
|
429
455
|
## Family theme tokens (`--apx-*`)
|
|
430
456
|
|
|
431
457
|
Every chart in the ApexCharts family reads the same five root tokens, so a page can state its brand once and have trees, flow diagrams, Gantt charts and plots all follow:
|
|
@@ -455,20 +481,20 @@ Every chart in the ApexCharts family reads the same five root tokens, so a page
|
|
|
455
481
|
}
|
|
456
482
|
```
|
|
457
483
|
|
|
458
|
-
Custom properties inherit, so declaring them on `:root` reaches every chart on the page.
|
|
484
|
+
Custom properties inherit, so declaring them on `:root` reaches every chart on the page. Every styling option resolves through the same order as the rest of the family, higher wins:
|
|
459
485
|
|
|
460
486
|
```
|
|
461
|
-
|
|
487
|
+
option you passed > --apex-sankey-* variable > --apx-* token > named theme > design system > built-in default
|
|
462
488
|
```
|
|
463
489
|
|
|
464
|
-
An option
|
|
490
|
+
An option counts as passed when it is in the options you gave the constructor, even at its default value. Options you did not pass rank last, so a variable or a token themes them. "Named theme" covers a Sankey theme (`theme: 'dark'`), the dark tooltip preset (`tooltipTheme: 'dark'`, which the `dark` and `midnight` themes set) and a family theme registered under the same name. `--apx-font-family` sets `fontFamily` the same way.
|
|
465
491
|
|
|
466
492
|
### Named themes
|
|
467
493
|
|
|
468
|
-
`registerTheme` from
|
|
494
|
+
`registerTheme` from `apex-commons` records a named set of tokens on a registry shared by the whole family, so a brand theme registered once from any product is resolvable by name from all of them:
|
|
469
495
|
|
|
470
496
|
```js
|
|
471
|
-
import {registerTheme} from '
|
|
497
|
+
import {registerTheme} from 'apex-commons';
|
|
472
498
|
|
|
473
499
|
registerTheme('acme', {
|
|
474
500
|
tokens: {accent: '#5b21b6', fore: '#101828', grid: '#e4e7ec', surface: '#ffffff'},
|
|
@@ -478,3 +504,19 @@ registerTheme('acme', {
|
|
|
478
504
|
A named theme's tokens sit one layer below the CSS `--apx-*` tokens, so the cascade still wins over the registry.
|
|
479
505
|
|
|
480
506
|
Reference it through the `theme` option, alongside the Sankey-specific named themes described in [Themes](#themes). The two registries are complementary: a Sankey theme carries diagram-specific defaults (palette, edge opacity, canvas style), while a family theme carries the cross-product token roles.
|
|
507
|
+
|
|
508
|
+
### Design systems (Ignite UI)
|
|
509
|
+
|
|
510
|
+
Ignite UI theming is an add-on. Load it once and diagrams follow the Ignite UI theme on the page: the node palette, label text, the focus ring, the font, the tooltip, light or dark.
|
|
511
|
+
|
|
512
|
+
```js
|
|
513
|
+
import 'apexsankey/ignite-ui';
|
|
514
|
+
```
|
|
515
|
+
|
|
516
|
+
Without a bundler, load `apexsankey.ignite-ui.min.js` with a script tag, before or after `apexsankey.min.js`. Load it before the first render: a diagram rendered earlier picks it up on its next `render()` or `refreshTokens()`. `designSystem: false` turns it off for one diagram. Without the add-on the `--ig-*` tokens are ignored, with no error; the `--apx-*` tokens work either way.
|
|
517
|
+
|
|
518
|
+
The add-on also themes ApexTree and ApexGantt on the same page; with several of them, load it from the newest package. ApexCharts charts take their own add-on, `apexcharts/features/ignite-ui`. That one themes diagrams as well, but from a script tag only once `apexcharts.js` has loaded, so on a script-tag page load `apexsankey.ignite-ui.min.js` (or `apex-commons.ignite-ui.min.js`) for the diagrams.
|
|
519
|
+
|
|
520
|
+
With the add-on loaded, on a page that loads an Ignite UI theme, the diagram reads its tokens as the lowest-ranked layer above the built-in defaults: the node palette from the theme's colour families (`--ig-primary-seed`, `--ig-secondary-seed`, and so on, with the built-in palette filling any row the theme does not declare), label text from `--ig-gray-800`, `fontFamily` from `--ig-font-family`, the keyboard focus ring from `--ig-primary-seed`, the tooltip border from `--ig-gray-300`, and (from Ignite UI 7.5.0) the tooltip surface and text from `--ig-surface-overlay` and its contrast colour. Anything above it (an option you passed, an `--apex-sankey-*` variable, an `--apx-*` token, a named theme) still wins.
|
|
521
|
+
|
|
522
|
+
When the sheet declares a dark variant and nothing set `tooltipTheme`, the tooltip renders dark. Tooltip colours from the design system apply only while the tooltip theme matches the sheet's variant. Turn the layer off with `designSystem: false`, or every token read with `tokens: false`.
|
package/apexsankey.d.ts
CHANGED
|
@@ -251,6 +251,26 @@ declare class ApexSankey extends BaseChart {
|
|
|
251
251
|
* ```
|
|
252
252
|
*/
|
|
253
253
|
update(data: GraphData, transition?: SankeyTransition): SankeyGraphRenderer;
|
|
254
|
+
/**
|
|
255
|
+
* Re-read the theme and repaint the diagram with it.
|
|
256
|
+
*
|
|
257
|
+
* The diagram reads its `--apex-sankey-*` variables, the `--apx-*` tokens,
|
|
258
|
+
* the named or registered theme and the page's design system on every
|
|
259
|
+
* render; `update()` takes only data. Call this when the theme changes
|
|
260
|
+
* without a render: the page swapped a stylesheet (an Ignite UI light/dark
|
|
261
|
+
* switch, say), toggled a class that sets the variables, or loaded the
|
|
262
|
+
* `apexsankey/ignite-ui` add-on after the first render. Node colours follow
|
|
263
|
+
* the palette as it resolves now (a node's own `color` stays), and labels,
|
|
264
|
+
* the tooltip, the focus ring and the particles follow too. Nodes stay
|
|
265
|
+
* where they are and the view does not move. A no-op before `render()`.
|
|
266
|
+
*
|
|
267
|
+
* @example
|
|
268
|
+
* ```ts
|
|
269
|
+
* themeLink.href = 'themes/dark/material.css';
|
|
270
|
+
* themeLink.onload = () => sankey.refreshTokens();
|
|
271
|
+
* ```
|
|
272
|
+
*/
|
|
273
|
+
refreshTokens(): void;
|
|
254
274
|
/**
|
|
255
275
|
* Subscribe to an instance event. Returns an unsubscribe function.
|
|
256
276
|
*
|
|
@@ -358,9 +378,26 @@ export declare interface CommonOptions {
|
|
|
358
378
|
* A named built-in theme (`'light'`, `'dark'`, `'midnight'`, `'mint'`,
|
|
359
379
|
* `'sunset'`), a name registered via `ApexSankey.registerTheme`, or an inline
|
|
360
380
|
* {@link SankeyTheme}. Seeds coordinated visual defaults (palette, colors,
|
|
361
|
-
* background); options you set explicitly still win
|
|
381
|
+
* background); options you set explicitly still win, and so do the
|
|
382
|
+
* `--apex-sankey-*` variables and the `--apx-*` family tokens.
|
|
383
|
+
* @default undefined (light)
|
|
362
384
|
*/
|
|
363
385
|
readonly theme?: string | SankeyTheme;
|
|
386
|
+
/**
|
|
387
|
+
* `false` stops the diagram reading the shared `--apx-*` family tokens and
|
|
388
|
+
* the page's design system (including its light or dark variant). Options,
|
|
389
|
+
* `--apex-sankey-*` variables and named themes still apply.
|
|
390
|
+
* @default true
|
|
391
|
+
*/
|
|
392
|
+
readonly tokens?: boolean;
|
|
393
|
+
/**
|
|
394
|
+
* `false` stops the diagram reading the page's design system (Ignite UI's
|
|
395
|
+
* `--ig-*` tokens, including its variant). The `--apx-*` family tokens still
|
|
396
|
+
* apply. Has an effect only while the `apexsankey/ignite-ui` add-on is
|
|
397
|
+
* loaded: without it the diagram reads no design system.
|
|
398
|
+
* @default true
|
|
399
|
+
*/
|
|
400
|
+
readonly designSystem?: boolean;
|
|
364
401
|
/** Height of the canvas. Use `'auto'` to derive height from width at a 1.6:1 ratio. @default 'auto' */
|
|
365
402
|
readonly height: number | string;
|
|
366
403
|
/** Localization and text-direction (RTL) options. See {@link LocaleOptions}. @default { direction: 'ltr' } */
|
|
@@ -968,10 +1005,18 @@ export declare interface SankeyGraphNode {
|
|
|
968
1005
|
|
|
969
1006
|
declare class SankeyGraphRenderer extends Paper {
|
|
970
1007
|
private readonly events?;
|
|
1008
|
+
/** The option keys the page passed, so a theme-seeded preset never overrides one. */
|
|
1009
|
+
private readonly explicitOptions?;
|
|
971
1010
|
graph: SankeyGraph;
|
|
972
1011
|
maxRank: number;
|
|
973
1012
|
/** Options resolved with CSS custom property overrides for the current render pass. */
|
|
974
1013
|
private renderOptions;
|
|
1014
|
+
/** Keyboard focus ring colour resolved for the current render; `''` keeps the built-in one. */
|
|
1015
|
+
private focusColor;
|
|
1016
|
+
/** Particle colour resolved for the current render; `''` keeps the built-in one. */
|
|
1017
|
+
private particleColor;
|
|
1018
|
+
/** The data the current graph was built from, so `refreshTokens()` can repaint its palette. */
|
|
1019
|
+
private lastData;
|
|
975
1020
|
/** Accessibility helper — re-created on each render pass. */
|
|
976
1021
|
private a11yHelper;
|
|
977
1022
|
/** Path highlighter — re-created on each render pass when feature is enabled. */
|
|
@@ -999,12 +1044,20 @@ declare class SankeyGraphRenderer extends Paper {
|
|
|
999
1044
|
private readonly chordRenderer;
|
|
1000
1045
|
/** Resolved chord input (palette applied), set by `construct` in chord mode. */
|
|
1001
1046
|
private chordData;
|
|
1002
|
-
constructor(element: HTMLElement, options: SankeyOptions, chartContext: ChartContext, events?: EventBus | undefined
|
|
1047
|
+
constructor(element: HTMLElement, options: SankeyOptions, chartContext: ChartContext, events?: EventBus | undefined,
|
|
1048
|
+
/** The option keys the page passed, so a theme-seeded preset never overrides one. */
|
|
1049
|
+
explicitOptions?: ReadonlySet<"animation" | "a11y" | keyof CommonOptions | keyof EdgeOptions | keyof FontOptions | keyof InteractionOptions | keyof LayoutOptions | keyof NodeOptions | keyof TooltipOptions> | undefined);
|
|
1003
1050
|
/** Resolved, localized screen-reader strings (English defaults + `locale.messages`). */
|
|
1004
1051
|
getMessages(): SankeyMessages;
|
|
1005
1052
|
/** Whether the current `locale.direction` resolves to right-to-left. */
|
|
1006
1053
|
private get isRtl();
|
|
1007
1054
|
construct(data: GraphData): void;
|
|
1055
|
+
/**
|
|
1056
|
+
* The nodes with their palette colours: a node's own `color`, else the
|
|
1057
|
+
* palette the family chain resolves now (see `resolveNodePalette`), by
|
|
1058
|
+
* position.
|
|
1059
|
+
*/
|
|
1060
|
+
private paintNodes;
|
|
1008
1061
|
/** Resolve palette colors onto the raw nodes and stash the chord input for `renderChord`. */
|
|
1009
1062
|
private constructChord;
|
|
1010
1063
|
/**
|
|
@@ -1015,6 +1068,19 @@ declare class SankeyGraphRenderer extends Paper {
|
|
|
1015
1068
|
* already-mirrored positions without compounding.
|
|
1016
1069
|
*/
|
|
1017
1070
|
private mirrorLayoutForRtl;
|
|
1071
|
+
/** Resolve this render's styling options, focus ring and particle colours (see `resolveSankeyStyle`). */
|
|
1072
|
+
private resolveStyle;
|
|
1073
|
+
/**
|
|
1074
|
+
* Re-read the theme (the `--apex-sankey-*` variables, the `--apx-*` tokens,
|
|
1075
|
+
* the named or registered theme, the page's design system) and repaint the
|
|
1076
|
+
* diagram with it: node colours from the palette as it resolves now, labels,
|
|
1077
|
+
* tooltip, focus ring and particles. Nodes stay where they are, dragged ones
|
|
1078
|
+
* included, and the view does not move. A no-op before the first render.
|
|
1079
|
+
*
|
|
1080
|
+
* A running `update()` animation is not interrupted: its frames and the
|
|
1081
|
+
* render that commits it take the new theme.
|
|
1082
|
+
*/
|
|
1083
|
+
refreshTokens(): void;
|
|
1018
1084
|
render({ keepOldPosition }?: {
|
|
1019
1085
|
keepOldPosition?: boolean | undefined;
|
|
1020
1086
|
}): void;
|
|
@@ -1302,7 +1368,13 @@ export declare interface TooltipOptions {
|
|
|
1302
1368
|
readonly tooltipFontColor: string;
|
|
1303
1369
|
/** HTML `id` for the tooltip container element. @default 'apexsankey-tooltip-container' */
|
|
1304
1370
|
readonly tooltipId: string;
|
|
1305
|
-
/**
|
|
1371
|
+
/**
|
|
1372
|
+
* `'light'` | `'dark'`. `'dark'` replaces the default `tooltipBGColor`/`tooltipBorderColor`/`tooltipFontColor`
|
|
1373
|
+
* with a dark preset, which ranks as a named theme: colours passed to the constructor still win, and so do the
|
|
1374
|
+
* `--apex-sankey-tooltip-*` variables and the `--apx-*` family tokens for any colour not passed. Left unset, it
|
|
1375
|
+
* follows a page design system that declares a dark variant (Ignite UI's `--ig-theme-variant: dark`, with the
|
|
1376
|
+
* `apexsankey/ignite-ui` add-on loaded).
|
|
1377
|
+
*/
|
|
1306
1378
|
readonly tooltipTheme?: 'dark' | 'light';
|
|
1307
1379
|
/** Custom function returning an HTML string for the edge (source→target) tooltip. */
|
|
1308
1380
|
readonly tooltipTemplate?: (content: TooltipContent) => string;
|