@mui/x-charts-pro 8.10.2 → 8.11.1

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 (124) hide show
  1. package/BarChartPro/BarChartPro.js +0 -36
  2. package/CHANGELOG.md +214 -13
  3. package/ChartDataProviderPro/ChartDataProviderPro.js +1 -1
  4. package/FunnelChart/curves/bump.js +0 -2
  5. package/FunnelChart/curves/linear.js +0 -2
  6. package/FunnelChart/curves/pyramid.js +0 -2
  7. package/FunnelChart/curves/step-pyramid.js +0 -2
  8. package/FunnelChart/curves/step.js +0 -2
  9. package/FunnelChart/labelUtils.d.ts +7 -5
  10. package/FunnelChart/labelUtils.js +2 -2
  11. package/Heatmap/Heatmap.js +0 -4
  12. package/LineChartPro/LineChartPro.js +0 -36
  13. package/PieChartPro/PieChartPro.js +2 -2
  14. package/SankeyChart/SankeyChart.d.ts +32 -0
  15. package/SankeyChart/SankeyChart.js +161 -0
  16. package/SankeyChart/SankeyChart.plugins.d.ts +3 -0
  17. package/SankeyChart/SankeyChart.plugins.js +11 -0
  18. package/SankeyChart/SankeyLinkElement.d.ts +27 -0
  19. package/SankeyChart/SankeyLinkElement.js +53 -0
  20. package/SankeyChart/SankeyLinkLabel.d.ts +12 -0
  21. package/SankeyChart/SankeyLinkLabel.js +58 -0
  22. package/SankeyChart/SankeyNodeElement.d.ts +27 -0
  23. package/SankeyChart/SankeyNodeElement.js +76 -0
  24. package/SankeyChart/SankeyPlot.d.ts +29 -0
  25. package/SankeyChart/SankeyPlot.js +100 -0
  26. package/SankeyChart/SankeyTooltip/SankeyTooltip.classes.d.ts +2 -0
  27. package/SankeyChart/SankeyTooltip/SankeyTooltip.classes.js +27 -0
  28. package/SankeyChart/SankeyTooltip/SankeyTooltip.d.ts +7 -0
  29. package/SankeyChart/SankeyTooltip/SankeyTooltip.js +208 -0
  30. package/SankeyChart/SankeyTooltip/SankeyTooltip.types.d.ts +10 -0
  31. package/SankeyChart/SankeyTooltip/SankeyTooltip.types.js +5 -0
  32. package/SankeyChart/SankeyTooltip/SankeyTooltipContent.d.ts +7 -0
  33. package/SankeyChart/SankeyTooltip/SankeyTooltipContent.js +66 -0
  34. package/SankeyChart/SankeyTooltip/index.d.ts +3 -0
  35. package/SankeyChart/SankeyTooltip/index.js +27 -0
  36. package/SankeyChart/calculateSankeyLayout.d.ts +13 -0
  37. package/SankeyChart/calculateSankeyLayout.js +141 -0
  38. package/SankeyChart/index.d.ts +9 -0
  39. package/SankeyChart/index.js +70 -0
  40. package/SankeyChart/sankey.types.d.ts +225 -0
  41. package/SankeyChart/sankey.types.js +6 -0
  42. package/SankeyChart/sankeyClasses.d.ts +15 -0
  43. package/SankeyChart/sankeyClasses.js +28 -0
  44. package/SankeyChart/sankeySlots.types.d.ts +24 -0
  45. package/SankeyChart/sankeySlots.types.js +5 -0
  46. package/SankeyChart/seriesConfig/getSeriesWithDefaultValues.d.ts +2 -0
  47. package/SankeyChart/seriesConfig/getSeriesWithDefaultValues.js +55 -0
  48. package/SankeyChart/seriesConfig/index.d.ts +2 -0
  49. package/SankeyChart/seriesConfig/index.js +19 -0
  50. package/SankeyChart/seriesConfig/tooltipGetter.d.ts +2 -0
  51. package/SankeyChart/seriesConfig/tooltipGetter.js +46 -0
  52. package/SankeyChart/useSankeyChartProps.d.ts +22 -0
  53. package/SankeyChart/useSankeyChartProps.js +77 -0
  54. package/SankeyChart/utils.d.ts +3 -0
  55. package/SankeyChart/utils.js +21 -0
  56. package/ScatterChartPro/ScatterChartPro.js +1 -37
  57. package/esm/BarChartPro/BarChartPro.js +0 -36
  58. package/esm/ChartDataProviderPro/ChartDataProviderPro.js +1 -1
  59. package/esm/FunnelChart/curves/bump.js +0 -2
  60. package/esm/FunnelChart/curves/linear.js +0 -2
  61. package/esm/FunnelChart/curves/pyramid.js +0 -2
  62. package/esm/FunnelChart/curves/step-pyramid.js +0 -2
  63. package/esm/FunnelChart/curves/step.js +0 -2
  64. package/esm/FunnelChart/labelUtils.d.ts +7 -5
  65. package/esm/FunnelChart/labelUtils.js +2 -2
  66. package/esm/Heatmap/Heatmap.js +0 -4
  67. package/esm/LineChartPro/LineChartPro.js +0 -36
  68. package/esm/PieChartPro/PieChartPro.js +2 -2
  69. package/esm/SankeyChart/SankeyChart.d.ts +32 -0
  70. package/esm/SankeyChart/SankeyChart.js +155 -0
  71. package/esm/SankeyChart/SankeyChart.plugins.d.ts +3 -0
  72. package/esm/SankeyChart/SankeyChart.plugins.js +9 -0
  73. package/esm/SankeyChart/SankeyLinkElement.d.ts +27 -0
  74. package/esm/SankeyChart/SankeyLinkElement.js +46 -0
  75. package/esm/SankeyChart/SankeyLinkLabel.d.ts +12 -0
  76. package/esm/SankeyChart/SankeyLinkLabel.js +52 -0
  77. package/esm/SankeyChart/SankeyNodeElement.d.ts +27 -0
  78. package/esm/SankeyChart/SankeyNodeElement.js +69 -0
  79. package/esm/SankeyChart/SankeyPlot.d.ts +29 -0
  80. package/esm/SankeyChart/SankeyPlot.js +94 -0
  81. package/esm/SankeyChart/SankeyTooltip/SankeyTooltip.classes.d.ts +2 -0
  82. package/esm/SankeyChart/SankeyTooltip/SankeyTooltip.classes.js +19 -0
  83. package/esm/SankeyChart/SankeyTooltip/SankeyTooltip.d.ts +7 -0
  84. package/esm/SankeyChart/SankeyTooltip/SankeyTooltip.js +202 -0
  85. package/esm/SankeyChart/SankeyTooltip/SankeyTooltip.types.d.ts +10 -0
  86. package/esm/SankeyChart/SankeyTooltip/SankeyTooltip.types.js +1 -0
  87. package/esm/SankeyChart/SankeyTooltip/SankeyTooltipContent.d.ts +7 -0
  88. package/esm/SankeyChart/SankeyTooltip/SankeyTooltipContent.js +59 -0
  89. package/esm/SankeyChart/SankeyTooltip/index.d.ts +3 -0
  90. package/esm/SankeyChart/SankeyTooltip/index.js +3 -0
  91. package/esm/SankeyChart/calculateSankeyLayout.d.ts +13 -0
  92. package/esm/SankeyChart/calculateSankeyLayout.js +135 -0
  93. package/esm/SankeyChart/index.d.ts +9 -0
  94. package/esm/SankeyChart/index.js +6 -0
  95. package/esm/SankeyChart/sankey.types.d.ts +225 -0
  96. package/esm/SankeyChart/sankey.types.js +3 -0
  97. package/esm/SankeyChart/sankeyClasses.d.ts +15 -0
  98. package/esm/SankeyChart/sankeyClasses.js +19 -0
  99. package/esm/SankeyChart/sankeySlots.types.d.ts +24 -0
  100. package/esm/SankeyChart/sankeySlots.types.js +1 -0
  101. package/esm/SankeyChart/seriesConfig/getSeriesWithDefaultValues.d.ts +2 -0
  102. package/esm/SankeyChart/seriesConfig/getSeriesWithDefaultValues.js +47 -0
  103. package/esm/SankeyChart/seriesConfig/index.d.ts +2 -0
  104. package/esm/SankeyChart/seriesConfig/index.js +14 -0
  105. package/esm/SankeyChart/seriesConfig/tooltipGetter.d.ts +2 -0
  106. package/esm/SankeyChart/seriesConfig/tooltipGetter.js +39 -0
  107. package/esm/SankeyChart/useSankeyChartProps.d.ts +22 -0
  108. package/esm/SankeyChart/useSankeyChartProps.js +70 -0
  109. package/esm/SankeyChart/utils.d.ts +3 -0
  110. package/esm/SankeyChart/utils.js +14 -0
  111. package/esm/ScatterChartPro/ScatterChartPro.js +1 -37
  112. package/esm/hooks/useSankeySeries.d.ts +33 -0
  113. package/esm/hooks/useSankeySeries.js +42 -0
  114. package/esm/index.d.ts +1 -0
  115. package/esm/index.js +2 -1
  116. package/esm/internals/plugins/allPlugins.d.ts +2 -2
  117. package/esm/typeOverloads/modules.d.ts +11 -0
  118. package/hooks/useSankeySeries.d.ts +33 -0
  119. package/hooks/useSankeySeries.js +48 -0
  120. package/index.d.ts +1 -0
  121. package/index.js +13 -1
  122. package/internals/plugins/allPlugins.d.ts +2 -2
  123. package/package.json +15 -15
  124. package/typeOverloads/modules.d.ts +11 -0
