@mui/x-charts-pro 8.0.0-alpha.13 → 8.0.0-alpha.14

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 (162) hide show
  1. package/BarChartPro/BarChartPro.d.ts +2 -1
  2. package/CHANGELOG.md +131 -0
  3. package/ChartContainerPro/useChartContainerProProps.d.ts +1 -1
  4. package/ChartDataProviderPro/useChartDataProviderProProps.d.ts +1 -1
  5. package/FunnelChart/FunnelChart.d.ts +37 -0
  6. package/FunnelChart/FunnelChart.js +218 -0
  7. package/FunnelChart/FunnelPlot.d.ts +16 -0
  8. package/FunnelChart/FunnelPlot.js +191 -0
  9. package/FunnelChart/FunnelSection.d.ts +15 -0
  10. package/FunnelChart/FunnelSection.js +62 -0
  11. package/FunnelChart/categoryAxis.types.d.ts +24 -0
  12. package/FunnelChart/categoryAxis.types.js +5 -0
  13. package/FunnelChart/funnel.types.d.ts +124 -0
  14. package/FunnelChart/funnel.types.js +5 -0
  15. package/FunnelChart/funnelPlotSlots.types.d.ts +20 -0
  16. package/FunnelChart/funnelPlotSlots.types.js +5 -0
  17. package/FunnelChart/funnelSectionClasses.d.ts +13 -0
  18. package/FunnelChart/funnelSectionClasses.js +28 -0
  19. package/FunnelChart/funnelSlots.types.d.ts +19 -0
  20. package/FunnelChart/funnelSlots.types.js +5 -0
  21. package/FunnelChart/funnelStepCurve.d.ts +4 -0
  22. package/FunnelChart/funnelStepCurve.js +74 -0
  23. package/FunnelChart/index.d.ts +7 -0
  24. package/FunnelChart/index.js +59 -0
  25. package/FunnelChart/labelUtils.d.ts +42 -0
  26. package/FunnelChart/labelUtils.js +174 -0
  27. package/FunnelChart/seriesConfig/extremums.d.ts +3 -0
  28. package/FunnelChart/seriesConfig/extremums.js +50 -0
  29. package/FunnelChart/seriesConfig/getColor.d.ts +3 -0
  30. package/FunnelChart/seriesConfig/getColor.js +10 -0
  31. package/FunnelChart/seriesConfig/getSeriesWithDefaultValues.d.ts +3 -0
  32. package/FunnelChart/seriesConfig/getSeriesWithDefaultValues.js +18 -0
  33. package/FunnelChart/seriesConfig/index.d.ts +2 -0
  34. package/FunnelChart/seriesConfig/index.js +22 -0
  35. package/FunnelChart/seriesConfig/legend.d.ts +3 -0
  36. package/FunnelChart/seriesConfig/legend.js +31 -0
  37. package/FunnelChart/seriesConfig/seriesProcessor.d.ts +3 -0
  38. package/FunnelChart/seriesConfig/seriesProcessor.js +96 -0
  39. package/FunnelChart/seriesConfig/tooltip.d.ts +3 -0
  40. package/FunnelChart/seriesConfig/tooltip.js +36 -0
  41. package/FunnelChart/useFunnelChartProps.d.ts +30 -0
  42. package/FunnelChart/useFunnelChartProps.js +168 -0
  43. package/Heatmap/seriesConfig/getSeriesWithDefaultValues.d.ts +3 -0
  44. package/Heatmap/seriesConfig/getSeriesWithDefaultValues.js +15 -0
  45. package/Heatmap/seriesConfig/index.js +3 -1
  46. package/LineChartPro/LineChartPro.d.ts +2 -1
  47. package/esm/BarChartPro/BarChartPro.d.ts +2 -1
  48. package/esm/ChartContainerPro/useChartContainerProProps.d.ts +1 -1
  49. package/esm/ChartDataProviderPro/useChartDataProviderProProps.d.ts +1 -1
  50. package/esm/FunnelChart/FunnelChart.d.ts +37 -0
  51. package/esm/FunnelChart/FunnelChart.js +212 -0
  52. package/esm/FunnelChart/FunnelPlot.d.ts +16 -0
  53. package/esm/FunnelChart/FunnelPlot.js +184 -0
  54. package/esm/FunnelChart/FunnelSection.d.ts +15 -0
  55. package/esm/FunnelChart/FunnelSection.js +56 -0
  56. package/esm/FunnelChart/categoryAxis.types.d.ts +24 -0
  57. package/esm/FunnelChart/categoryAxis.types.js +1 -0
  58. package/esm/FunnelChart/funnel.types.d.ts +124 -0
  59. package/esm/FunnelChart/funnel.types.js +1 -0
  60. package/esm/FunnelChart/funnelPlotSlots.types.d.ts +20 -0
  61. package/esm/FunnelChart/funnelPlotSlots.types.js +1 -0
  62. package/esm/FunnelChart/funnelSectionClasses.d.ts +13 -0
  63. package/esm/FunnelChart/funnelSectionClasses.js +20 -0
  64. package/esm/FunnelChart/funnelSlots.types.d.ts +19 -0
  65. package/esm/FunnelChart/funnelSlots.types.js +1 -0
  66. package/esm/FunnelChart/funnelStepCurve.d.ts +4 -0
  67. package/esm/FunnelChart/funnelStepCurve.js +67 -0
  68. package/esm/FunnelChart/index.d.ts +7 -0
  69. package/esm/FunnelChart/index.js +5 -0
  70. package/esm/FunnelChart/labelUtils.d.ts +42 -0
  71. package/esm/FunnelChart/labelUtils.js +166 -0
  72. package/esm/FunnelChart/seriesConfig/extremums.d.ts +3 -0
  73. package/esm/FunnelChart/seriesConfig/extremums.js +42 -0
  74. package/esm/FunnelChart/seriesConfig/getColor.d.ts +3 -0
  75. package/esm/FunnelChart/seriesConfig/getColor.js +4 -0
  76. package/esm/FunnelChart/seriesConfig/getSeriesWithDefaultValues.d.ts +3 -0
  77. package/esm/FunnelChart/seriesConfig/getSeriesWithDefaultValues.js +11 -0
  78. package/esm/FunnelChart/seriesConfig/index.d.ts +2 -0
  79. package/esm/FunnelChart/seriesConfig/index.js +15 -0
  80. package/esm/FunnelChart/seriesConfig/legend.d.ts +3 -0
  81. package/esm/FunnelChart/seriesConfig/legend.js +25 -0
  82. package/esm/FunnelChart/seriesConfig/seriesProcessor.d.ts +3 -0
  83. package/esm/FunnelChart/seriesConfig/seriesProcessor.js +89 -0
  84. package/esm/FunnelChart/seriesConfig/tooltip.d.ts +3 -0
  85. package/esm/FunnelChart/seriesConfig/tooltip.js +29 -0
  86. package/esm/FunnelChart/useFunnelChartProps.d.ts +30 -0
  87. package/esm/FunnelChart/useFunnelChartProps.js +161 -0
  88. package/esm/Heatmap/seriesConfig/getSeriesWithDefaultValues.d.ts +3 -0
  89. package/esm/Heatmap/seriesConfig/getSeriesWithDefaultValues.js +8 -0
  90. package/esm/Heatmap/seriesConfig/index.js +3 -1
  91. package/esm/LineChartPro/LineChartPro.d.ts +2 -1
  92. package/esm/hooks/useFunnelSeries.d.ts +33 -0
  93. package/esm/hooks/useFunnelSeries.js +42 -0
  94. package/esm/index.d.ts +3 -1
  95. package/esm/index.js +4 -2
  96. package/esm/internals/plugins/allPlugins.d.ts +3 -3
  97. package/esm/internals/plugins/allPlugins.js +2 -2
  98. package/esm/internals/utils/releaseInfo.js +1 -1
  99. package/esm/typeOverloads/modules.d.ts +13 -2
  100. package/hooks/useFunnelSeries.d.ts +33 -0
  101. package/hooks/useFunnelSeries.js +48 -0
  102. package/index.d.ts +3 -1
  103. package/index.js +23 -1
  104. package/internals/plugins/allPlugins.d.ts +3 -3
  105. package/internals/plugins/allPlugins.js +1 -1
  106. package/internals/utils/releaseInfo.js +1 -1
  107. package/modern/BarChartPro/BarChartPro.d.ts +2 -1
  108. package/modern/ChartContainerPro/useChartContainerProProps.d.ts +1 -1
  109. package/modern/ChartDataProviderPro/useChartDataProviderProProps.d.ts +1 -1
  110. package/modern/FunnelChart/FunnelChart.d.ts +37 -0
  111. package/modern/FunnelChart/FunnelChart.js +212 -0
  112. package/modern/FunnelChart/FunnelPlot.d.ts +16 -0
  113. package/modern/FunnelChart/FunnelPlot.js +184 -0
  114. package/modern/FunnelChart/FunnelSection.d.ts +15 -0
  115. package/modern/FunnelChart/FunnelSection.js +56 -0
  116. package/modern/FunnelChart/categoryAxis.types.d.ts +24 -0
  117. package/modern/FunnelChart/categoryAxis.types.js +1 -0
  118. package/modern/FunnelChart/funnel.types.d.ts +124 -0
  119. package/modern/FunnelChart/funnel.types.js +1 -0
  120. package/modern/FunnelChart/funnelPlotSlots.types.d.ts +20 -0
  121. package/modern/FunnelChart/funnelPlotSlots.types.js +1 -0
  122. package/modern/FunnelChart/funnelSectionClasses.d.ts +13 -0
  123. package/modern/FunnelChart/funnelSectionClasses.js +20 -0
  124. package/modern/FunnelChart/funnelSlots.types.d.ts +19 -0
  125. package/modern/FunnelChart/funnelSlots.types.js +1 -0
  126. package/modern/FunnelChart/funnelStepCurve.d.ts +4 -0
  127. package/modern/FunnelChart/funnelStepCurve.js +67 -0
  128. package/modern/FunnelChart/index.d.ts +7 -0
  129. package/modern/FunnelChart/index.js +5 -0
  130. package/modern/FunnelChart/labelUtils.d.ts +42 -0
  131. package/modern/FunnelChart/labelUtils.js +166 -0
  132. package/modern/FunnelChart/seriesConfig/extremums.d.ts +3 -0
  133. package/modern/FunnelChart/seriesConfig/extremums.js +42 -0
  134. package/modern/FunnelChart/seriesConfig/getColor.d.ts +3 -0
  135. package/modern/FunnelChart/seriesConfig/getColor.js +4 -0
  136. package/modern/FunnelChart/seriesConfig/getSeriesWithDefaultValues.d.ts +3 -0
  137. package/modern/FunnelChart/seriesConfig/getSeriesWithDefaultValues.js +11 -0
  138. package/modern/FunnelChart/seriesConfig/index.d.ts +2 -0
  139. package/modern/FunnelChart/seriesConfig/index.js +15 -0
  140. package/modern/FunnelChart/seriesConfig/legend.d.ts +3 -0
  141. package/modern/FunnelChart/seriesConfig/legend.js +25 -0
  142. package/modern/FunnelChart/seriesConfig/seriesProcessor.d.ts +3 -0
  143. package/modern/FunnelChart/seriesConfig/seriesProcessor.js +89 -0
  144. package/modern/FunnelChart/seriesConfig/tooltip.d.ts +3 -0
  145. package/modern/FunnelChart/seriesConfig/tooltip.js +29 -0
  146. package/modern/FunnelChart/useFunnelChartProps.d.ts +30 -0
  147. package/modern/FunnelChart/useFunnelChartProps.js +161 -0
  148. package/modern/Heatmap/seriesConfig/getSeriesWithDefaultValues.d.ts +3 -0
  149. package/modern/Heatmap/seriesConfig/getSeriesWithDefaultValues.js +8 -0
  150. package/modern/Heatmap/seriesConfig/index.js +3 -1
  151. package/modern/LineChartPro/LineChartPro.d.ts +2 -1
  152. package/modern/hooks/useFunnelSeries.d.ts +33 -0
  153. package/modern/hooks/useFunnelSeries.js +42 -0
  154. package/modern/index.d.ts +3 -1
  155. package/modern/index.js +4 -2
  156. package/modern/internals/plugins/allPlugins.d.ts +3 -3
  157. package/modern/internals/plugins/allPlugins.js +2 -2
  158. package/modern/internals/utils/releaseInfo.js +1 -1
  159. package/modern/typeOverloads/modules.d.ts +13 -2
  160. package/package.json +4 -4
  161. package/tsconfig.build.tsbuildinfo +1 -1
  162. package/typeOverloads/modules.d.ts +13 -2
