@mui/x-charts-pro 8.20.0 → 8.21.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 (60) hide show
  1. package/BarChartPro/BarChartPro.js +18 -0
  2. package/CHANGELOG.md +112 -0
  3. package/ChartDataProviderPro/ChartDataProviderPro.js +1 -1
  4. package/ChartZoomSlider/internals/previews/BarPreviewPlot.js +3 -3
  5. package/Heatmap/Heatmap.js +2 -0
  6. package/LineChartPro/LineChartPro.js +18 -0
  7. package/SankeyChart/SankeyPlot.js +12 -16
  8. package/SankeyChart/calculateSankeyLayout.d.ts +2 -3
  9. package/SankeyChart/calculateSankeyLayout.js +3 -2
  10. package/SankeyChart/d3Sankey/align.d.ts +33 -0
  11. package/SankeyChart/d3Sankey/align.js +63 -0
  12. package/SankeyChart/d3Sankey/index.d.ts +4 -0
  13. package/SankeyChart/d3Sankey/index.js +49 -0
  14. package/SankeyChart/d3Sankey/sankey.d.ts +42 -0
  15. package/SankeyChart/d3Sankey/sankey.js +454 -0
  16. package/SankeyChart/d3Sankey/sankey.types.d.ts +344 -0
  17. package/SankeyChart/d3Sankey/sankey.types.js +5 -0
  18. package/SankeyChart/d3Sankey/sankeyLinkHorizontal.d.ts +22 -0
  19. package/SankeyChart/d3Sankey/sankeyLinkHorizontal.js +37 -0
  20. package/SankeyChart/sankey.types.d.ts +1 -1
  21. package/SankeyChart/seriesConfig/index.js +15 -0
  22. package/SankeyChart/seriesConfig/tooltipPosition.d.ts +3 -0
  23. package/SankeyChart/seriesConfig/tooltipPosition.js +96 -0
  24. package/SankeyChart/utils.d.ts +2 -2
  25. package/SankeyChart/utils.js +1 -1
  26. package/ScatterChartPro/ScatterChartPro.js +18 -0
  27. package/esm/BarChartPro/BarChartPro.js +18 -0
  28. package/esm/ChartDataProviderPro/ChartDataProviderPro.js +1 -1
  29. package/esm/ChartZoomSlider/internals/previews/BarPreviewPlot.js +3 -3
  30. package/esm/Heatmap/Heatmap.js +2 -0
  31. package/esm/LineChartPro/LineChartPro.js +18 -0
  32. package/esm/SankeyChart/SankeyPlot.js +14 -18
  33. package/esm/SankeyChart/calculateSankeyLayout.d.ts +2 -3
  34. package/esm/SankeyChart/calculateSankeyLayout.js +3 -2
  35. package/esm/SankeyChart/d3Sankey/align.d.ts +33 -0
  36. package/esm/SankeyChart/d3Sankey/align.js +54 -0
  37. package/esm/SankeyChart/d3Sankey/index.d.ts +4 -0
  38. package/esm/SankeyChart/d3Sankey/index.js +4 -0
  39. package/esm/SankeyChart/d3Sankey/sankey.d.ts +42 -0
  40. package/esm/SankeyChart/d3Sankey/sankey.js +448 -0
  41. package/esm/SankeyChart/d3Sankey/sankey.types.d.ts +344 -0
  42. package/esm/SankeyChart/d3Sankey/sankey.types.js +1 -0
  43. package/esm/SankeyChart/d3Sankey/sankeyLinkHorizontal.d.ts +22 -0
  44. package/esm/SankeyChart/d3Sankey/sankeyLinkHorizontal.js +31 -0
  45. package/esm/SankeyChart/sankey.types.d.ts +1 -1
  46. package/esm/SankeyChart/seriesConfig/index.js +14 -0
  47. package/esm/SankeyChart/seriesConfig/tooltipPosition.d.ts +3 -0
  48. package/esm/SankeyChart/seriesConfig/tooltipPosition.js +90 -0
  49. package/esm/SankeyChart/utils.d.ts +2 -2
  50. package/esm/SankeyChart/utils.js +1 -1
  51. package/esm/ScatterChartPro/ScatterChartPro.js +18 -0
  52. package/esm/hooks/useSankeySeries.d.ts +9 -2
  53. package/esm/hooks/useSankeySeries.js +15 -1
  54. package/esm/index.js +1 -1
  55. package/esm/typeOverloads/modules.d.ts +6 -1
  56. package/hooks/useSankeySeries.d.ts +9 -2
  57. package/hooks/useSankeySeries.js +15 -0
  58. package/index.js +1 -1
  59. package/package.json +5 -5
  60. package/typeOverloads/modules.d.ts +6 -1
