apexsankey 1.13.0 → 1.15.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 +15 -10
- package/README.md +153 -16
- package/apexsankey.d.ts +383 -22
- 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 -1
package/LICENSE.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
ApexSankey is a commercial product, included in the **Pro** plan and above.
|
|
4
4
|
|
|
5
|
-
**There is no free tier for ApexSankey.** The $2M threshold that makes some Apex products free does not apply to this one: a Pro license is required whatever your financial resources, by companies, individuals, non-profits and educators alike. Without a valid license key ApexSankey renders with a trial watermark
|
|
5
|
+
**There is no free tier for ApexSankey.** The $2M threshold that makes some Apex products free does not apply to this one: a Pro license is required whatever your financial resources, by companies, individuals, non-profits and educators alike. Without a valid license key ApexSankey renders with a trial watermark. Using it that way without ever having bought a license is for evaluation only.
|
|
6
6
|
|
|
7
|
-
One license key
|
|
7
|
+
One license key covers every Apex product your plan includes, so you do not buy a separate key for each product.
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
@@ -16,13 +16,15 @@ Pro and Premium are priced per developer, and priced on the features you use rat
|
|
|
16
16
|
|
|
17
17
|
✅ What's included:
|
|
18
18
|
|
|
19
|
-
- Use in internal tools and commercial applications
|
|
20
|
-
-
|
|
21
|
-
-
|
|
19
|
+
- Use in internal tools, client work, and commercial applications
|
|
20
|
+
- Client work includes a system you build for a single client and hand over to run on the client's own servers
|
|
21
|
+
- Modifications, and deploying your application to its users
|
|
22
|
+
- 12-month subscription with updates, and technical support on Pro and above
|
|
22
23
|
|
|
23
24
|
🚫 Not allowed:
|
|
24
25
|
|
|
25
26
|
- Redistribution in toolkits, SDKs, or platforms
|
|
27
|
+
- Selling or licensing the same product to multiple customers, which is redistribution and needs the OEM License below
|
|
26
28
|
- Use by unlicensed developers
|
|
27
29
|
- Competing charting or diagramming products
|
|
28
30
|
|
|
@@ -36,7 +38,7 @@ Non-Profits are treated like commercial entities and need a **Pro** license or h
|
|
|
36
38
|
|
|
37
39
|
### 🔄 OEM / Redistribution License (Paid)
|
|
38
40
|
|
|
39
|
-
Required if you
|
|
41
|
+
Required if you ship ApexSankey inside a **product you distribute** to customers or other developers, or inside a **hosted product where users build, customize, or configure diagrams**, such as:
|
|
40
42
|
|
|
41
43
|
- No-code dashboards
|
|
42
44
|
- Developer platforms
|
|
@@ -46,13 +48,16 @@ Required if you are **embedding ApexSankey into a product or platform used by ot
|
|
|
46
48
|
✅ What's included:
|
|
47
49
|
|
|
48
50
|
- Redistribution rights for **one application or product**
|
|
49
|
-
- **Unlimited developer seats** on that application, with no separate per-developer license to buy
|
|
50
51
|
- **Every licensed feature**, at the highest tier
|
|
51
52
|
- 12-month subscription with updates & support
|
|
52
53
|
|
|
54
|
+
⚠️ **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, which is free for organizations under $2M in annual revenue, budget or funding. That is the tier whatever features your product uses, because the license key comes from the OEM License and already renders every licensed feature.
|
|
55
|
+
|
|
56
|
+
This holds for ApexSankey too, even though the Community plan does not include it on its own: the OEM license key is what covers ApexSankey in that application.
|
|
57
|
+
|
|
53
58
|
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
59
|
|
|
55
|
-
✅ OEM **not required**
|
|
60
|
+
✅ OEM **not required** for a hosted app that only shows predefined diagrams, which users **cannot** build, customize, or configure. Using features your developers enabled, including Premium features, does not by itself require an OEM license. OEM is for products whose purpose is letting users build charts or dashboards: dashboard and report builders, embedded BI, no-code tools, SDKs.
|
|
56
61
|
|
|
57
62
|
---
|
|
58
63
|
|
|
@@ -60,7 +65,7 @@ Your end users need no license of their own. A second application needs a second
|
|
|
60
65
|
|
|
61
66
|
Your license key expires and **ApexSankey renders with a trial watermark**, because the whole product is licensed rather than a set of features inside a free one. You no longer receive updates, new features, or technical support. Your existing deployment keeps running.
|
|
62
67
|
|
|
63
|
-
For OEM licenses,
|
|
68
|
+
For OEM licenses, redistribution must stop until the license is reinstated. Cancelling or not renewing a subscription is not termination of the [Terms of Use](https://apexcharts.com/legal/terms/).
|
|
64
69
|
|
|
65
70
|
---
|
|
66
71
|
|
|
@@ -69,7 +74,7 @@ For OEM licenses, continued redistribution requires an active subscription.
|
|
|
69
74
|
By installing ApexSankey (e.g., via `npm install apexsankey`), you are agreeing to the applicable license based on your usage:
|
|
70
75
|
|
|
71
76
|
- Commercial License (Pro or higher, whatever your financial resources)
|
|
72
|
-
- OEM License (if
|
|
77
|
+
- OEM License (if you distribute a product containing it, or host one where users build diagrams)
|
|
73
78
|
|
|
74
79
|
---
|
|
75
80
|
|
package/README.md
CHANGED
|
@@ -67,8 +67,11 @@ Methods available on an `ApexSankey` instance:
|
|
|
67
67
|
|
|
68
68
|
| Method | Description |
|
|
69
69
|
| --- | --- |
|
|
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()
|
|
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()` and `getResolvedOptions()` (the styling options this render resolved from the options, the variables, the tokens and the theme, for page code that matches its own DOM to the diagram). |
|
|
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()`. |
|
|
73
|
+
| `pauseParticles()` | Stop the `particleFlow` particles where they are. They stay paused through `update()` and `refreshTokens()`, still riding along with their ribbons as an update moves them, until `resumeParticles()`. Called before the particles exist, it takes effect when they appear. |
|
|
74
|
+
| `resumeParticles()` | Set paused particles moving again from where they are. |
|
|
72
75
|
| `ApexSankey.setLicense(key)` | Static. Set the commercial license key before creating any chart instances. |
|
|
73
76
|
| `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
77
|
| `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 +93,8 @@ The layout can be configured by passing a second argument to `ApexSankey` with t
|
|
|
90
93
|
| `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
94
|
| `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
95
|
| `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). |
|
|
96
|
+
| `tokens` | `boolean` | `true` | `false` stops the diagram reading the `--apx-*` family tokens and the page's design system (including its variant). |
|
|
97
|
+
| `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
98
|
| `spacing` | `number` | `20` | Horizontal spacing between node columns in pixels. |
|
|
94
99
|
| `nodeWidth` | `number` | `20` | Width of each node rectangle in pixels. |
|
|
95
100
|
| `nodeBorderWidth` | `number` | `1` | Border width of each node in pixels. |
|
|
@@ -99,11 +104,13 @@ The layout can be configured by passing a second argument to `ApexSankey` with t
|
|
|
99
104
|
| `onNodeClick` | `(node: SankeyNode) => void` | `undefined` | Callback fired when the user clicks a node. |
|
|
100
105
|
| `edgeOpacity` | `number` | `0.4` | Opacity of edges (0–1). |
|
|
101
106
|
| `edgeGradientFill` | `boolean` | `true` | Fill edges with a gradient between source and target node colors. |
|
|
102
|
-
| `particleFlow` | `boolean` | `false` | Animate particles drifting along each flow ribbon
|
|
107
|
+
| `particleFlow` | `boolean \| ParticleFlowOptions` | `false` | Animate particles drifting along each flow ribbon. Purely decorative; skipped under `prefers-reduced-motion`. The particles keep moving through `update()`, each holding its place along its ribbon. `true` uses the built-in density (one particle per 9 px of thickness, 1 to 16 per flow); an object turns them on with its rules: `unitsPerParticle` (one particle per that many units of value, rounded, no per-flow limit, so counts compare across flows and updates) and `minValue` (a flow below it carries none). Counts are worked out when an update starts. At most 600 particles are drawn: with `unitsPerParticle`, a frame that needs more scales every count down by one factor (a flow that had a particle keeps one), warns once in the console with a setting that fits, and keeps that factor for the later frames. Chord diagrams draw no particles. |
|
|
103
108
|
| `edgeGap` | `number` | `0` | Gap in pixels between adjacent edges at node connection points. |
|
|
104
109
|
| `whitespace` | `number` | `0.18` | Fraction of vertical space used as margins between nodes (0–1). Lower = taller nodes. |
|
|
105
110
|
| `orientation` | `'horizontal' \| 'vertical'` | `'horizontal'` | Flow direction. `'horizontal'` lays ranks out in columns (flows left→right); `'vertical'` lays them in rows (flows top→bottom). |
|
|
106
111
|
| `axisTitles` | `string[]` | `undefined` | Titles drawn above each column (or beside each row when vertical), one per rank — the axis/dimension labels of an alluvial diagram. Index `i` labels rank `i`. See [Alluvial](#alluvial). |
|
|
112
|
+
| `maxValue` | `number` | `undefined` | Draw every render and `update()` at one fixed scale instead of fitting each to the chart, so the same value draws the same thickness in every frame. Set it to the largest column total across all your data. A lighter column packs to the top (the left when vertical) with the gaps it has at `maxValue`, rather than spreading out, as long as it keeps the same nodes (keep a node's flows at 0 rather than leaving them out). Ignored, with a console warning, by chord diagrams and when not a positive number. See [Comparing frames](#comparing-frames-fixed-scale-and-input-order). |
|
|
113
|
+
| `nodeOrder` | `'auto' \| 'input'` | `'auto'` | Order of the nodes within each column. `'auto'` reorders them to cut crossings, so the order can change when flows appear or disappear; `'input'` keeps the order of `nodes`. See [Comparing frames](#comparing-frames-fixed-scale-and-input-order). |
|
|
107
114
|
| `viewPortWidth` | `number` | `800` | Internal SVG viewport width in pixels. |
|
|
108
115
|
| `viewPortHeight` | `number` | `500` | Internal SVG viewport height in pixels. |
|
|
109
116
|
| `highlightConnectedPath` | `boolean` | `true` | Highlight connected flows on interaction. Hovering a node or flow gives a one-hop preview; clicking a node or flow pins an isolate of its full upstream/downstream path (click again, or click another, to change/release). |
|
|
@@ -114,7 +121,7 @@ The layout can be configured by passing a second argument to `ApexSankey` with t
|
|
|
114
121
|
| `tooltipId` | `string` | `'apexsankey-tooltip-container'` | HTML `id` for the tooltip container element. |
|
|
115
122
|
| `tooltipTemplate` | `(content: TooltipContent) => string` | built-in | Custom function returning an HTML string for the edge (source→target) tooltip. |
|
|
116
123
|
| `nodeTooltipTemplate` | `(content: NodeTooltipContent) => string` | built-in | Custom function returning an HTML string for the per-node tooltip. |
|
|
117
|
-
| `tooltipTheme` | `'light' \| 'dark'` | `undefined` |
|
|
124
|
+
| `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
125
|
| `tooltipBorderColor` | `string` | `'#E2E8F0'` | Border color of the tooltip. |
|
|
119
126
|
| `tooltipBGColor` | `string` | `'#FFFFFF'` | Background color of the tooltip. |
|
|
120
127
|
| `tooltipFontColor` | `string` | `'#1a1a1a'` | Font color inside the tooltip. |
|
|
@@ -122,7 +129,8 @@ The layout can be configured by passing a second argument to `ApexSankey` with t
|
|
|
122
129
|
| `fontFamily` | `string` | `''` | CSS font-family for node labels. Falls back to the page default when empty. |
|
|
123
130
|
| `fontSize` | `string` | `'14px'` | CSS font-size for node labels. |
|
|
124
131
|
| `fontWeight` | `string` | `'400'` | CSS font-weight for node labels. |
|
|
125
|
-
| `
|
|
132
|
+
| `nodeLabel` | `{ formatter?: (content: NodeLabelContent) => string, position?: 'inside' \| 'outside' \| 'start' \| 'end', minHeight?: number }` | `undefined` | Node label text, side and visibility. Unset, a label is the node's title cut to 15 characters (18 when vertical), on the side facing the middle of the diagram, on nodes taller than `fontSize`. See [Node labels](#node-labels). |
|
|
133
|
+
| `a11y` | `{ enabled?: boolean, diagramLabel?: string, description?: string }` | `{ enabled: true }` | WCAG 2.1 AA accessibility options. The SVG is a labelled `group` holding a list of nodes and the flows as images, so all of them stay exposed to screen readers. Nodes are Tab stops in reading order (column by column, top to bottom); the arrow keys move to a node's flows. Zero-value nodes and flows draw nothing and are skipped. `description` fills a `<desc>` with an id unique to the diagram. |
|
|
126
134
|
| `locale` | `{ direction?: 'ltr' \| 'rtl' \| 'auto', messages?: Partial<SankeyMessages> }` | `{ direction: 'ltr' }` | Localization and text-direction. `direction: 'rtl'` mirrors the diagram horizontally (flows read right-to-left) and sets `dir="rtl"` on the container (`'auto'` defers to the document). `messages` overrides the screen-reader strings the diagram generates. |
|
|
127
135
|
|
|
128
136
|
### Chord
|
|
@@ -175,6 +183,30 @@ sankey.render({...ApexSankey.buildAlluvialData(input), options: sankey.options})
|
|
|
175
183
|
|
|
176
184
|
Each `AlluvialRecord` is `{ values: Record<string, string>, value?: number }` — the category at each dimension (keyed by dimension id), and the weight it contributes (default `1`). A record missing a category at some dimension simply skips that adjacency.
|
|
177
185
|
|
|
186
|
+
### Comparing frames: fixed scale and input order
|
|
187
|
+
|
|
188
|
+
By default every `render()` and `update()` fits the diagram to the chart: the largest column fills the height. That is right for one diagram, but across a series of updates (one frame per year, say) a small year is scaled up as far as a large one, so ribbon widths cannot be compared between frames. Two options make the frames comparable:
|
|
189
|
+
|
|
190
|
+
- `maxValue` fixes the scale. Set it to the largest column total across all the frames you will show. A column that totals `maxValue` fills the height as the largest column does by default; a lighter one is drawn in proportion, packed to the top (the left when vertical) with the same gaps, and the unused space collects below it. A column that totals more draws past the edge of the chart, with a one-time console warning. The gaps are shared among the nodes the column has in that frame. A node whose flows are left out of a frame leaves the layout, and the others move to share its gap, so keep such a node's flows in the data with a value of 0: it then keeps its slot at zero height.
|
|
191
|
+
- `nodeOrder: 'input'` keeps every column in the order the nodes are listed in `nodes`, so a flow that appears or disappears never reshuffles them. The column a node sits in still follows its flows.
|
|
192
|
+
|
|
193
|
+
```js
|
|
194
|
+
const sankey = new ApexSankey(el, {maxValue: 100, nodeOrder: 'input'});
|
|
195
|
+
sankey.render({nodes, edges: edges1950, options: sankey.options});
|
|
196
|
+
// later: the same value draws the same thickness, and the nodes keep their order
|
|
197
|
+
sankey.update({nodes, edges: edges2007, options: sankey.options});
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
Both work horizontally and vertically, in circular and alluvial diagrams, and in a [comparison](#comparison-split-view) (pass them in `options` and both panels share one scale and one order). A chord diagram always fills its ring and keeps the order of `nodes`, so it ignores `maxValue` (with a warning) and needs no `nodeOrder`.
|
|
201
|
+
|
|
202
|
+
Flows whose value is zero can stay in the data from frame to frame:
|
|
203
|
+
|
|
204
|
+
- A node whose flows are all zero is drawn at zero height. It is not a tab stop and screen readers do not announce it; a zero flow is skipped the same way, and is left out of its nodes' descriptions and of the diagram's node and flow counts.
|
|
205
|
+
- When an update takes the focused node or flow to zero, focus moves to the nearest one still drawn: a flow hands it to its source node (then its target), a node to the next node in reading order (then the previous one). A node removed from the data hands focus to the node now in its place in reading order.
|
|
206
|
+
- While an animated update runs, keyboard focus stays on the node or flow it was on, and the frame being drawn shows it: the node's focus ring and the connected-path highlight.
|
|
207
|
+
- When a flow rises from zero, it unfurls out of its source node, as a new flow does. When it falls to zero, it thins away in place.
|
|
208
|
+
- A frame in which every flow is zero draws nothing, without errors.
|
|
209
|
+
|
|
178
210
|
### Plugins & Events
|
|
179
211
|
|
|
180
212
|
Subscribe to instance events with `on` (it returns an unsubscribe function), or package reusable behaviour as a `SankeyPlugin` and install it with `use`.
|
|
@@ -206,8 +238,9 @@ Emitted events and their payloads:
|
|
|
206
238
|
| `edge:mouseleave` | `{ source, target, value, originalEvent }` | The pointer leaves a flow. |
|
|
207
239
|
| `rendered` | none | After the initial render and after each `update()` settles. |
|
|
208
240
|
| `destroyed` | none | On `destroy()`. |
|
|
241
|
+
| `playback:frame` | `{ index, frame }` | The `timePlayback` plugin showed a frame (a playback step, a scrub or `goTo()`). |
|
|
209
242
|
|
|
210
|
-
A `SankeyPlugin` is `{ name, install(ctx) }`. `install` receives `{ chart, on }` and may return a teardown function that runs on `destroy()`. Every subscription made through `ctx.on` is also released automatically on `destroy()`.
|
|
243
|
+
A `SankeyPlugin` is `{ name, install(ctx) }`. `install` receives `{ chart, on, emit }` and may return a teardown function that runs on `destroy()`. Every subscription made through `ctx.on` is also released automatically on `destroy()`. `ctx.emit(event, payload)` sends an event to the chart's subscribers, as `timePlayback` does with `playback:frame`.
|
|
211
244
|
|
|
212
245
|
#### Built-in plugins
|
|
213
246
|
|
|
@@ -234,12 +267,47 @@ sankey.use(timePlayback({frames, interval: 1500, loop: true}));
|
|
|
234
267
|
|
|
235
268
|
| `TimePlaybackOptions` | Type | Default | Description |
|
|
236
269
|
| --- | --- | --- | --- |
|
|
237
|
-
| `frames` | `TimePlaybackFrame[]` | required | Ordered frames (`{ nodes, edges, label? }`). Share topology across frames for a smooth morph. |
|
|
238
|
-
| `interval` | `number` | `1600` | Milliseconds each frame is shown before advancing
|
|
239
|
-
| `autoplay` | `boolean` | `false` | Start playing on install. |
|
|
270
|
+
| `frames` | `TimePlaybackFrame[]` | required | Ordered frames (`{ nodes, edges, label?, hold? }`). Share topology across frames for a smooth morph. |
|
|
271
|
+
| `interval` | `number` | `1600` | Milliseconds each frame is shown before advancing, unless the frame sets its own `hold`. |
|
|
272
|
+
| `autoplay` | `boolean` | `false` | Start playing on install. Ignored when the user prefers reduced motion. |
|
|
240
273
|
| `loop` | `boolean` | `false` | Loop back to the first frame after the last. |
|
|
241
274
|
| `controls` | `boolean` | `true` | Render the built-in control bar. |
|
|
242
275
|
| `mount` | `HTMLElement` | after the chart | Where to render the control bar. |
|
|
276
|
+
| `onFrame` | `(index, frame) => void` | none | Called each time the plugin shows a frame: a playback step, a scrub or `goTo()`. Not called on install. |
|
|
277
|
+
| `announce` | `boolean` | `true` | Announce frame changes to screen readers through a polite live region, with the frame's label. A scrub or `goTo()` is announced at once. While playing, announcements are at least 1.5 s apart so speech keeps up: the frame on screen when the gap ends is spoken, and so is the frame playback pauses or stops on. Skipped while the scrubber has focus, since it reads its own value out. |
|
|
278
|
+
|
|
279
|
+
A frame's `label` is what the bar shows, what the scrubber reads out as its value (`aria-valuetext`) and what the announcement speaks; a frame without one uses the `playbackFrameLabel` message (`Frame 2 / 75`). A frame's `hold` (milliseconds) replaces `interval` for that frame, so a story can stop on the frames it is about:
|
|
280
|
+
|
|
281
|
+
```js
|
|
282
|
+
const frames = years.map((y) => ({...y, label: String(y.year), hold: y.year === 2007 ? 4000 : 800}));
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
Under `locale.direction: 'rtl'` the bar is mirrored too: the button sits on the right and the scrubber runs right to left, the way the flows do.
|
|
286
|
+
|
|
287
|
+
`timePlayback()` returns the plugin, which is also its controller. Keep the reference to drive it from the page; `use()` still returns the chart, so chaining is unchanged:
|
|
288
|
+
|
|
289
|
+
```js
|
|
290
|
+
const playback = timePlayback({frames, controls: false, onFrame: (i, frame) => console.log(i, frame.label)});
|
|
291
|
+
sankey.use(playback);
|
|
292
|
+
playback.goTo(57); // show frame 57; playback, if running, continues from it
|
|
293
|
+
playback.play();
|
|
294
|
+
playback.pause();
|
|
295
|
+
playback.index; // the frame on screen
|
|
296
|
+
playback.playing; // whether playback is running
|
|
297
|
+
sankey.on('playback:frame', ({index, frame}) => {}); // the same as onFrame, as an event
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
| `TimePlaybackController` | Type | Description |
|
|
301
|
+
| --- | --- | --- |
|
|
302
|
+
| `play()` | `() => void` | Play from the frame on screen (from the first when the last is on screen and `loop` is off). |
|
|
303
|
+
| `pause()` | `() => void` | Stop on the frame on screen. |
|
|
304
|
+
| `goTo(index)` | `(index: number) => void` | Show a frame; the index is rounded and clamped, and a non-number is ignored. Called from `onFrame` or a `playback:frame` handler, it runs once every handler has seen the frame it was called for, and a call for that same frame is ignored. |
|
|
305
|
+
| `index` | `number` | 0-based index of the frame on screen. |
|
|
306
|
+
| `playing` | `boolean` | Whether playback is running. |
|
|
307
|
+
|
|
308
|
+
Before `use()` and after `destroy()` the controller does nothing, `index` reads `0` and `playing` reads `false`. Install each `timePlayback()` on one chart.
|
|
309
|
+
|
|
310
|
+
The control bar's play and pause glyphs are hidden from screen readers, and the button is named by the `playbackPlayLabel` and `playbackPauseLabel` messages, the scrubber by `playbackSliderLabel` (see [Localization & RTL](#localization--rtl)). The bar follows the diagram's theme: its text takes the label colour (`fontColor`, `--apex-sankey-label-color`, `--apx-fore`, the theme or the design system) once something sets it, and with light labels it renders its native parts dark and sits on the canvas colour the theme paints. The button and its border take `--apx-surface` and `--apx-grid`, and the scrubber `--apx-accent`. With nothing themed it keeps its light look.
|
|
243
311
|
|
|
244
312
|
`drillDown` turns a large diagram into a set of super-nodes you expand on demand: click a super-node to reveal its constituent flows, click any of its children to collapse it back. The drillable nodes get a `pointer` cursor so they read as clickable. Expanding animates the children **growing out of the super-node** (and shrinking back into it on collapse) with their ribbons — driven through the chart's own `update()` (which accepts an optional `SankeyTransition` hint for this). It is built on the pure `ApexSankey.collapseGroups` transform (also exported as `collapseGroups`), which re-routes and merges the flows of a collapsed group. Importable as `drillDown` or `ApexSankey.plugins.drillDown`; applies to the Sankey projection (not chord). Seed the initial collapsed render with `ApexSankey.collapseGroups` so there is no load-time morph.
|
|
245
313
|
|
|
@@ -281,7 +349,7 @@ const cmp = ApexSankey.compare(el, {
|
|
|
281
349
|
|
|
282
350
|
### Themes
|
|
283
351
|
|
|
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
|
|
352
|
+
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
353
|
|
|
286
354
|
```js
|
|
287
355
|
const sankey = new ApexSankey(el, {theme: 'dark'});
|
|
@@ -310,16 +378,46 @@ You can also pass an inline `SankeyTheme` object directly as `theme`. A `SankeyT
|
|
|
310
378
|
| `canvasStyle` | `string` | CSS on the SVG root container, typically the background and border. |
|
|
311
379
|
| `tooltipTheme` | `'light' \| 'dark'` | Tooltip color preset. |
|
|
312
380
|
|
|
381
|
+
### Node labels
|
|
382
|
+
|
|
383
|
+
`nodeLabel` sets what each node's label says, which side of the node it sits on, and how small a node can be and still get one. Every field is optional.
|
|
384
|
+
|
|
385
|
+
| `NodeLabelOptions` field | Type | Default | Description |
|
|
386
|
+
| --- | --- | --- | --- |
|
|
387
|
+
| `formatter` | `(content: NodeLabelContent) => string` | `undefined` | Returns the label text. `content.node` is the node's data and `content.value` its value (the larger of its incoming and outgoing totals, unrounded). The text is never truncated; an empty string leaves that node unlabelled. |
|
|
388
|
+
| `position` | `NodeLabelPosition` | `'inside'` | `'inside'` faces the middle of the diagram (downstream for the first half of the columns, upstream for the rest), `'outside'` the other way, `'start'` always upstream and `'end'` always downstream. These follow the flow, so they hold under RTL and `orientation: 'vertical'` (`'start'` is above a vertical bar). Labels past the outer columns sit in the `spacing` margin: raise `spacing` until they fit. |
|
|
389
|
+
| `minHeight` | `number` | `undefined` | Labels nodes at least this many pixels along the value axis (height, or width when vertical); `0` labels every node with a value. A zero-value node draws nothing and is never labelled. Unset, a node must be taller than `fontSize`. |
|
|
390
|
+
|
|
391
|
+
```ts
|
|
392
|
+
const sankey = new ApexSankey(el, {
|
|
393
|
+
nodeLabel: {
|
|
394
|
+
formatter: ({node, value}) => `${node.title} ${value.toFixed(1)}`, // "Coal 7.8"
|
|
395
|
+
position: 'end',
|
|
396
|
+
minHeight: 4,
|
|
397
|
+
},
|
|
398
|
+
});
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
During an animated `update()`, a label shows the new value from the first frame, and whether a node is labelled follows the height it is moving to. A label therefore appears or goes once, as the update starts, instead of popping in or out when the node crosses `minHeight` part way through.
|
|
402
|
+
|
|
313
403
|
### Localization & RTL
|
|
314
404
|
|
|
315
405
|
The diagram's screen-reader strings live in `SankeyMessages`; pass a `Partial<SankeyMessages>` via `locale.messages` to translate any subset (unset keys keep their English defaults, exported as `DEFAULT_SANKEY_MESSAGES`). Visible tooltips are localized separately via `tooltipTemplate` / `nodeTooltipTemplate`.
|
|
316
406
|
|
|
407
|
+
A message whose default is a function also takes a string template, whose `{name}` placeholders take the fields of the message's context: `playbackFrameLabel: '{position} of {total}'`, `diagramLabel: '{nodeCount} nodes, {flowCount} flows'`. This is the form the Blazor wrapper sends.
|
|
408
|
+
|
|
409
|
+
The English defaults speak numbers in English formatting, rounded to at most three decimals (three significant digits below 1, so a small flow is never read as 0). A message you supply receives the raw numbers. Zero-value flows, and nodes whose flows are all zero, are left out of the counts and summaries.
|
|
410
|
+
|
|
317
411
|
| `SankeyMessages` key | Type | Description |
|
|
318
412
|
| --- | --- | --- |
|
|
319
413
|
| `diagramLabel` | `(ctx: SankeyDiagramLabelContext) => string` | SVG root aria-label summary (node/flow counts + largest flow). |
|
|
320
414
|
| `nodeAriaLabel` | `(ctx: SankeyNodeLabelContext) => string` | Per-node aria-label (incoming/outgoing flow summary). |
|
|
321
|
-
| `edgeAriaLabel` | `(ctx: SankeyEdgeLabelContext) => string` | Per-edge aria-label. Default: `Flow from {source} to {target}: {value} units
|
|
415
|
+
| `edgeAriaLabel` | `(ctx: SankeyEdgeLabelContext) => string` | Per-edge aria-label. Default: `Flow from {source} to {target}: {value} units`, with `{value}` rounded (`1 unit` for exactly one). |
|
|
322
416
|
| `nodesGroupLabel` | `string` | aria-label for the `<g>` wrapping all nodes. Default: `'Sankey nodes'`. |
|
|
417
|
+
| `playbackFrameLabel` | `(ctx: SankeyPlaybackFrameContext) => string` | `timePlayback` text for a frame without a `label` (`ctx` is `{ position, total }`, 1-based). Default: `Frame {position} / {total}`. |
|
|
418
|
+
| `playbackPlayLabel` | `string` | aria-label of the `timePlayback` button while paused. Default: `'Play'`. |
|
|
419
|
+
| `playbackPauseLabel` | `string` | aria-label of the `timePlayback` button while playing. Default: `'Pause'`. |
|
|
420
|
+
| `playbackSliderLabel` | `string` | aria-label of the `timePlayback` scrubber. Default: `'Time frame'`. |
|
|
323
421
|
|
|
324
422
|
```ts
|
|
325
423
|
const sankey = new ApexSankey(el, {
|
|
@@ -330,7 +428,7 @@ const sankey = new ApexSankey(el, {
|
|
|
330
428
|
});
|
|
331
429
|
```
|
|
332
430
|
|
|
333
|
-
Default tooltip template
|
|
431
|
+
Default tooltip template (the built-in one rounds `value` to at most three decimals, three significant digits below 1; a template you supply gets the raw number)
|
|
334
432
|
|
|
335
433
|
```js
|
|
336
434
|
const tooltipTemplate = ({source, target, value}) => {
|
|
@@ -426,6 +524,29 @@ const data = {
|
|
|
426
524
|
};
|
|
427
525
|
```
|
|
428
526
|
|
|
527
|
+
### CSS variables
|
|
528
|
+
|
|
529
|
+
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.
|
|
530
|
+
|
|
531
|
+
| Variable | Sets |
|
|
532
|
+
| --- | --- |
|
|
533
|
+
| `--apex-sankey-label-color` | `fontColor` |
|
|
534
|
+
| `--apex-sankey-label-font-size` | `fontSize` |
|
|
535
|
+
| `--apex-sankey-font-family` | `fontFamily` |
|
|
536
|
+
| `--apex-sankey-node-width` | `nodeWidth` |
|
|
537
|
+
| `--apex-sankey-node-border-color` | `nodeBorderColor` |
|
|
538
|
+
| `--apex-sankey-node-border-width` | `nodeBorderWidth` |
|
|
539
|
+
| `--apex-sankey-edge-opacity` | `edgeOpacity` |
|
|
540
|
+
| `--apex-sankey-edge-gradient` | `edgeGradientFill` (`true` or `false`) |
|
|
541
|
+
| `--apex-sankey-tooltip-bg` | `tooltipBGColor` |
|
|
542
|
+
| `--apex-sankey-tooltip-border-color` | `tooltipBorderColor` |
|
|
543
|
+
| `--apex-sankey-tooltip-font-color` | `tooltipFontColor` |
|
|
544
|
+
| `--apex-sankey-tooltip-theme` | `tooltipTheme` (`light` or `dark`) |
|
|
545
|
+
| `--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) |
|
|
546
|
+
| `--apex-sankey-particle-color` | The `particleFlow` particles (default `rgba(255,255,255,0.9)`) |
|
|
547
|
+
|
|
548
|
+
After changing them without a render, call `refreshTokens()`.
|
|
549
|
+
|
|
429
550
|
## Family theme tokens (`--apx-*`)
|
|
430
551
|
|
|
431
552
|
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 +576,20 @@ Every chart in the ApexCharts family reads the same five root tokens, so a page
|
|
|
455
576
|
}
|
|
456
577
|
```
|
|
457
578
|
|
|
458
|
-
Custom properties inherit, so declaring them on `:root` reaches every chart on the page.
|
|
579
|
+
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
580
|
|
|
460
581
|
```
|
|
461
|
-
|
|
582
|
+
option you passed > --apex-sankey-* variable > --apx-* token > named theme > design system > built-in default
|
|
462
583
|
```
|
|
463
584
|
|
|
464
|
-
An option
|
|
585
|
+
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
586
|
|
|
466
587
|
### Named themes
|
|
467
588
|
|
|
468
|
-
`registerTheme` from
|
|
589
|
+
`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
590
|
|
|
470
591
|
```js
|
|
471
|
-
import {registerTheme} from '
|
|
592
|
+
import {registerTheme} from 'apex-commons';
|
|
472
593
|
|
|
473
594
|
registerTheme('acme', {
|
|
474
595
|
tokens: {accent: '#5b21b6', fore: '#101828', grid: '#e4e7ec', surface: '#ffffff'},
|
|
@@ -478,3 +599,19 @@ registerTheme('acme', {
|
|
|
478
599
|
A named theme's tokens sit one layer below the CSS `--apx-*` tokens, so the cascade still wins over the registry.
|
|
479
600
|
|
|
480
601
|
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.
|
|
602
|
+
|
|
603
|
+
### Design systems (Ignite UI)
|
|
604
|
+
|
|
605
|
+
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.
|
|
606
|
+
|
|
607
|
+
```js
|
|
608
|
+
import 'apexsankey/ignite-ui';
|
|
609
|
+
```
|
|
610
|
+
|
|
611
|
+
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.
|
|
612
|
+
|
|
613
|
+
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.
|
|
614
|
+
|
|
615
|
+
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.
|
|
616
|
+
|
|
617
|
+
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`.
|