@@ -0,0 +1,174 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.positionLabel = exports.alignLabel = void 0;
7
+ /**
8
+ * It tries to keep the label inside the bounds of the section based on the position.
9
+ *
10
+ * @returns The text anchor and dominant baseline of the label.
11
+ */
12
+ const alignLabel = ({
13
+ position,
14
+ textAnchor,
15
+ dominantBaseline
16
+ }) => {
17
+ const vertical = position?.vertical ?? 'middle';
18
+ const horizontal = position?.horizontal ?? 'center';
19
+ let anchor = 'middle';
20
+ let baseline = 'central';
21
+ if (vertical === 'top') {
22
+ baseline = 'hanging';
23
+ } else if (vertical === 'bottom') {
24
+ baseline = 'baseline';
25
+ }
26
+ if (horizontal === 'start') {
27
+ anchor = 'start';
28
+ } else if (horizontal === 'end') {
29
+ anchor = 'end';
30
+ }
31
+ return {
32
+ textAnchor: textAnchor ?? anchor,
33
+ dominantBaseline: dominantBaseline ?? baseline
34
+ };
35
+ };
36
+
37
+ /**
38
+ * This function calculates the position of the label based on the position and margin.
39
+ *
40
+ * It is quite complex, because it needs to calculate the position based on the position of the points of a rectangle.
41
+ * And we are manually calculating each possible position of the label.
42
+ *
43
+ * @returns The x and y position of the label.
44
+ */
45
+ exports.alignLabel = alignLabel;
46
+ const positionLabel = ({
47
+ position,
48
+ offset,
49
+ xPosition,
50
+ yPosition,
51
+ isHorizontal,
52
+ values,
53
+ dataIndex,
54
+ baseScaleData
55
+ }) => {
56
+ const vertical = position?.vertical ?? 'middle';
57
+ const horizontal = position?.horizontal ?? 'center';
58
+ let x = 0;
59
+ let y = 0;
60
+ let minTop = 0;
61
+ let maxTop = 0;
62
+ let minBottom = 0;
63
+ let maxBottom = 0;
64
+ let minLeft = 0;
65
+ let maxLeft = 0;
66
+ let minRight = 0;
67
+ let maxRight = 0;
68
+ let center = 0;
69
+ let leftCenter = 0;
70
+ let rightCenter = 0;
71
+ let middle = 0;
72
+ let topMiddle = 0;
73
+ let bottomMiddle = 0;
74
+ const mv = typeof offset === 'number' ? offset : offset?.y ?? 0;
75
+ const mh = typeof offset === 'number' ? offset : offset?.x ?? 0;
76
+ const stackOffset = values[0].stackOffset;
77
+ if (isHorizontal) {
78
+ maxTop = yPosition(values[0].y, baseScaleData[dataIndex], stackOffset) - mv;
79
+ minTop = yPosition(values[1].y, baseScaleData[dataIndex], stackOffset) - mv;
80
+ minBottom = yPosition(values[2].y, baseScaleData[dataIndex], stackOffset) + mv;
81
+ maxBottom = yPosition(values[3].y, baseScaleData[dataIndex], stackOffset) + mv;
82
+ minRight = 0;
83
+ maxRight = xPosition(Math.min(...values.map(v => v.x)), baseScaleData[dataIndex], stackOffset, true) + mh;
84
+ minLeft = 0;
85
+ maxLeft = xPosition(Math.max(...values.map(v => v.x)), baseScaleData[dataIndex], stackOffset) + mh;
86
+ center = maxRight - (maxRight - maxLeft) / 2;
87
+ leftCenter = 0;
88
+ rightCenter = 0;
89
+ middle = yPosition(0, baseScaleData[dataIndex], stackOffset) - mv;
90
+ topMiddle = yPosition(values[0].y - (values[0].y - values[1].y) / 2, baseScaleData[dataIndex], stackOffset) - mv;
91
+ bottomMiddle = yPosition(values[3].y - (values[3].y - values[2].y) / 2, baseScaleData[dataIndex], stackOffset) + mv;
92
+ } else {
93
+ minTop = 0;
94
+ maxTop = yPosition(Math.max(...values.map(v => v.y)), baseScaleData[dataIndex], stackOffset) - mv;
95
+ minBottom = 0;
96
+ maxBottom = yPosition(Math.min(...values.map(v => v.y)), baseScaleData[dataIndex], stackOffset, true) - mv;
97
+ maxRight = xPosition(values[0].x, baseScaleData[dataIndex], stackOffset) + mh;
98
+ minRight = xPosition(values[1].x, baseScaleData[dataIndex], stackOffset) + mh;
99
+ minLeft = xPosition(values[2].x, baseScaleData[dataIndex], stackOffset) - mh;
100
+ maxLeft = xPosition(values[3].x, baseScaleData[dataIndex], stackOffset) - mh;
101
+ center = xPosition(0, baseScaleData[dataIndex], stackOffset) - mh;
102
+ rightCenter = xPosition(values[0].x - (values[0].x - values[1].x) / 2, baseScaleData[dataIndex], stackOffset) + mh;
103
+ leftCenter = xPosition(values[3].x - (values[3].x - values[2].x) / 2, baseScaleData[dataIndex], stackOffset) - mh;
104
+ middle = yPosition(values[0].y - (values[0].y - values[1].y) / 2, baseScaleData[dataIndex], stackOffset);
105
+ middle = maxTop - (maxTop - maxBottom) / 2;
106
+ topMiddle = 0;
107
+ bottomMiddle = 0;
108
+ }
109
+ if (isHorizontal) {
110
+ if (horizontal === 'center') {
111
+ x = center;
112
+ if (vertical === 'top') {
113
+ y = topMiddle;
114
+ } else if (vertical === 'middle') {
115
+ y = middle;
116
+ } else if (vertical === 'bottom') {
117
+ y = bottomMiddle;
118
+ }
119
+ } else if (horizontal === 'start') {
120
+ x = maxLeft;
121
+ if (vertical === 'top') {
122
+ y = maxTop;
123
+ } else if (vertical === 'middle') {
124
+ y = middle;
125
+ } else if (vertical === 'bottom') {
126
+ y = maxBottom;
127
+ }
128
+ } else if (horizontal === 'end') {
129
+ x = maxRight;
130
+ if (vertical === 'top') {
131
+ y = minTop;
132
+ } else if (vertical === 'middle') {
133
+ y = middle;
134
+ } else if (vertical === 'bottom') {
135
+ y = minBottom;
136
+ }
137
+ }
138
+ }
139
+ if (!isHorizontal) {
140
+ if (vertical === 'middle') {
141
+ y = middle;
142
+ if (horizontal === 'start') {
143
+ x = leftCenter;
144
+ } else if (horizontal === 'center') {
145
+ x = center;
146
+ } else if (horizontal === 'end') {
147
+ x = rightCenter;
148
+ }
149
+ } else if (vertical === 'top') {
150
+ y = maxTop;
151
+ if (horizontal === 'start') {
152
+ x = maxLeft;
153
+ } else if (horizontal === 'center') {
154
+ x = center;
155
+ } else if (horizontal === 'end') {
156
+ x = maxRight;
157
+ }
158
+ } else if (vertical === 'bottom') {
159
+ y = maxBottom;
160
+ if (horizontal === 'start') {
161
+ x = minLeft;
162
+ } else if (horizontal === 'center') {
163
+ x = center;
164
+ } else if (horizontal === 'end') {
165
+ x = minRight;
166
+ }
167
+ }
168
+ }
169
+ return {
170
+ x,
171
+ y
172
+ };
173
+ };
174
+ exports.positionLabel = positionLabel;
@@ -0,0 +1,3 @@
1
+ import { CartesianExtremumGetter } from '@mui/x-charts/internals';
2
+ export declare const getExtremumX: CartesianExtremumGetter<'funnel'>;
3
+ export declare const getExtremumY: CartesianExtremumGetter<'funnel'>;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getExtremumY = exports.getExtremumX = void 0;
7
+ const getValueExtremum = (direction, isHorizontal, params) => {
8
+ const {
9
+ series,
10
+ axis,
11
+ isDefaultAxis
12
+ } = params;
13
+ return Object.keys(series)
14
+ // Keep only series that are associated with the current axis
15
+ .reduce((acc, seriesId) => {
16
+ const yAxisId = series[seriesId].yAxisId;
17
+ const xAxisId = series[seriesId].xAxisId;
18
+ const {
19
+ dataPoints
20
+ } = series[seriesId];
21
+ if (
22
+ // We skip except if the axis id is not defined for the direction and we are on the default one.
23
+ !(isDefaultAxis && yAxisId === undefined && direction === 'y') && !(isDefaultAxis && xAxisId === undefined && direction === 'x')) {
24
+ return acc;
25
+ }
26
+ if (axis.scaleType === 'band' || !isHorizontal && direction === 'x' || isHorizontal && direction === 'y') {
27
+ const [seriesMin, seriesMax] = dataPoints.map(v => v.map(t => t[direction]))?.reduce((seriesAcc, values) => {
28
+ return [Math.min(...values, seriesAcc[0]), Math.max(...values, seriesAcc[1])];
29
+ }, [Infinity, -Infinity]) ?? [Infinity, -Infinity];
30
+ return [Math.min(seriesMin, acc[0]), Math.max(seriesMax, acc[1])];
31
+ }
32
+ const seriesMin = dataPoints.flatMap(v => v.map(t => t[direction]).reduce((min, value) => Math.min(value, min), Infinity)).reduce((sumAcc, value) => sumAcc + value, 0);
33
+ const seriesMax = dataPoints.flatMap(v => v.map(t => t[direction]).reduce((max, value) => Math.max(value, max), -Infinity)).reduce((sumAcc, value) => sumAcc + value, 0);
34
+ return [Math.min(seriesMin, acc[0]), Math.max(seriesMax, acc[1])];
35
+ }, [Infinity, -Infinity]);
36
+ };
37
+ const getExtremumX = params => {
38
+ const isHorizontal = Object.keys(params.series).some(seriesId => params.series[seriesId].layout === 'horizontal');
39
+ if (isHorizontal) {
40
+ const [min, max] = getValueExtremum('x', isHorizontal, params);
41
+ return [max, min];
42
+ }
43
+ return getValueExtremum('x', isHorizontal, params);
44
+ };
45
+ exports.getExtremumX = getExtremumX;
46
+ const getExtremumY = params => {
47
+ const isHorizontal = Object.keys(params.series).some(seriesId => params.series[seriesId].layout === 'horizontal');
48
+ return getValueExtremum('y', isHorizontal, params);
49
+ };
50
+ exports.getExtremumY = getExtremumY;
@@ -0,0 +1,3 @@
1
+ import { ColorProcessor } from '@mui/x-charts/internals';
2
+ declare const getColor: ColorProcessor<'funnel'>;
3
+ export default getColor;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ const getColor = series => {
8
+ return dataIndex => series.data[dataIndex].color;
9
+ };
10
+ var _default = exports.default = getColor;
@@ -0,0 +1,3 @@
1
+ import { GetSeriesWithDefaultValues } from '@mui/x-charts/internals';
2
+ declare const getSeriesWithDefaultValues: GetSeriesWithDefaultValues<'funnel'>;
3
+ export default getSeriesWithDefaultValues;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ const getSeriesWithDefaultValues = (seriesData, seriesIndex, colors) => {
10
+ return (0, _extends2.default)({
11
+ id: seriesData.id ?? `auto-generated-id-${seriesIndex}`
12
+ }, seriesData, {
13
+ data: seriesData.data.map((d, index) => (0, _extends2.default)({
14
+ color: colors[index % colors.length]
15
+ }, d))
16
+ });
17
+ };
18
+ var _default = exports.default = getSeriesWithDefaultValues;
@@ -0,0 +1,2 @@
1
+ import type { ChartSeriesTypeConfig } from '@mui/x-charts/internals';
2
+ export declare const seriesConfig: ChartSeriesTypeConfig<'funnel'>;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.seriesConfig = void 0;
8
+ var _extremums = require("./extremums");
9
+ var _seriesProcessor = _interopRequireDefault(require("./seriesProcessor"));
10
+ var _getColor = _interopRequireDefault(require("./getColor"));
11
+ var _legend = _interopRequireDefault(require("./legend"));
12
+ var _tooltip = _interopRequireDefault(require("./tooltip"));
13
+ var _getSeriesWithDefaultValues = _interopRequireDefault(require("./getSeriesWithDefaultValues"));
14
+ const seriesConfig = exports.seriesConfig = {
15
+ seriesProcessor: _seriesProcessor.default,
16
+ colorProcessor: _getColor.default,
17
+ legendGetter: _legend.default,
18
+ tooltipGetter: _tooltip.default,
19
+ xExtremumGetter: _extremums.getExtremumX,
20
+ yExtremumGetter: _extremums.getExtremumY,
21
+ getSeriesWithDefaultValues: _getSeriesWithDefaultValues.default
22
+ };
@@ -0,0 +1,3 @@
1
+ import { LegendGetter } from '@mui/x-charts/internals';
2
+ declare const legendGetter: LegendGetter<'funnel'>;
3
+ export default legendGetter;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _internals = require("@mui/x-charts/internals");
8
+ const legendGetter = params => {
9
+ const {
10
+ seriesOrder,
11
+ series
12
+ } = params;
13
+ return seriesOrder.reduce((acc, seriesId) => {
14
+ series[seriesId].data.forEach(item => {
15
+ const formattedLabel = (0, _internals.getLabel)(item.label, 'legend');
16
+ if (formattedLabel === undefined) {
17
+ return;
18
+ }
19
+ acc.push({
20
+ markType: item.labelMarkType ?? series[seriesId].labelMarkType,
21
+ seriesId,
22
+ id: item.id,
23
+ itemId: item.id,
24
+ color: item.color,
25
+ label: formattedLabel
26
+ });
27
+ });
28
+ return acc;
29
+ }, []);
30
+ };
31
+ var _default = exports.default = legendGetter;
@@ -0,0 +1,3 @@
1
+ import { SeriesProcessor } from '@mui/x-charts/internals';
2
+ declare const seriesProcessor: SeriesProcessor<'funnel'>;
3
+ export default seriesProcessor;
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ const createPoint = ({
10
+ main,
11
+ other,
12
+ inverse,
13
+ useBandWidth,
14
+ stackOffset
15
+ }) => inverse ? {
16
+ x: other,
17
+ y: main,
18
+ useBandWidth,
19
+ stackOffset
20
+ } : {
21
+ x: main,
22
+ y: other,
23
+ useBandWidth,
24
+ stackOffset
25
+ };
26
+ const seriesProcessor = params => {
27
+ const {
28
+ seriesOrder,
29
+ series
30
+ } = params;
31
+ const completedSeries = {};
32
+ const isHorizontal = seriesOrder.some(seriesId => series[seriesId].layout === 'horizontal');
33
+ seriesOrder.forEach(seriesId => {
34
+ const currentSeries = series[seriesId];
35
+ completedSeries[seriesId] = (0, _extends2.default)({
36
+ labelMarkType: 'square',
37
+ layout: isHorizontal ? 'horizontal' : 'vertical',
38
+ valueFormatter: item => item == null ? '' : item.value.toLocaleString()
39
+ }, currentSeries, {
40
+ data: currentSeries.data.map((v, i) => (0, _extends2.default)({
41
+ id: `${seriesId}-funnel-item-${v.id ?? i}`
42
+ }, v)),
43
+ dataPoints: []
44
+ });
45
+ const stackOffsets = completedSeries[seriesId].data.toReversed().map((_, i, array) => array.slice(0, i).reduce((acc, item) => acc + item.value, 0)).toReversed();
46
+ completedSeries[seriesId].dataPoints = completedSeries[seriesId].data.map((item, dataIndex, array) => {
47
+ // Main = main axis, Other = other axis
48
+ // For horizontal layout, main is y, other is x
49
+ // For vertical layout, main is x, other is y
50
+ const currentMaxMain = item.value;
51
+ const nextDataIndex = dataIndex === array.length - 1 ? dataIndex : dataIndex + 1;
52
+ const nextMaxMain = array[nextDataIndex].value ?? 0;
53
+ const nextMaxOther = 0;
54
+ const currentMaxOther = completedSeries[seriesId].data[dataIndex].value;
55
+ const stackOffset = stackOffsets[dataIndex];
56
+ return [
57
+ // Top right (vertical) or Top left (horizontal)
58
+ createPoint({
59
+ main: currentMaxMain,
60
+ other: currentMaxOther,
61
+ inverse: isHorizontal,
62
+ useBandWidth: false,
63
+ stackOffset
64
+ }),
65
+ // Bottom right (vertical) or Top right (horizontal)
66
+ createPoint({
67
+ main: nextMaxMain,
68
+ other: nextMaxOther,
69
+ inverse: isHorizontal,
70
+ useBandWidth: true,
71
+ stackOffset
72
+ }),
73
+ // Bottom left (vertical) or Bottom right (horizontal)
74
+ createPoint({
75
+ main: -nextMaxMain,
76
+ other: nextMaxOther,
77
+ inverse: isHorizontal,
78
+ useBandWidth: true,
79
+ stackOffset
80
+ }),
81
+ // Top left (vertical) or Bottom left (horizontal)
82
+ createPoint({
83
+ main: -currentMaxMain,
84
+ other: currentMaxOther,
85
+ inverse: isHorizontal,
86
+ useBandWidth: false,
87
+ stackOffset
88
+ })];
89
+ });
90
+ });
91
+ return {
92
+ seriesOrder,
93
+ series: completedSeries
94
+ };
95
+ };
96
+ var _default = exports.default = seriesProcessor;
@@ -0,0 +1,3 @@
1
+ import { TooltipGetter } from '@mui/x-charts/internals';
2
+ declare const tooltipGetter: TooltipGetter<'funnel'>;
3
+ export default tooltipGetter;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var _internals = require("@mui/x-charts/internals");
10
+ const tooltipGetter = params => {
11
+ const {
12
+ series,
13
+ getColor,
14
+ identifier
15
+ } = params;
16
+ if (!identifier || identifier.dataIndex === undefined) {
17
+ return null;
18
+ }
19
+ const point = series.data[identifier.dataIndex];
20
+ const label = (0, _internals.getLabel)(point.label, 'tooltip');
21
+ const value = (0, _extends2.default)({}, point, {
22
+ label
23
+ });
24
+ const formattedValue = series.valueFormatter(value, {
25
+ dataIndex: identifier.dataIndex
26
+ });
27
+ return {
28
+ identifier,
29
+ color: getColor(identifier.dataIndex),
30
+ label,
31
+ value,
32
+ formattedValue,
33
+ markType: point.labelMarkType ?? series.labelMarkType
34
+ };
35
+ };
36
+ var _default = exports.default = tooltipGetter;
@@ -0,0 +1,30 @@
1
+ import { ChartsOverlayProps } from '@mui/x-charts/ChartsOverlay';
2
+ import { ChartsAxisProps } from '@mui/x-charts/ChartsAxis';
3
+ import { ChartsLegendSlotExtension } from '@mui/x-charts/ChartsLegend';
4
+ import { ChartsClipPathProps } from '@mui/x-charts/ChartsClipPath';
5
+ import { ChartsWrapperProps } from '@mui/x-charts/internals';
6
+ import { ChartsAxisHighlightProps } from '@mui/x-charts/ChartsAxisHighlight';
7
+ import { FunnelPlotProps } from "./FunnelPlot.js";
8
+ import type { FunnelChartProps } from './FunnelChart';
9
+ import { ChartContainerProProps } from "../ChartContainerPro/index.js";
10
+ /**
11
+ * A helper function that extracts FunnelChartProps from the input props
12
+ * and returns an object with props for the children components of FunnelChart.
13
+ *
14
+ * @param props The input props for FunnelChart
15
+ * @returns An object with props for the children components of FunnelChart
16
+ */
17
+ export declare const useFunnelChartProps: (props: FunnelChartProps) => {
18
+ chartContainerProps: ChartContainerProProps<"funnel">;
19
+ funnelPlotProps: FunnelPlotProps;
20
+ overlayProps: ChartsOverlayProps;
21
+ chartsAxisProps: ChartsAxisProps;
22
+ legendProps: ChartsLegendSlotExtension;
23
+ clipPathGroupProps: {
24
+ clipPath: string;
25
+ };
26
+ clipPathProps: ChartsClipPathProps;
27
+ chartsWrapperProps: Omit<ChartsWrapperProps, "children">;
28
+ axisHighlightProps: ChartsAxisHighlightProps;
29
+ children: import("react").ReactNode;
30
+ };
@@ -0,0 +1,168 @@
1
+ "use strict";
2
+ 'use client';
3
+
4
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.useFunnelChartProps = void 0;
9
+ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
10
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
+ var _constants = require("@mui/x-charts/constants");
12
+ var _useId = _interopRequireDefault(require("@mui/utils/useId"));
13
+ var _internals = require("@mui/x-charts/internals");
14
+ var _warning = require("@mui/x-internals/warning");
15
+ const _excluded = ["categoryAxis", "series", "width", "height", "margin", "colors", "sx", "children", "slots", "slotProps", "skipAnimation", "loading", "onItemClick", "highlightedItem", "onHighlightChange", "className", "hideLegend", "axisHighlight", "apiRef"];
16
+ function getCategoryAxisConfig(categoryAxis, series, isHorizontal, direction) {
17
+ const maxSeriesLength = Math.max(...series.map(s => (s.data ?? []).length), 0);
18
+ const maxSeriesValue = Array.from({
19
+ length: maxSeriesLength
20
+ }, (_, index) => series.reduce((a, s) => a + (s.data?.[index]?.value ?? 0), 0));
21
+ if (process.env.NODE_ENV !== 'production') {
22
+ if ((categoryAxis?.position === 'left' || categoryAxis?.position === 'right') && isHorizontal || (categoryAxis?.position === 'top' || categoryAxis?.position === 'bottom') && !isHorizontal) {
23
+ (0, _warning.warnOnce)([`MUI X: the categoryAxis position is set to '${categoryAxis.position}' but the series layout is ${isHorizontal ? 'horizontal' : 'vertical'}.`, `Ensure that the categoryAxis position is set to '${isHorizontal ? 'top' : 'left'}' or '${isHorizontal ? 'bottom' : 'right'}' for ${isHorizontal ? 'horizontal' : 'vertical'} layout.\n`], 'warning');
24
+ }
25
+ }
26
+ const side = isHorizontal ? 'bottom' : 'left';
27
+ const categoryValues = (0, _extends2.default)({
28
+ id: direction === 'x' ? _constants.DEFAULT_X_AXIS_KEY : _constants.DEFAULT_Y_AXIS_KEY
29
+ }, categoryAxis, categoryAxis?.size ? {
30
+ [isHorizontal ? 'height' : 'width']: categoryAxis.size
31
+ } : {}, {
32
+ position: categoryAxis?.position ?? (categoryAxis?.categories ? side : 'none')
33
+ });
34
+
35
+ // If the scaleType is not defined or is 'band', our job is simple.
36
+ if (!categoryAxis?.scaleType || categoryAxis.scaleType === 'band') {
37
+ return (0, _extends2.default)({
38
+ scaleType: 'band',
39
+ categoryGapRatio: 0,
40
+ // Use the categories as the domain if they are defined.
41
+ data: categoryAxis?.categories ? categoryAxis.categories :
42
+ // Otherwise we just need random data to create the band scale.
43
+ Array.from({
44
+ length: maxSeriesLength
45
+ }, (_, index) => index),
46
+ tickLabelPlacement: 'middle'
47
+ }, categoryValues);
48
+ }
49
+
50
+ // If the scaleType is other than 'band', we have to do some magic.
51
+ // First we need to calculate the tick values additively and in reverse order.
52
+ const tickValues = [...maxSeriesValue.toReversed().map((_, i, arr) => arr.slice(0, i).reduce((a, value) => a + value, 0)),
53
+ // We add the total value of the series as the last tick value
54
+ maxSeriesValue.reduce((a, value) => a + value, 0)];
55
+ return (0, _extends2.default)({
56
+ scaleType: categoryAxis.scaleType,
57
+ domainLimit: 'strict',
58
+ tickLabelPlacement: 'middle',
59
+ tickInterval: tickValues,
60
+ // No need to show the first tick label
61
+ tickLabelInterval: (_, i) => i !== 0,
62
+ // We trick the valueFormatter to show the category values.
63
+ // By using the index of the tickValues array we can get the category value.
64
+ valueFormatter: value => `${categoryAxis.categories?.toReversed()[tickValues.findIndex(v => v === value) - 1]}`
65
+ }, categoryValues);
66
+ }
67
+
68
+ /**
69
+ * A helper function that extracts FunnelChartProps from the input props
70
+ * and returns an object with props for the children components of FunnelChart.
71
+ *
72
+ * @param props The input props for FunnelChart
73
+ * @returns An object with props for the children components of FunnelChart
74
+ */
75
+ const useFunnelChartProps = props => {
76
+ const {
77
+ categoryAxis,
78
+ series,
79
+ width,
80
+ height,
81
+ margin: marginProps,
82
+ colors,
83
+ sx,
84
+ children,
85
+ slots,
86
+ slotProps,
87
+ loading,
88
+ onItemClick,
89
+ highlightedItem,
90
+ onHighlightChange,
91
+ className,
92
+ axisHighlight,
93
+ apiRef
94
+ } = props,
95
+ rest = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
96
+ const margin = (0, _internals.defaultizeMargin)(marginProps, _constants.DEFAULT_MARGINS);
97
+ const id = (0, _useId.default)();
98
+ const clipPathId = `${id}-clip-path`;
99
+ const isHorizontal = series.some(s => s.layout === 'horizontal');
100
+ const valueAxisConfig = {
101
+ id: isHorizontal ? _constants.DEFAULT_Y_AXIS_KEY : _constants.DEFAULT_X_AXIS_KEY,
102
+ scaleType: 'linear',
103
+ domainLimit: 'strict',
104
+ position: 'none'
105
+ };
106
+ const xAxis = isHorizontal ? getCategoryAxisConfig(categoryAxis, series, isHorizontal, 'x') : valueAxisConfig;
107
+ const yAxis = isHorizontal ? valueAxisConfig : getCategoryAxisConfig(categoryAxis, series, isHorizontal, 'y');
108
+ const chartContainerProps = (0, _extends2.default)({}, rest, {
109
+ series: series.map(s => (0, _extends2.default)({
110
+ type: 'funnel',
111
+ layout: isHorizontal ? 'horizontal' : 'vertical'
112
+ }, s)),
113
+ width,
114
+ height,
115
+ margin,
116
+ colors,
117
+ xAxis: [xAxis],
118
+ yAxis: [yAxis],
119
+ sx,
120
+ highlightedItem,
121
+ onHighlightChange,
122
+ className,
123
+ apiRef
124
+ });
125
+ const funnelPlotProps = {
126
+ onItemClick,
127
+ slots,
128
+ slotProps
129
+ };
130
+ const overlayProps = {
131
+ slots,
132
+ slotProps,
133
+ loading
134
+ };
135
+ const chartsAxisProps = {
136
+ slots,
137
+ slotProps
138
+ };
139
+ const legendProps = {
140
+ slots,
141
+ slotProps
142
+ };
143
+ const clipPathGroupProps = {
144
+ clipPath: `url(#${clipPathId})`
145
+ };
146
+ const clipPathProps = {
147
+ id: clipPathId
148
+ };
149
+ const chartsWrapperProps = {
150
+ sx,
151
+ legendPosition: props.slotProps?.legend?.position,
152
+ legendDirection: props.slotProps?.legend?.direction
153
+ };
154
+ const axisHighlightProps = (0, _extends2.default)({}, axisHighlight);
155
+ return {
156
+ chartContainerProps,
157
+ funnelPlotProps,
158
+ overlayProps,
159
+ chartsAxisProps,
160
+ legendProps,
161
+ clipPathGroupProps,
162
+ clipPathProps,
163
+ chartsWrapperProps,
164
+ axisHighlightProps,
165
+ children
166
+ };
167
+ };
168
+ exports.useFunnelChartProps = useFunnelChartProps;
@@ -0,0 +1,3 @@
1
+ import { GetSeriesWithDefaultValues } from '@mui/x-charts/internals';
2
+ declare const getSeriesWithDefaultValues: GetSeriesWithDefaultValues<'heatmap'>;
3
+ export default getSeriesWithDefaultValues;