@@ -0,0 +1,344 @@
1
+ /**
2
+ * A helper interface as an extension reference for user-provided properties of
3
+ * nodes and links in the graph, which are not required or calculated by
4
+ * the Sankey layout Generator
5
+ */
6
+ export interface SankeyExtraProperties {
7
+ [key: string]: any;
8
+ }
9
+ /**
10
+ * Helper interface to define the properties of Sankey Nodes. Calculated properties may only be defined,
11
+ * once the layout(...) method of the Sankey layout generator has been invoked.
12
+ *
13
+ * The first generic N refers to user-defined properties contained in the node data passed into
14
+ * Sankey layout generator. These properties are IN EXCESS to the properties explicitly identified in the
15
+ * SankeyNodeMinimal interface.
16
+ *
17
+ * The second generic L refers to user-defined properties contained in the link data passed into
18
+ * Sankey layout generator. These properties are IN EXCESS to the properties explicitly identified in the
19
+ * SankeyLinkMinimal interface.
20
+ */
21
+ export interface SankeyNodeMinimal<N extends SankeyExtraProperties, L extends SankeyExtraProperties> {
22
+ /**
23
+ * Array of outgoing links which have this node as their source.
24
+ * This property is calculated internally by the Sankey layout generator.
25
+ */
26
+ sourceLinks?: Array<SankeyLink<N, L>> | undefined;
27
+ /**
28
+ * Array of incoming links which have this node as their target.
29
+ * This property is calculated internally by the Sankey layout generator.
30
+ */
31
+ targetLinks?: Array<SankeyLink<N, L>> | undefined;
32
+ /**
33
+ * Node's value calculated by Sankey layout Generator;
34
+ * the sum of link.value for the node's incoming links.
35
+ */
36
+ value?: number | undefined;
37
+ /**
38
+ * Node's fixedValue (user-defined)
39
+ */
40
+ fixedValue?: number | undefined;
41
+ /**
42
+ * Node's zero-based index within the array of nodes calculated by Sankey layout generator.
43
+ */
44
+ index?: number | undefined;
45
+ /**
46
+ * Node's zero-based graph depth, derived from the graph topology calculated by Sankey layout generator.
47
+ */
48
+ depth?: number | undefined;
49
+ /**
50
+ * Node's zero-based graph height, derived from the graph topology calculated by Sankey layout generator.
51
+ */
52
+ height?: number | undefined;
53
+ /**
54
+ * Node's minimum horizontal position (derived from the node.depth) calculated by Sankey layout generator.
55
+ */
56
+ x0?: number | undefined;
57
+ /**
58
+ * Node's maximum horizontal position (node.x0 + sankey.nodeWidth) calculated by Sankey layout generator.
59
+ */
60
+ x1?: number | undefined;
61
+ /**
62
+ * Node's minimum vertical position calculated by Sankey layout generator.
63
+ */
64
+ y0?: number | undefined;
65
+ /**
66
+ * Node's maximum vertical position (node.y1 - node.y0 is proportional to node.value) calculated by Sankey layout generator.
67
+ */
68
+ y1?: number | undefined;
69
+ /**
70
+ * Link's layer in case of layered layout, calculated by Sankey layout generator.
71
+ */
72
+ layer?: number | undefined;
73
+ }
74
+ /**
75
+ * Sankey Node type including both user-defined node data elements as well as those
76
+ * calculated once the layout(...) method of the Sankey layout generators has been invoked.
77
+ *
78
+ * The first generic N refers to user-defined properties contained in the node data passed into
79
+ * Sankey layout generator. These properties are IN EXCESS to the properties explicitly identified in the
80
+ * SankeyNodeMinimal interface.
81
+ *
82
+ * The second generic L refers to user-defined properties contained in the link data passed into
83
+ * Sankey layout generator. These properties are IN EXCESS to the properties explicitly identified in the
84
+ * SankeyLinkMinimal interface.
85
+ */
86
+ export type SankeyNode<N extends SankeyExtraProperties, L extends SankeyExtraProperties> = N & SankeyNodeMinimal<N, L>;
87
+ /**
88
+ * Helper interface to define the properties of Sankey Links. Calculated properties may only be defined,
89
+ * once the layout(...) method of the Sankey layout generator has been invoked.
90
+ *
91
+ * The first generic N refers to user-defined properties contained in the node data passed into
92
+ * Sankey layout generator. These properties are IN EXCESS to the properties explicitly identified in the
93
+ * SankeyNodeMinimal interface.
94
+ *
95
+ * The second generic L refers to user-defined properties contained in the link data passed into
96
+ * Sankey layout generator. These properties are IN EXCESS to the properties explicitly identified in the
97
+ * SankeyLinkMinimal interface.
98
+ */
99
+ export interface SankeyLinkMinimal<N extends SankeyExtraProperties, L extends SankeyExtraProperties> {
100
+ /**
101
+ * Link's source node. For convenience, when initializing a Sankey layout using the default node id accessor,
102
+ * source may be the zero-based index of the corresponding node in the nodes array
103
+ * returned by the nodes accessor of the Sankey layout generator rather than object references. Alternatively,
104
+ * the Sankey layout can be configured with a custom node ID accessor to resolve the source node of the link upon initialization.
105
+ *
106
+ * Once the Sankey generator is invoked to return the Sankey graph object,
107
+ * the numeric index will be replaced with the corresponding source node object.
108
+ */
109
+ source: number | string | SankeyNode<N, L>;
110
+ /**
111
+ * Link's target node. For convenience, when initializing a Sankey layout using the default node id accessor,
112
+ * target may be the zero-based index of the corresponding node in the nodes array
113
+ * returned by the nodes accessor of the Sankey layout generator rather than object references. Alternatively,
114
+ * the Sankey layout can be configured with a custom node ID accessor to resolve the target node of the link upon initialization.
115
+ *
116
+ * Once the Sankey generator is invoked to return the Sankey graph object,
117
+ * the numeric index will be replaced with the corresponding target node object.
118
+ */
119
+ target: number | string | SankeyNode<N, L>;
120
+ /**
121
+ * Link's numeric value
122
+ */
123
+ value: number;
124
+ /**
125
+ * Link's vertical starting position (at source node) calculated by Sankey layout generator.
126
+ */
127
+ y0?: number | undefined;
128
+ /**
129
+ * Link's vertical end position (at target node) calculated by Sankey layout generator.
130
+ */
131
+ y1?: number | undefined;
132
+ /**
133
+ * Link's width (proportional to its value) calculated by Sankey layout generator.
134
+ */
135
+ width?: number | undefined;
136
+ /**
137
+ * Link's zero-based index within the array of links calculated by Sankey layout generator.
138
+ */
139
+ index?: number | undefined;
140
+ }
141
+ /**
142
+ * Sankey Link type including both user-defined link data elements, those required by the Sankey layout generator,
143
+ * as well as those calculated once the layout(...) method of the layout generator has been invoked.
144
+ *
145
+ * The first generic N refers to user-defined properties contained in the node data passed into
146
+ * Sankey layout generator. These properties are IN EXCESS to the properties explicitly identified in the
147
+ * SankeyNodeMinimal interface.
148
+ *
149
+ * The second generic L refers to user-defined properties contained in the link data passed into
150
+ * Sankey layout generator. These properties are IN EXCESS to the properties explicitly identified in the
151
+ * SankeyLinkMinimal interface.
152
+ */
153
+ export type SankeyLink<N extends SankeyExtraProperties, L extends SankeyExtraProperties> = L & SankeyLinkMinimal<N, L>;
154
+ /**
155
+ * A Sankey Graph Object which contains the computed layout information for nodes and links.
156
+ *
157
+ * The first generic N refers to user-defined properties contained in the node data passed into
158
+ * Sankey layout generator. These properties are IN EXCESS to the properties explicitly identified in the
159
+ * SankeyNodeMinimal interface.
160
+ *
161
+ * The second generic L refers to user-defined properties contained in the link data passed into
162
+ * Sankey layout generator. These properties are IN EXCESS to the properties explicitly identified in the
163
+ * SankeyLinkMinimal interface.
164
+ */
165
+ export interface SankeyGraph<N extends SankeyExtraProperties, L extends SankeyExtraProperties> {
166
+ /**
167
+ * Array of Sankey diagram nodes
168
+ */
169
+ nodes: Array<SankeyNode<N, L>>;
170
+ /**
171
+ * Array of Sankey diagram links
172
+ */
173
+ links: Array<SankeyLink<N, L>>;
174
+ }
175
+ /**
176
+ * A Sankey layout generator.
177
+ *
178
+ * The first generic Data refers to the data type of the first argument passed in when invoking the
179
+ * Sankey layout generator and internally the configured nodes/links accessor functions.
180
+ *
181
+ * The second generic N refers to user-defined properties contained in the node data passed into
182
+ * Sankey layout generator. These properties are IN EXCESS to the properties explicitly identified in the
183
+ * SankeyNodeMinimal interface.
184
+ *
185
+ * The third generic L refers to user-defined properties contained in the link data passed into
186
+ * Sankey layout generator. These properties are IN EXCESS to the properties explicitly identified in the
187
+ * SankeyLinkMinimal interface.
188
+ */
189
+ export interface SankeyLayout<Data, N extends SankeyExtraProperties, L extends SankeyExtraProperties> {
190
+ /**
191
+ * Computes the node and link positions for the given arguments, returning a graph representing the Sankey layout.
192
+ *
193
+ * @param data Data object being passed as the first argument to the nodes and links accessor functions. Additional arguments will also be passed
194
+ * to the accessor functions.
195
+ */
196
+ (data: Data, ...args: any[]): SankeyGraph<N, L>;
197
+ /**
198
+ * Recomputes the specified graph's links' positions, updating the following properties of each link:
199
+ *
200
+ * - link.sy: the link's vertical starting position (at source node)
201
+ * - link.ty: the link's vertical end position (at target node)
202
+ *
203
+ * This method is intended to be called after computing the initial Sankey layout, for example when the diagram is repositioned interactively.
204
+ *
205
+ * @param graph A previously initialized Sankey graph for which the link positions should be re-calculated
206
+ */
207
+ update(graph: SankeyGraph<N, L>): SankeyGraph<N, L>;
208
+ /**
209
+ * Return the current nodes accessor function, which defaults to a function returning the "nodes" property of the
210
+ * first argument it is invoked with.
211
+ */
212
+ nodes(): (data: Data, ...args: any[]) => Array<SankeyNode<N, L>>;
213
+ /**
214
+ * Set the Sankey generator's nodes accessor to a function returning the specified array of objects and returns this Sankey layout generator.
215
+ *
216
+ * @param nodes Array of nodes.
217
+ */
218
+ nodes(nodes: Array<SankeyNode<N, L>>): this;
219
+ /**
220
+ * Set the Sankey generator's nodes accessor to the specified function and returns this Sankey layout generator.
221
+ *
222
+ * @param nodes A nodes accessor function. The function is invoked when the Sankey layout is generated, being passed any arguments passed to the Sankey generator.
223
+ * This function must return an array of nodes.
224
+ */
225
+ nodes(nodes: (data: Data, ...args: any[]) => Array<SankeyNode<N, L>>): this;
226
+ /**
227
+ * Return the current links accessor function, which defaults to a function returning the "links" property of the
228
+ * first argument it is invoked with.
229
+ */
230
+ links(): (data: Data, ...args: any[]) => Array<SankeyLink<N, L>>;
231
+ /**
232
+ * Set the Sankey generator's links accessor to a function returning the specified array of objects and returns this Sankey layout generator.
233
+ *
234
+ * @param links Array of links.
235
+ */
236
+ links(links: Array<SankeyLink<N, L>>): this;
237
+ /**
238
+ * Set the Sankey generator's links accessor to the specified function and returns this Sankey layout generator.
239
+ *
240
+ * @param links A links accessor function. The function is invoked when the Sankey layout is generated, being passed any arguments passed to the Sankey generator.
241
+ * This function must return an array of links.
242
+ */
243
+ links(links: (data: Data, ...args: any[]) => Array<SankeyLink<N, L>>): this;
244
+ /**
245
+ * Return the current node id accessor.
246
+ * The default accessor is a function being passed in a Sankey layout node and returning its numeric node.index.
247
+ */
248
+ nodeId(): (node: SankeyNode<N, L>) => string | number;
249
+ /**
250
+ * Set the node id accessor to the specified function and return this Sankey layout generator.
251
+ *
252
+ * The default accessor is a function being passed in a Sankey layout node and returning its numeric node.index.
253
+ * The default id accessor allows each link's source and target to be specified as a zero-based index into the nodes array.
254
+ *
255
+ * @param nodeId A node id accessor function being passed a node in the Sankey graph and returning its id.
256
+ */
257
+ nodeId(nodeId: (node: SankeyNode<N, L>) => string | number): this;
258
+ /**
259
+ * Return the current node alignment method, which defaults to d3.sankeyJustify.
260
+ */
261
+ nodeAlign(): (node: SankeyNode<N, L>, n: number) => number;
262
+ /**
263
+ * Set the node alignment method the specified function and return this Sankey layout generator.
264
+ *
265
+ * @param nodeAlign A node alignment function which is evaluated for each input node in order,
266
+ * being passed the current node and the total depth n of the graph (one plus the maximum node.depth),
267
+ * and must return an integer between 0 and n - 1 that indicates the desired horizontal position of the node in the generated Sankey diagram.
268
+ */
269
+ nodeAlign(nodeAlign: (node: SankeyNode<N, L>, n: number) => number): this;
270
+ /**
271
+ * Return the current node width, which defaults to 24.
272
+ */
273
+ nodeWidth(): number;
274
+ /**
275
+ * Set the node width to the specified number and return this Sankey layout generator.
276
+ *
277
+ * @param width Width of node in pixels, which defaults to 24.
278
+ */
279
+ nodeWidth(width: number): this;
280
+ /**
281
+ * Return the current node padding, which defaults to 8.
282
+ *
283
+ * Node padding refers to the vertical space between nodes which occupy the same horizontal space.
284
+ */
285
+ nodePadding(): number;
286
+ /**
287
+ * Set the vertical separation between nodes at each column to the specified number and return this Sankey layout generator.
288
+ *
289
+ * @param padding Node padding, i.e. vertical separation between nodes at each column, in pixels, which defaults to 8.
290
+ */
291
+ nodePadding(padding: number): this;
292
+ /**
293
+ * Return the current extent which defaults to [[0, 0], [1, 1]].
294
+ */
295
+ extent(): [[number, number], [number, number]];
296
+ /**
297
+ * Set the extent of the Sankey layout to the specified bounds and returns this Sankey layout generator.
298
+ *
299
+ * @param extent Extent bounds for the layout. The extent bounds are specified as an array [[x0, y0], [x1, y1]],
300
+ * where x0 is the left side of the extent, y0 is the top, x1 is the right and y1 is the bottom. The default is [[0, 0], [1, 1]].
301
+ */
302
+ extent(extent: [[number, number], [number, number]]): this;
303
+ /**
304
+ * Return the current layout size in pixels. The size is a two element array of [width, height] which defaults to [1, 1].
305
+ */
306
+ size(): [number, number];
307
+ /**
308
+ * Set the size of the layout and return this Sankey layout generator.
309
+ * This convenience method is equivalent to using extent([[0, 0], [width, height]]).
310
+ *
311
+ * @param size A two element array of [width, height] in pixels which defaults to [1, 1].
312
+ */
313
+ size(size: [number, number]): this;
314
+ /**
315
+ * Return the current number of relaxation iterations, which defaults to 32.
316
+ */
317
+ iterations(): number;
318
+ /**
319
+ * Set the number of relaxation iterations when generating the layout and return this Sankey layout generator.
320
+ *
321
+ * @param iterations Number of relaxation iterations, which defaults to 32.
322
+ */
323
+ iterations(iterations: number): this;
324
+ /**
325
+ * Returns the node comparison function which defaults to undefined.
326
+ */
327
+ nodeSort(): ((a: SankeyNode<N, L>, b: SankeyNode<N, L>) => number) | undefined | null;
328
+ /**
329
+ * Set the node comparison function and return this Sankey layout generator.
330
+ *
331
+ * @param compare Node comparison function. If `null`, the order is fixed by the input.
332
+ */
333
+ nodeSort(compare: ((a: SankeyNode<N, L>, b: SankeyNode<N, L>) => number) | undefined | null): this;
334
+ /**
335
+ * Returns the link comparison function which defaults to undefined.
336
+ */
337
+ linkSort(): ((a: SankeyLink<N, L>, b: SankeyLink<N, L>) => number) | undefined | null;
338
+ /**
339
+ * Set the link comparison function and return this Sankey layout generator.
340
+ *
341
+ * @param compare Link comparison function. If `null`, the order is fixed by the input.
342
+ */
343
+ linkSort(compare: ((a: SankeyLink<N, L>, b: SankeyLink<N, L>) => number) | undefined | null): this;
344
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,22 @@
1
+ import { type Link } from '@mui/x-charts-vendor/d3-shape';
2
+ import type { SankeyExtraProperties, SankeyLink } from "./sankey.types.js";
3
+ /**
4
+ * Get a horizontal link shape suitable for a Sankey diagram.
5
+ * Source and target accessors are pre-configured and work with the
6
+ * default x- and y- accessors of the link shape generator.
7
+ */
8
+ export declare function sankeyLinkHorizontal(): Link<any, SankeyLink<{}, {}>, [number, number]>;
9
+ /**
10
+ * Get a horizontal link shape suitable for a Sankey diagram.
11
+ * Source and target accessors are pre-configured and work with the
12
+ * default x- and y- accessors of the link shape generator.
13
+ *
14
+ * The first generic N refers to user-defined properties contained in the node data passed into
15
+ * Sankey layout generator. These properties are IN EXCESS to the properties explicitly identified in the
16
+ * SankeyNodeMinimal interface.
17
+ *
18
+ * The second generic L refers to user-defined properties contained in the link data passed into
19
+ * Sankey layout generator. These properties are IN EXCESS to the properties explicitly identified in the
20
+ * SankeyLinkMinimal interface.
21
+ */
22
+ export declare function sankeyLinkHorizontal<N extends SankeyExtraProperties, L extends SankeyExtraProperties>(): Link<any, SankeyLink<N, L>, [number, number]>;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.sankeyLinkHorizontal = sankeyLinkHorizontal;
7
+ var _d3Shape = require("@mui/x-charts-vendor/d3-shape");
8
+ function horizontalSource(d) {
9
+ return [d.source.x1, d.y0];
10
+ }
11
+ function horizontalTarget(d) {
12
+ return [d.target.x0, d.y1];
13
+ }
14
+
15
+ /**
16
+ * Get a horizontal link shape suitable for a Sankey diagram.
17
+ * Source and target accessors are pre-configured and work with the
18
+ * default x- and y- accessors of the link shape generator.
19
+ */
20
+
21
+ /**
22
+ * Get a horizontal link shape suitable for a Sankey diagram.
23
+ * Source and target accessors are pre-configured and work with the
24
+ * default x- and y- accessors of the link shape generator.
25
+ *
26
+ * The first generic N refers to user-defined properties contained in the node data passed into
27
+ * Sankey layout generator. These properties are IN EXCESS to the properties explicitly identified in the
28
+ * SankeyNodeMinimal interface.
29
+ *
30
+ * The second generic L refers to user-defined properties contained in the link data passed into
31
+ * Sankey layout generator. These properties are IN EXCESS to the properties explicitly identified in the
32
+ * SankeyLinkMinimal interface.
33
+ */
34
+
35
+ function sankeyLinkHorizontal() {
36
+ return (0, _d3Shape.linkHorizontal)().source(horizontalSource).target(horizontalTarget);
37
+ }
@@ -1,6 +1,6 @@
1
1
  import type { HighlightScope, SeriesId } from '@mui/x-charts/internals';
2
2
  import type { DefaultizedProps, MakeRequired } from '@mui/x-internals/types';
3
- import type { SankeyLink as D3SankeyLink, SankeyNode as D3SankeyNode } from '@mui/x-charts-vendor/d3-sankey';
3
+ import type { SankeyLink as D3SankeyLink, SankeyNode as D3SankeyNode } from "./d3Sankey/index.js";
4
4
  import type { SankeyLinkHighlightScope, SankeyNodeHighlightScope } from "./sankey.highlight.types.js";
5
5
  export type SankeyNodeId = string | number;
6
6
  export interface SankeyNode {
@@ -1,19 +1,34 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.sankeySeriesConfig = void 0;
7
8
  var _getSeriesWithDefaultValues = require("./getSeriesWithDefaultValues");
8
9
  var _tooltipGetter = require("./tooltipGetter");
10
+ var _calculateSankeyLayout = require("../calculateSankeyLayout");
11
+ var _tooltipPosition = _interopRequireDefault(require("./tooltipPosition"));
9
12
  // Simple passthrough functions for sankey chart
10
13
  const seriesProcessor = series => series;
11
14
  const colorProcessor = series => series;
12
15
  const legendGetter = () => [];
16
+ const seriesLayout = (series, drawingArea) => {
17
+ if (series.seriesOrder.length === 0) {
18
+ return {};
19
+ }
20
+ return {
21
+ [series.seriesOrder[0]]: {
22
+ sankeyLayout: (0, _calculateSankeyLayout.calculateSankeyLayout)(series.series[series.seriesOrder[0]], drawingArea)
23
+ }
24
+ };
25
+ };
13
26
  const sankeySeriesConfig = exports.sankeySeriesConfig = {
14
27
  seriesProcessor,
28
+ seriesLayout,
15
29
  colorProcessor,
16
30
  legendGetter,
17
31
  tooltipGetter: _tooltipGetter.tooltipGetter,
32
+ tooltipItemPositionGetter: _tooltipPosition.default,
18
33
  getSeriesWithDefaultValues: _getSeriesWithDefaultValues.getSeriesWithDefaultValues
19
34
  };
@@ -0,0 +1,3 @@
1
+ import type { TooltipItemPositionGetter } from '@mui/x-charts/internals';
2
+ declare const tooltipItemPositionGetter: TooltipItemPositionGetter<'sankey'>;
3
+ export default tooltipItemPositionGetter;
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ const tooltipItemPositionGetter = params => {
8
+ const {
9
+ series,
10
+ seriesLayout,
11
+ identifier,
12
+ placement
13
+ } = params;
14
+ if (!identifier) {
15
+ return null;
16
+ }
17
+ const seriesItem = series.sankey?.series[identifier.seriesId];
18
+ const layout = seriesLayout.sankey?.[identifier.seriesId]?.sankeyLayout;
19
+ if (seriesItem == null || layout == null) {
20
+ return null;
21
+ }
22
+ if (identifier.subType === 'node') {
23
+ const node = layout.nodes.find(n => n.id === identifier.nodeId);
24
+ if (!node) {
25
+ return null;
26
+ }
27
+ const {
28
+ x0 = 0,
29
+ x1 = 0,
30
+ y0 = 0,
31
+ y1 = 0
32
+ } = node;
33
+ switch (placement) {
34
+ case 'bottom':
35
+ return {
36
+ x: (x1 + x0) / 2,
37
+ y: y1
38
+ };
39
+ case 'left':
40
+ return {
41
+ x: x0,
42
+ y: (y1 + y0) / 2
43
+ };
44
+ case 'right':
45
+ return {
46
+ x: x1,
47
+ y: (y1 + y0) / 2
48
+ };
49
+ case 'top':
50
+ default:
51
+ return {
52
+ x: (x1 + x0) / 2,
53
+ y: y0
54
+ };
55
+ }
56
+ }
57
+ if (identifier.subType === 'link') {
58
+ const link = layout.links.find(l => l.source.id === identifier.sourceId && l.target.id === identifier.targetId);
59
+ if (!link) {
60
+ return null;
61
+ }
62
+ const {
63
+ y0: yStart = 0,
64
+ y1: yEnd = 0
65
+ } = link;
66
+ const y0 = Math.min(yStart, yEnd) - link.width / 2;
67
+ const y1 = Math.max(yStart, yEnd) + link.width / 2;
68
+ const x0 = Math.min(link.source.x1 ?? 0, link.target.x1 ?? 0);
69
+ const x1 = Math.max(link.source.x0 ?? 0, link.target.x0 ?? 0);
70
+ switch (placement) {
71
+ case 'bottom':
72
+ return {
73
+ x: (x1 + x0) / 2,
74
+ y: y1
75
+ };
76
+ case 'left':
77
+ return {
78
+ x: x0,
79
+ y: (y1 + y0) / 2
80
+ };
81
+ case 'right':
82
+ return {
83
+ x: x1,
84
+ y: (y1 + y0) / 2
85
+ };
86
+ case 'top':
87
+ default:
88
+ return {
89
+ x: (x1 + x0) / 2,
90
+ y: y0
91
+ };
92
+ }
93
+ }
94
+ return null;
95
+ };
96
+ var _default = exports.default = tooltipItemPositionGetter;
@@ -1,3 +1,3 @@
1
- import { sankeyLeft } from '@mui/x-charts-vendor/d3-sankey';
1
+ import { sankeyJustify } from "./d3Sankey/index.js";
2
2
  import type { SankeyNodeOptions } from "./sankey.types.js";
3
- export declare const getNodeAlignFunction: (align: SankeyNodeOptions["align"]) => typeof sankeyLeft;
3
+ export declare const getNodeAlignFunction: (align: SankeyNodeOptions["align"]) => typeof sankeyJustify;
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getNodeAlignFunction = void 0;
7
- var _d3Sankey = require("@mui/x-charts-vendor/d3-sankey");
7
+ var _d3Sankey = require("./d3Sankey");
8
8
  const getNodeAlignFunction = align => {
9
9
  switch (align) {
10
10
  case 'left':