@@ -0,0 +1,9 @@
1
+ export { SankeyChart as Unstable_SankeyChart } from "./SankeyChart.js";
2
+ export type { SankeyChartProps, SankeySeries } from "./SankeyChart.js";
3
+ export { SankeyPlot } from "./SankeyPlot.js";
4
+ export type { SankeyPlotProps } from "./SankeyPlot.js";
5
+ export * from "./sankey.types.js";
6
+ export * from "./sankeySlots.types.js";
7
+ export { type SankeyPlotClasses, sankeyPlotClasses } from "./sankeyClasses.js";
8
+ export { SankeyTooltip, SankeyTooltipContent } from "./SankeyTooltip/index.js";
9
+ export type { SankeyTooltipProps } from "./SankeyTooltip/index.js";
@@ -0,0 +1,6 @@
1
+ export { SankeyChart as Unstable_SankeyChart } from "./SankeyChart.js";
2
+ export { SankeyPlot } from "./SankeyPlot.js";
3
+ export * from "./sankey.types.js";
4
+ export * from "./sankeySlots.types.js";
5
+ export { sankeyPlotClasses } from "./sankeyClasses.js";
6
+ export { SankeyTooltip, SankeyTooltipContent } from "./SankeyTooltip/index.js";
@@ -0,0 +1,225 @@
1
+ import type { HighlightScope, SeriesId } from '@mui/x-charts/internals';
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';
4
+ export type SankeyNodeId = string | number;
5
+ export interface SankeyNode {
6
+ /**
7
+ * Unique identifier for the node
8
+ */
9
+ id: SankeyNodeId;
10
+ /**
11
+ * The node label to display
12
+ */
13
+ label?: string;
14
+ /**
15
+ * Optional custom data for the node
16
+ */
17
+ data?: any;
18
+ /**
19
+ * Optional color override for the node
20
+ */
21
+ color?: string;
22
+ }
23
+ export interface SankeyLink {
24
+ /**
25
+ * Source node ID
26
+ */
27
+ source: SankeyNodeId;
28
+ /**
29
+ * Target node ID
30
+ */
31
+ target: SankeyNodeId;
32
+ /**
33
+ * The value/weight of the link (affects width)
34
+ */
35
+ value: number;
36
+ /**
37
+ * Optional custom data for the link
38
+ */
39
+ data?: any;
40
+ /**
41
+ * Optional color override for the link
42
+ */
43
+ color?: string;
44
+ }
45
+ export type SankeyNodeOptions = {
46
+ /**
47
+ * Default color for nodes without specified colors
48
+ */
49
+ color?: string;
50
+ /**
51
+ * Width of the nodes in pixels
52
+ */
53
+ width?: number;
54
+ /**
55
+ * Padding between nodes in pixels
56
+ */
57
+ padding?: number;
58
+ /**
59
+ * Node alignment strategy
60
+ * - 'justify': Nodes are evenly distributed across the width.
61
+ * - 'left': Nodes are aligned to the left.
62
+ * - 'right': Nodes are aligned to the right.
63
+ * - 'center': Nodes are centered.
64
+ * @default 'justify'
65
+ */
66
+ align?: 'justify' | 'left' | 'right' | 'center';
67
+ /**
68
+ * Whether to show node labels
69
+ */
70
+ showLabels?: boolean;
71
+ /**
72
+ * Custom sort function for nodes
73
+ * @param {SankeyLayoutNode} a - First node to compare
74
+ * @param {SankeyLayoutNode} b - Second node to compare
75
+ * @returns {number} Comparison result
76
+ */
77
+ sort?: (a: SankeyLayoutNode, b: SankeyLayoutNode) => number | null;
78
+ };
79
+ export type SankeyLinkOptions = {
80
+ /**
81
+ * Default color for links without specified colors
82
+ */
83
+ color?: string;
84
+ /**
85
+ * Opacity of the links (0-1)
86
+ */
87
+ opacity?: number;
88
+ /**
89
+ * Whether to show link values
90
+ */
91
+ showValues?: boolean;
92
+ /**
93
+ * Custom sort function for links
94
+ * @param {SankeyLayoutLink} a - First link to compare
95
+ * @param {SankeyLayoutLink} b - Second link to compare
96
+ * @returns {number} Comparison result
97
+ */
98
+ sort?: (a: SankeyLayoutLink, b: SankeyLayoutLink) => number | null;
99
+ /**
100
+ * Applies the given number to the X dimension of the control points of the link's curve function.
101
+ * This can create better looking links between nodes, but is dependent on the graph layout.
102
+ * It is specially impacted by the chart height.
103
+ * @default 10
104
+ */
105
+ curveCorrection?: number;
106
+ };
107
+ export interface SankeyData {
108
+ /**
109
+ * An array of node configs for the Sankey diagram
110
+ *
111
+ * This is optional, but can be used to provide custom labels or styles for nodes.
112
+ */
113
+ nodes?: readonly SankeyNode[];
114
+ /**
115
+ * Array of links between nodes.
116
+ *
117
+ * The node ids will be used as the labels. If you want to provide custom labels, use the `nodes` property.
118
+ *
119
+ * Each link should have a `source`, `target`, and `value` property.
120
+ */
121
+ links: readonly SankeyLink[];
122
+ }
123
+ export interface SankeySeriesType {
124
+ /**
125
+ * Unique identifier for the series
126
+ */
127
+ id?: SeriesId;
128
+ /**
129
+ * Type identifier for Sankey series
130
+ */
131
+ type: 'sankey';
132
+ /**
133
+ * The data for the Sankey diagram
134
+ */
135
+ data: SankeyData;
136
+ /**
137
+ * Optional configuration for the nodes style, layout, and behavior
138
+ */
139
+ nodeOptions?: SankeyNodeOptions;
140
+ /**
141
+ * Optional configuration for the links style, layout, and behavior
142
+ */
143
+ linkOptions?: SankeyLinkOptions;
144
+ /**
145
+ * Number of iterations for the layout algorithm
146
+ * @default 6
147
+ */
148
+ iterations?: number;
149
+ }
150
+ /**
151
+ * Represents the calculated positions and dimensions for a node in the Sankey diagram
152
+ */
153
+ export interface SankeyLayoutNode extends D3SankeyNode<MakeRequired<SankeyNode, 'label' | 'color'>, SankeyLayoutLink> {
154
+ targetLinks: SankeyLayoutLink[];
155
+ sourceLinks: SankeyLayoutLink[];
156
+ value: number;
157
+ }
158
+ /**
159
+ * Represents the calculated positions and paths for a link in the Sankey diagram
160
+ */
161
+ export interface SankeyLayoutLink extends D3SankeyLink<SankeyLayoutNode, Omit<MakeRequired<SankeyLink, 'color'>, 'source' | 'target'>> {
162
+ path?: string | null;
163
+ source: SankeyLayoutNode;
164
+ target: SankeyLayoutNode;
165
+ }
166
+ /**
167
+ * Calculated layout for the Sankey diagram
168
+ */
169
+ export interface SankeyLayout {
170
+ nodes: readonly SankeyLayoutNode[];
171
+ links: readonly SankeyLayoutLink[];
172
+ }
173
+ export interface DefaultizedSankeySeriesType extends DefaultizedProps<Omit<SankeySeriesType, 'data'>, 'id'> {
174
+ data: {
175
+ nodes: Map<SankeyNodeId, SankeyNode>;
176
+ links: readonly SankeyLink[];
177
+ };
178
+ highlightScope?: HighlightScope;
179
+ }
180
+ type SankeyNodeIdentifierBase = {
181
+ type: 'sankey';
182
+ /**
183
+ * Unique identifier for the series
184
+ */
185
+ seriesId: SeriesId;
186
+ };
187
+ export type SankeyNodeIdentifier = SankeyNodeIdentifierBase & {
188
+ /**
189
+ * Subtype to differentiate between node and link
190
+ */
191
+ subType: 'node';
192
+ /**
193
+ * The id of the node
194
+ */
195
+ nodeId: SankeyNodeId;
196
+ };
197
+ export type SankeyNodeIdentifierWithData = SankeyNodeIdentifier & {
198
+ /**
199
+ * The node object with all the calculated properties
200
+ */
201
+ node: SankeyLayoutNode;
202
+ };
203
+ export type SankeyLinkIdentifier = SankeyNodeIdentifierBase & {
204
+ /**
205
+ * Subtype to differentiate between node and link
206
+ */
207
+ subType: 'link';
208
+ /**
209
+ * The id of the source node
210
+ */
211
+ sourceId: SankeyNodeId;
212
+ /**
213
+ * The id of the target node
214
+ */
215
+ targetId: SankeyNodeId;
216
+ };
217
+ export type SankeyLinkIdentifierWithData = SankeyLinkIdentifier & {
218
+ /**
219
+ * The link object with all the calculated properties
220
+ */
221
+ link: SankeyLayoutLink;
222
+ };
223
+ export type SankeyItemIdentifier = SankeyNodeIdentifier | SankeyLinkIdentifier;
224
+ export type SankeyItemIdentifierWithData = SankeyNodeIdentifierWithData | SankeyLinkIdentifierWithData;
225
+ export {};
@@ -0,0 +1,3 @@
1
+ 'use client';
2
+
3
+ export {};
@@ -0,0 +1,15 @@
1
+ export interface SankeyPlotClasses {
2
+ /** Styles applied to the root element. */
3
+ root: string;
4
+ /** Styles applied to the nodes container. */
5
+ nodes: string;
6
+ /** Styles applied to the links container. */
7
+ links: string;
8
+ /** Styles applied to the link label container. */
9
+ linkLabels: string;
10
+ }
11
+ export declare function getSankeyPlotUtilityClass(slot: string): string;
12
+ export declare const sankeyPlotClasses: SankeyPlotClasses;
13
+ export declare const useUtilityClasses: (ownerState: {
14
+ classes?: Partial<SankeyPlotClasses>;
15
+ }) => Record<"root" | "nodes" | "links" | "linkLabels", string>;
@@ -0,0 +1,19 @@
1
+ import composeClasses from '@mui/utils/composeClasses';
2
+ import generateUtilityClass from '@mui/utils/generateUtilityClass';
3
+ import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
4
+ export function getSankeyPlotUtilityClass(slot) {
5
+ return generateUtilityClass('MuiSankeyChart', slot);
6
+ }
7
+ export const sankeyPlotClasses = generateUtilityClasses('MuiSankeyChart', ['root', 'nodes', 'links', 'linkLabels']);
8
+ export const useUtilityClasses = ownerState => {
9
+ const {
10
+ classes
11
+ } = ownerState;
12
+ const slots = {
13
+ root: ['root'],
14
+ nodes: ['nodes'],
15
+ links: ['links'],
16
+ linkLabels: ['linkLabels']
17
+ };
18
+ return composeClasses(slots, getSankeyPlotUtilityClass, classes);
19
+ };
@@ -0,0 +1,24 @@
1
+ import { ChartsOverlaySlotProps, ChartsOverlaySlots } from '@mui/x-charts/ChartsOverlay';
2
+ import { ChartsTooltipProps, ChartsTooltipSlotProps, ChartsTooltipSlots } from '@mui/x-charts/ChartsTooltip';
3
+ import { ChartsSlotProps, ChartsSlots } from '@mui/x-charts/internals';
4
+ import { ChartsToolbarSlotProps, ChartsToolbarSlots } from '@mui/x-charts/Toolbar';
5
+ export interface SankeyChartSlots extends ChartsTooltipSlots, ChartsOverlaySlots, ChartsToolbarSlots, Partial<ChartsSlots> {}
6
+ export interface SankeyChartSlotProps extends Omit<ChartsTooltipSlotProps, 'tooltip'>, ChartsOverlaySlotProps, ChartsToolbarSlotProps, Partial<ChartsSlotProps> {
7
+ /**
8
+ * Slot props for the tooltip component.
9
+ * @default {}
10
+ */
11
+ tooltip?: Partial<ChartsTooltipProps<'item' | 'none'>>;
12
+ }
13
+ export interface SankeyChartSlotExtension {
14
+ /**
15
+ * Overridable component slots.
16
+ * @default {}
17
+ */
18
+ slots?: SankeyChartSlots;
19
+ /**
20
+ * The props used for each component slot.
21
+ * @default {}
22
+ */
23
+ slotProps?: SankeyChartSlotProps;
24
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { GetSeriesWithDefaultValues } from '@mui/x-charts/internals';
2
+ export declare const getSeriesWithDefaultValues: GetSeriesWithDefaultValues<'sankey'>;
@@ -0,0 +1,47 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ export const getSeriesWithDefaultValues = (seriesData, seriesIndex, colors) => {
3
+ const nodeMap = new Map();
4
+ const nodeColor = seriesData.nodeOptions?.color;
5
+ const data = seriesData.data;
6
+ let colorIndex = -1;
7
+ if (data.nodes) {
8
+ data.nodes.forEach(node => {
9
+ const id = node.id || node.label || '';
10
+ const label = node.label || `${id}`;
11
+ colorIndex += 1;
12
+ nodeMap.set(id, _extends({}, node, {
13
+ id,
14
+ label,
15
+ color: node.color ?? nodeColor ?? colors?.[colorIndex % colors.length]
16
+ }));
17
+ });
18
+ }
19
+ data.links.forEach(v => {
20
+ if (!nodeMap.has(v.source)) {
21
+ colorIndex += 1;
22
+ const source = {
23
+ id: v.source,
24
+ label: `${v.source}`,
25
+ color: nodeColor ?? colors?.[colorIndex % colors.length]
26
+ };
27
+ nodeMap.set(source.id, source);
28
+ }
29
+ if (!nodeMap.has(v.target)) {
30
+ colorIndex += 1;
31
+ const target = {
32
+ id: v.target,
33
+ label: `${v.target}`,
34
+ color: nodeColor ?? colors?.[colorIndex % colors.length]
35
+ };
36
+ nodeMap.set(target.id, target);
37
+ }
38
+ });
39
+ return _extends({
40
+ id: seriesData.id ?? `auto-generated-id-${seriesIndex}`
41
+ }, seriesData, {
42
+ data: {
43
+ links: data.links,
44
+ nodes: nodeMap
45
+ }
46
+ });
47
+ };
@@ -0,0 +1,2 @@
1
+ import type { ChartSeriesTypeConfig } from '@mui/x-charts/internals';
2
+ export declare const seriesConfig: ChartSeriesTypeConfig<'sankey'>;
@@ -0,0 +1,14 @@
1
+ import { getSeriesWithDefaultValues } from "./getSeriesWithDefaultValues.js";
2
+ import { tooltipGetter } from "./tooltipGetter.js";
3
+
4
+ // Simple passthrough functions for sankey chart
5
+ const seriesProcessor = series => series;
6
+ const colorProcessor = series => series;
7
+ const legendGetter = () => [];
8
+ export const seriesConfig = {
9
+ seriesProcessor,
10
+ colorProcessor,
11
+ legendGetter,
12
+ tooltipGetter,
13
+ getSeriesWithDefaultValues
14
+ };
@@ -0,0 +1,2 @@
1
+ import type { TooltipGetter } from '@mui/x-charts/internals';
2
+ export declare const tooltipGetter: TooltipGetter<'sankey'>;
@@ -0,0 +1,39 @@
1
+ export const tooltipGetter = params => {
2
+ const {
3
+ identifier
4
+ } = params;
5
+ if (!identifier) {
6
+ return null;
7
+ }
8
+ const {
9
+ subType
10
+ } = identifier;
11
+ if (subType === 'node') {
12
+ const node = identifier.node;
13
+ return {
14
+ identifier,
15
+ color: node.color,
16
+ label: `${node.label}:`,
17
+ value: node.value,
18
+ formattedValue: `${node.value}`,
19
+ markType: 'square'
20
+ };
21
+ }
22
+ if (subType === 'link') {
23
+ const link = identifier.link;
24
+ if (!link) {
25
+ return null;
26
+ }
27
+ const sourceLabel = link.source.label;
28
+ const targetLabel = link.target.label;
29
+ return {
30
+ identifier,
31
+ color: link.color,
32
+ label: `${sourceLabel} → ${targetLabel}:`,
33
+ value: link.value,
34
+ formattedValue: `${link.value}`,
35
+ markType: 'line'
36
+ };
37
+ }
38
+ return null;
39
+ };
@@ -0,0 +1,22 @@
1
+ import type { ChartsOverlayProps } from '@mui/x-charts/ChartsOverlay';
2
+ import type { ChartsWrapperProps } from '@mui/x-charts/ChartsWrapper';
3
+ import type { SankeyChartProps } from "./SankeyChart.js";
4
+ import type { ChartContainerProProps } from "../ChartContainerPro/index.js";
5
+ import { type SankeyChartPluginsSignatures } from "./SankeyChart.plugins.js";
6
+ /**
7
+ * A helper function that extracts SankeyChartProps from the input props
8
+ * and returns an object with props for the children components of SankeyChart.
9
+ *
10
+ * @param props The input props for SankeyChart
11
+ * @returns An object with props for the children components of SankeyChart
12
+ */
13
+ export declare const useSankeyChartProps: (props: SankeyChartProps) => {
14
+ chartContainerProps: ChartContainerProProps<"sankey", SankeyChartPluginsSignatures>;
15
+ sankeyPlotProps: {
16
+ onNodeClick: ((event: React.MouseEvent<SVGElement, MouseEvent>, node: import("./sankey.types.js").SankeyNodeIdentifierWithData) => void) | undefined;
17
+ onLinkClick: ((event: React.MouseEvent<SVGElement, MouseEvent>, link: import("./sankey.types.js").SankeyLinkIdentifierWithData) => void) | undefined;
18
+ };
19
+ overlayProps: ChartsOverlayProps;
20
+ chartsWrapperProps: Omit<ChartsWrapperProps, "children">;
21
+ children: import("react").ReactNode;
22
+ };
@@ -0,0 +1,70 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["series", "width", "height", "margin", "colors", "sx", "children", "slots", "slotProps", "loading", "className", "apiRef", "onNodeClick", "onLinkClick"];
4
+ import { DEFAULT_MARGINS } from '@mui/x-charts/constants';
5
+ import { defaultizeMargin } from '@mui/x-charts/internals';
6
+ import { SANKEY_CHART_PLUGINS } from "./SankeyChart.plugins.js";
7
+
8
+ /**
9
+ * A helper function that extracts SankeyChartProps from the input props
10
+ * and returns an object with props for the children components of SankeyChart.
11
+ *
12
+ * @param props The input props for SankeyChart
13
+ * @returns An object with props for the children components of SankeyChart
14
+ */
15
+ export const useSankeyChartProps = props => {
16
+ const {
17
+ series,
18
+ width,
19
+ height,
20
+ margin: marginProps,
21
+ colors,
22
+ sx,
23
+ children,
24
+ slots,
25
+ slotProps,
26
+ loading,
27
+ // highlightedItem,
28
+ // onHighlightChange,
29
+ className,
30
+ apiRef,
31
+ onNodeClick,
32
+ onLinkClick
33
+ } = props,
34
+ rest = _objectWithoutPropertiesLoose(props, _excluded);
35
+ const margin = defaultizeMargin(marginProps, DEFAULT_MARGINS);
36
+ const chartContainerProps = _extends({}, rest, {
37
+ series: [_extends({
38
+ type: 'sankey'
39
+ }, series)],
40
+ width,
41
+ height,
42
+ margin,
43
+ colors,
44
+ sx,
45
+ // highlightedItem,
46
+ // onHighlightChange,
47
+ className,
48
+ apiRef,
49
+ plugins: SANKEY_CHART_PLUGINS
50
+ });
51
+ const sankeyPlotProps = {
52
+ onNodeClick,
53
+ onLinkClick
54
+ };
55
+ const overlayProps = {
56
+ slots,
57
+ slotProps,
58
+ loading
59
+ };
60
+ const chartsWrapperProps = {
61
+ sx
62
+ };
63
+ return {
64
+ chartContainerProps,
65
+ sankeyPlotProps,
66
+ overlayProps,
67
+ chartsWrapperProps,
68
+ children
69
+ };
70
+ };
@@ -0,0 +1,3 @@
1
+ import { sankeyLeft } from '@mui/x-charts-vendor/d3-sankey';
2
+ import type { SankeyNodeOptions } from "./sankey.types.js";
3
+ export declare const getNodeAlignFunction: (align: SankeyNodeOptions["align"]) => typeof sankeyLeft;
@@ -0,0 +1,14 @@
1
+ import { sankeyLeft, sankeyRight, sankeyCenter, sankeyJustify } from '@mui/x-charts-vendor/d3-sankey';
2
+ export const getNodeAlignFunction = align => {
3
+ switch (align) {
4
+ case 'left':
5
+ return sankeyLeft;
6
+ case 'right':
7
+ return sankeyRight;
8
+ case 'center':
9
+ return sankeyCenter;
10
+ case 'justify':
11
+ default:
12
+ return sankeyJustify;
13
+ }
14
+ };