@mui/x-charts 7.11.0 → 7.12.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 (259) hide show
  1. package/BarChart/BarChart.js +0 -2
  2. package/BarChart/BarElement.d.ts +22 -21
  3. package/BarChart/BarElement.js +3 -3
  4. package/BarChart/BarLabel/BarLabel.d.ts +20 -20
  5. package/BarChart/BarLabel/BarLabelItem.d.ts +2 -1
  6. package/BarChart/BarLabel/BarLabelItem.js +2 -2
  7. package/BarChart/BarPlot.js +8 -8
  8. package/BarChart/checkScaleErrors.d.ts +4 -4
  9. package/BarChart/checkScaleErrors.js +11 -11
  10. package/BarChart/extremums.js +4 -1
  11. package/BarChart/formatter.js +3 -3
  12. package/CHANGELOG.md +194 -4
  13. package/ChartContainer/ChartContainer.d.ts +3 -3
  14. package/ChartContainer/ChartContainer.js +3 -5
  15. package/ChartContainer/useChartContainerProps.d.ts +50 -52
  16. package/ChartContainer/useChartContainerProps.js +2 -2
  17. package/ChartContainer/useDefaultizeAxis.d.ts +24 -25
  18. package/ChartContainer/usePluginsMerge.d.ts +1 -1
  19. package/ChartsAxis/ChartsAxis.js +4 -4
  20. package/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
  21. package/ChartsLegend/ChartsLegend.js +6 -6
  22. package/ChartsLegend/DefaultChartsLegend.d.ts +1 -1
  23. package/ChartsLegend/LegendPerItem.js +2 -2
  24. package/ChartsLegend/utils.d.ts +1 -1
  25. package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +3 -1
  26. package/ChartsOverlay/ChartsOverlay.d.ts +3 -2
  27. package/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  28. package/ChartsReferenceLine/ChartsXReferenceLine.js +1 -2
  29. package/ChartsReferenceLine/ChartsYReferenceLine.js +1 -2
  30. package/ChartsTooltip/ChartsAxisTooltipContent.js +9 -5
  31. package/ChartsTooltip/ChartsItemTooltipContent.js +6 -6
  32. package/ChartsTooltip/ChartsTooltip.d.ts +1 -1
  33. package/ChartsTooltip/ChartsTooltip.js +10 -10
  34. package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +5 -3
  35. package/ChartsXAxis/ChartsXAxis.js +5 -5
  36. package/ChartsYAxis/ChartsYAxis.js +6 -6
  37. package/Gauge/GaugeReferenceArc.js +1 -1
  38. package/Gauge/GaugeValueArc.js +1 -1
  39. package/LineChart/AnimatedArea.d.ts +20 -20
  40. package/LineChart/AnimatedArea.js +1 -1
  41. package/LineChart/AnimatedLine.d.ts +20 -20
  42. package/LineChart/AnimatedLine.js +1 -1
  43. package/LineChart/AreaElement.d.ts +2 -1
  44. package/LineChart/AreaElement.js +2 -2
  45. package/LineChart/AreaPlot.js +11 -7
  46. package/LineChart/LineChart.js +4 -3
  47. package/LineChart/LineElement.d.ts +2 -1
  48. package/LineChart/LineElement.js +2 -2
  49. package/LineChart/LineHighlightPlot.d.ts +2 -1
  50. package/LineChart/LineHighlightPlot.js +9 -5
  51. package/LineChart/LinePlot.js +11 -7
  52. package/LineChart/MarkElement.js +1 -1
  53. package/LineChart/MarkPlot.js +9 -5
  54. package/LineChart/extremums.js +4 -1
  55. package/LineChart/formatter.js +3 -3
  56. package/PieChart/PieArc.js +2 -1
  57. package/PieChart/PieArcLabel.js +1 -1
  58. package/PieChart/PieChart.js +0 -2
  59. package/PieChart/formatter.js +1 -1
  60. package/ResponsiveChartContainer/ResponsiveChartContainer.js +0 -2
  61. package/ResponsiveChartContainer/useChartContainerDimensions.js +2 -2
  62. package/ResponsiveChartContainer/useResponsiveChartContainerProps.d.ts +2 -2
  63. package/ScatterChart/ScatterChart.js +4 -3
  64. package/ScatterChart/ScatterPlot.js +6 -3
  65. package/ScatterChart/extremums.js +8 -2
  66. package/SparkLineChart/SparkLineChart.js +0 -2
  67. package/context/CartesianProvider/CartesianContext.d.ts +1 -1
  68. package/context/CartesianProvider/computeValue.d.ts +1 -1
  69. package/context/CartesianProvider/computeValue.js +1 -1
  70. package/context/CartesianProvider/defaultizeAxis.d.ts +24 -25
  71. package/context/CartesianProvider/getAxisExtremum.d.ts +1 -1
  72. package/context/CartesianProvider/normalizeAxis.js +1 -1
  73. package/context/DrawingProvider.d.ts +2 -1
  74. package/context/DrawingProvider.js +7 -1
  75. package/context/{SeriesContextProvider.d.ts → SeriesProvider/Series.types.d.ts} +4 -8
  76. package/context/SeriesProvider/Series.types.js +5 -0
  77. package/context/SeriesProvider/SeriesContext.d.ts +4 -0
  78. package/context/SeriesProvider/SeriesContext.js +16 -0
  79. package/context/SeriesProvider/SeriesProvider.d.ts +5 -0
  80. package/context/SeriesProvider/SeriesProvider.js +37 -0
  81. package/context/SeriesProvider/index.d.ts +12 -0
  82. package/context/SeriesProvider/index.js +49 -0
  83. package/context/SeriesProvider/processSeries.d.ts +17 -0
  84. package/context/SeriesProvider/processSeries.js +55 -0
  85. package/context/ZAxisContextProvider.d.ts +1 -1
  86. package/context/ZAxisContextProvider.js +1 -1
  87. package/esm/BarChart/BarChart.js +0 -2
  88. package/esm/BarChart/BarElement.js +2 -2
  89. package/esm/BarChart/BarLabel/BarLabelItem.js +1 -1
  90. package/esm/BarChart/BarPlot.js +8 -8
  91. package/esm/BarChart/checkScaleErrors.js +11 -11
  92. package/esm/BarChart/extremums.js +4 -1
  93. package/esm/BarChart/formatter.js +3 -3
  94. package/esm/ChartContainer/ChartContainer.js +3 -5
  95. package/esm/ChartContainer/useChartContainerProps.js +2 -2
  96. package/esm/ChartsAxis/ChartsAxis.js +4 -4
  97. package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
  98. package/esm/ChartsLegend/ChartsLegend.js +2 -2
  99. package/esm/ChartsLegend/LegendPerItem.js +1 -1
  100. package/esm/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +3 -1
  101. package/esm/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  102. package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +2 -3
  103. package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +2 -3
  104. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +8 -4
  105. package/esm/ChartsTooltip/ChartsItemTooltipContent.js +5 -5
  106. package/esm/ChartsTooltip/ChartsTooltip.js +3 -3
  107. package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +5 -3
  108. package/esm/ChartsXAxis/ChartsXAxis.js +2 -2
  109. package/esm/ChartsYAxis/ChartsYAxis.js +2 -2
  110. package/esm/Gauge/GaugeReferenceArc.js +1 -1
  111. package/esm/Gauge/GaugeValueArc.js +1 -1
  112. package/esm/LineChart/AnimatedArea.js +1 -1
  113. package/esm/LineChart/AnimatedLine.js +1 -1
  114. package/esm/LineChart/AreaElement.js +1 -1
  115. package/esm/LineChart/AreaPlot.js +11 -7
  116. package/esm/LineChart/LineChart.js +4 -3
  117. package/esm/LineChart/LineElement.js +1 -1
  118. package/esm/LineChart/LineHighlightPlot.js +9 -5
  119. package/esm/LineChart/LinePlot.js +11 -7
  120. package/esm/LineChart/MarkElement.js +1 -1
  121. package/esm/LineChart/MarkPlot.js +9 -5
  122. package/esm/LineChart/extremums.js +4 -1
  123. package/esm/LineChart/formatter.js +3 -3
  124. package/esm/PieChart/PieArc.js +2 -1
  125. package/esm/PieChart/PieArcLabel.js +1 -1
  126. package/esm/PieChart/PieChart.js +0 -2
  127. package/esm/PieChart/formatter.js +1 -1
  128. package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +0 -2
  129. package/esm/ResponsiveChartContainer/useChartContainerDimensions.js +2 -2
  130. package/esm/ScatterChart/ScatterChart.js +4 -3
  131. package/esm/ScatterChart/ScatterPlot.js +6 -3
  132. package/esm/ScatterChart/extremums.js +8 -2
  133. package/esm/SparkLineChart/SparkLineChart.js +0 -2
  134. package/esm/context/CartesianProvider/computeValue.js +1 -1
  135. package/esm/context/CartesianProvider/normalizeAxis.js +1 -1
  136. package/esm/context/DrawingProvider.js +7 -1
  137. package/esm/context/SeriesProvider/Series.types.js +1 -0
  138. package/esm/context/SeriesProvider/SeriesContext.js +8 -0
  139. package/esm/context/SeriesProvider/SeriesProvider.js +30 -0
  140. package/esm/context/SeriesProvider/index.js +8 -0
  141. package/esm/context/{SeriesContextProvider.js → SeriesProvider/processSeries.js} +10 -35
  142. package/esm/context/ZAxisContextProvider.js +1 -1
  143. package/esm/hooks/useAxisEvents.js +12 -8
  144. package/esm/hooks/useReducedMotion.js +2 -2
  145. package/esm/hooks/useSeries.js +1 -1
  146. package/esm/internals/SlotComponentPropsFromProps.js +1 -0
  147. package/esm/internals/colorScale.js +1 -1
  148. package/esm/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +1 -1
  149. package/esm/internals/geometry.js +1 -1
  150. package/esm/internals/getCurve.js +1 -1
  151. package/esm/internals/getPercentageValue.js +1 -1
  152. package/esm/internals/getScale.js +1 -1
  153. package/esm/internals/index.js +1 -1
  154. package/esm/internals/stackSeries.js +1 -1
  155. package/esm/internals/useAnimatedPath.js +1 -1
  156. package/esm/internals/warning.js +19 -11
  157. package/hooks/useAxisEvents.js +12 -8
  158. package/hooks/useReducedMotion.js +2 -2
  159. package/hooks/useSeries.d.ts +1 -1
  160. package/hooks/useSeries.js +2 -2
  161. package/hooks/useTicks.d.ts +1 -1
  162. package/index.js +1 -1
  163. package/internals/SlotComponentPropsFromProps.d.ts +1 -0
  164. package/internals/SlotComponentPropsFromProps.js +5 -0
  165. package/internals/colorScale.d.ts +3 -3
  166. package/internals/colorScale.js +1 -1
  167. package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +1 -1
  168. package/internals/defaultizeColor.d.ts +8 -1
  169. package/internals/geometry.js +1 -1
  170. package/internals/getCurve.d.ts +1 -1
  171. package/internals/getCurve.js +1 -1
  172. package/internals/getPercentageValue.js +1 -1
  173. package/internals/getScale.js +1 -1
  174. package/internals/index.d.ts +1 -1
  175. package/internals/index.js +4 -4
  176. package/internals/isBandScale.d.ts +1 -1
  177. package/internals/stackSeries.d.ts +1 -1
  178. package/internals/stackSeries.js +1 -1
  179. package/internals/useAnimatedPath.js +1 -1
  180. package/internals/warning.d.ts +2 -1
  181. package/internals/warning.js +21 -12
  182. package/models/axis.d.ts +2 -2
  183. package/models/seriesType/common.d.ts +10 -0
  184. package/models/seriesType/pie.d.ts +1 -1
  185. package/models/seriesType/scatter.d.ts +5 -0
  186. package/models/z-axis.d.ts +1 -1
  187. package/modern/BarChart/BarChart.js +0 -2
  188. package/modern/BarChart/BarElement.js +2 -2
  189. package/modern/BarChart/BarLabel/BarLabelItem.js +1 -1
  190. package/modern/BarChart/BarPlot.js +8 -8
  191. package/modern/BarChart/checkScaleErrors.js +11 -11
  192. package/modern/BarChart/extremums.js +4 -1
  193. package/modern/BarChart/formatter.js +3 -3
  194. package/modern/ChartContainer/ChartContainer.js +3 -5
  195. package/modern/ChartContainer/useChartContainerProps.js +2 -2
  196. package/modern/ChartsAxis/ChartsAxis.js +4 -4
  197. package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
  198. package/modern/ChartsLegend/ChartsLegend.js +2 -2
  199. package/modern/ChartsLegend/LegendPerItem.js +1 -1
  200. package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +3 -1
  201. package/modern/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  202. package/modern/ChartsReferenceLine/ChartsXReferenceLine.js +2 -3
  203. package/modern/ChartsReferenceLine/ChartsYReferenceLine.js +2 -3
  204. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +8 -4
  205. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +5 -5
  206. package/modern/ChartsTooltip/ChartsTooltip.js +3 -3
  207. package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +5 -3
  208. package/modern/ChartsXAxis/ChartsXAxis.js +2 -2
  209. package/modern/ChartsYAxis/ChartsYAxis.js +2 -2
  210. package/modern/Gauge/GaugeReferenceArc.js +1 -1
  211. package/modern/Gauge/GaugeValueArc.js +1 -1
  212. package/modern/LineChart/AnimatedArea.js +1 -1
  213. package/modern/LineChart/AnimatedLine.js +1 -1
  214. package/modern/LineChart/AreaElement.js +1 -1
  215. package/modern/LineChart/AreaPlot.js +11 -7
  216. package/modern/LineChart/LineChart.js +4 -3
  217. package/modern/LineChart/LineElement.js +1 -1
  218. package/modern/LineChart/LineHighlightPlot.js +9 -5
  219. package/modern/LineChart/LinePlot.js +11 -7
  220. package/modern/LineChart/MarkElement.js +1 -1
  221. package/modern/LineChart/MarkPlot.js +9 -5
  222. package/modern/LineChart/extremums.js +4 -1
  223. package/modern/LineChart/formatter.js +3 -3
  224. package/modern/PieChart/PieArc.js +2 -1
  225. package/modern/PieChart/PieArcLabel.js +1 -1
  226. package/modern/PieChart/PieChart.js +0 -2
  227. package/modern/PieChart/formatter.js +1 -1
  228. package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +0 -2
  229. package/modern/ResponsiveChartContainer/useChartContainerDimensions.js +2 -2
  230. package/modern/ScatterChart/ScatterChart.js +4 -3
  231. package/modern/ScatterChart/ScatterPlot.js +6 -3
  232. package/modern/ScatterChart/extremums.js +8 -2
  233. package/modern/SparkLineChart/SparkLineChart.js +0 -2
  234. package/modern/context/CartesianProvider/computeValue.js +1 -1
  235. package/modern/context/CartesianProvider/normalizeAxis.js +1 -1
  236. package/modern/context/DrawingProvider.js +7 -1
  237. package/modern/context/SeriesProvider/Series.types.js +1 -0
  238. package/modern/context/SeriesProvider/SeriesContext.js +8 -0
  239. package/modern/context/SeriesProvider/SeriesProvider.js +30 -0
  240. package/modern/context/SeriesProvider/index.js +8 -0
  241. package/modern/context/{SeriesContextProvider.js → SeriesProvider/processSeries.js} +10 -35
  242. package/modern/context/ZAxisContextProvider.js +1 -1
  243. package/modern/hooks/useAxisEvents.js +12 -8
  244. package/modern/hooks/useReducedMotion.js +2 -2
  245. package/modern/hooks/useSeries.js +1 -1
  246. package/modern/index.js +1 -1
  247. package/modern/internals/SlotComponentPropsFromProps.js +1 -0
  248. package/modern/internals/colorScale.js +1 -1
  249. package/modern/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +1 -1
  250. package/modern/internals/geometry.js +1 -1
  251. package/modern/internals/getCurve.js +1 -1
  252. package/modern/internals/getPercentageValue.js +1 -1
  253. package/modern/internals/getScale.js +1 -1
  254. package/modern/internals/index.js +1 -1
  255. package/modern/internals/stackSeries.js +1 -1
  256. package/modern/internals/useAnimatedPath.js +1 -1
  257. package/modern/internals/warning.js +19 -11
  258. package/package.json +8 -25
  259. package/context/SeriesContextProvider.js +0 -81
@@ -50,7 +50,10 @@ const ScatterChart = exports.ScatterChart = /*#__PURE__*/React.forwardRef(functi
50
50
  ref: ref
51
51
  }, chartContainerProps, {
52
52
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ZAxisContextProvider.ZAxisContextProvider, (0, _extends2.default)({}, zAxisProps, {
53
- children: [!props.disableVoronoi && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsVoronoiHandler.ChartsVoronoiHandler, (0, _extends2.default)({}, voronoiHandlerProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxis.ChartsAxis, (0, _extends2.default)({}, chartsAxisProps)), props.grid && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsGrid.ChartsGrid, (0, _extends2.default)({}, gridProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScatterPlot.ScatterPlot, (0, _extends2.default)({}, scatterPlotProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsOverlay.ChartsOverlay, (0, _extends2.default)({}, overlayProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsLegend.ChartsLegend, (0, _extends2.default)({}, legendProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxisHighlight.ChartsAxisHighlight, (0, _extends2.default)({}, axisHighlightProps)), !props.loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsTooltip.ChartsTooltip, (0, _extends2.default)({}, tooltipProps)), children]
53
+ children: [!props.disableVoronoi && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsVoronoiHandler.ChartsVoronoiHandler, (0, _extends2.default)({}, voronoiHandlerProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxis.ChartsAxis, (0, _extends2.default)({}, chartsAxisProps)), props.grid && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsGrid.ChartsGrid, (0, _extends2.default)({}, gridProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {
54
+ "data-drawing-container": true,
55
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScatterPlot.ScatterPlot, (0, _extends2.default)({}, scatterPlotProps))
56
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsOverlay.ChartsOverlay, (0, _extends2.default)({}, overlayProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsLegend.ChartsLegend, (0, _extends2.default)({}, legendProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxisHighlight.ChartsAxisHighlight, (0, _extends2.default)({}, axisHighlightProps)), !props.loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsTooltip.ChartsTooltip, (0, _extends2.default)({}, tooltipProps)), children]
54
57
  }))
55
58
  }));
56
59
  });
@@ -227,7 +230,6 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
227
230
  * An array of [[AxisConfig]] objects.
228
231
  */
229
232
  xAxis: _propTypes.default.arrayOf(_propTypes.default.shape({
230
- axisId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
231
233
  classes: _propTypes.default.object,
232
234
  colorMap: _propTypes.default.oneOfType([_propTypes.default.shape({
233
235
  colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
@@ -280,7 +282,6 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
280
282
  * An array of [[AxisConfig]] objects.
281
283
  */
282
284
  yAxis: _propTypes.default.arrayOf(_propTypes.default.shape({
283
- axisId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
284
285
  classes: _propTypes.default.object,
285
286
  colorMap: _propTypes.default.oneOfType([_propTypes.default.shape({
286
287
  colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
@@ -62,12 +62,15 @@ function ScatterPlot(props) {
62
62
  xAxisKey,
63
63
  yAxisKey,
64
64
  zAxisKey,
65
+ xAxisId,
66
+ yAxisId,
67
+ zAxisId,
65
68
  markerSize,
66
69
  color
67
70
  } = series[seriesId];
68
- const colorGetter = (0, _getColor.default)(series[seriesId], xAxis[xAxisKey ?? defaultXAxisId], yAxis[yAxisKey ?? defaultYAxisId], zAxis[zAxisKey ?? defaultZAxisId]);
69
- const xScale = xAxis[xAxisKey ?? defaultXAxisId].scale;
70
- const yScale = yAxis[yAxisKey ?? defaultYAxisId].scale;
71
+ const colorGetter = (0, _getColor.default)(series[seriesId], xAxis[xAxisId ?? xAxisKey ?? defaultXAxisId], yAxis[yAxisId ?? yAxisKey ?? defaultYAxisId], zAxis[zAxisId ?? zAxisKey ?? defaultZAxisId]);
72
+ const xScale = xAxis[xAxisId ?? xAxisKey ?? defaultXAxisId].scale;
73
+ const yScale = yAxis[yAxisId ?? yAxisKey ?? defaultYAxisId].scale;
71
74
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(ScatterItems, (0, _extends2.default)({
72
75
  xScale: xScale,
73
76
  yScale: yScale,
@@ -19,7 +19,10 @@ const getExtremumX = params => {
19
19
  axis,
20
20
  isDefaultAxis
21
21
  } = params;
22
- return Object.keys(series).filter(seriesId => series[seriesId].xAxisKey === axis.id || series[seriesId].xAxisKey === undefined && isDefaultAxis).reduce((acc, seriesId) => {
22
+ return Object.keys(series).filter(seriesId => {
23
+ const axisId = series[seriesId].xAxisId ?? series[seriesId].xAxisKey;
24
+ return axisId === axis.id || axisId === undefined && isDefaultAxis;
25
+ }).reduce((acc, seriesId) => {
23
26
  const seriesMinMax = series[seriesId].data.reduce((accSeries, {
24
27
  x
25
28
  }) => {
@@ -36,7 +39,10 @@ const getExtremumY = params => {
36
39
  axis,
37
40
  isDefaultAxis
38
41
  } = params;
39
- return Object.keys(series).filter(seriesId => series[seriesId].yAxisKey === axis.id || series[seriesId].yAxisKey === undefined && isDefaultAxis).reduce((acc, seriesId) => {
42
+ return Object.keys(series).filter(seriesId => {
43
+ const axisId = series[seriesId].yAxisId ?? series[seriesId].yAxisKey;
44
+ return axisId === axis.id || axisId === undefined && isDefaultAxis;
45
+ }).reduce((acc, seriesId) => {
40
46
  const seriesMinMax = series[seriesId].data.reduce((accSeries, {
41
47
  y
42
48
  }) => {
@@ -254,7 +254,6 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
254
254
  * Notice it is a single [[AxisConfig]] object, not an array of configuration.
255
255
  */
256
256
  xAxis: _propTypes.default.shape({
257
- axisId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
258
257
  classes: _propTypes.default.object,
259
258
  colorMap: _propTypes.default.oneOfType([_propTypes.default.shape({
260
259
  colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
@@ -306,7 +305,6 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
306
305
  * Notice it is a single [[AxisConfig]] object, not an array of configuration.
307
306
  */
308
307
  yAxis: _propTypes.default.shape({
309
- axisId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
310
308
  classes: _propTypes.default.object,
311
309
  colorMap: _propTypes.default.oneOfType([_propTypes.default.shape({
312
310
  colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import { Initializable } from '../context.types';
3
3
  import { AxisDefaultized, ScaleName, ChartsXAxisProps, ChartsYAxisProps, AxisId } from '../../models/axis';
4
4
  export type DefaultizedAxisConfig<AxisProps> = {
5
- [axisKey: AxisId]: AxisDefaultized<ScaleName, any, AxisProps>;
5
+ [axisId: AxisId]: AxisDefaultized<ScaleName, any, AxisProps>;
6
6
  };
7
7
  export type CartesianContextState = {
8
8
  /**
@@ -3,7 +3,7 @@ import { ChartsXAxisProps, ChartsAxisProps, ChartsYAxisProps, AxisId } from '../
3
3
  import { CartesianChartSeriesType, DatasetType, ExtremumGetter } from '../../models/seriesType/config';
4
4
  import { DefaultizedAxisConfig } from './CartesianContext';
5
5
  import { DrawingArea } from '../DrawingProvider';
6
- import { FormattedSeries } from '../SeriesContextProvider';
6
+ import { FormattedSeries } from '../SeriesProvider';
7
7
  export declare function computeValue(options: {
8
8
  drawingArea: DrawingArea;
9
9
  formattedSeries: FormattedSeries;
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.computeValue = computeValue;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
- var _d3Scale = require("d3-scale");
9
+ var _d3Scale = require("@mui/x-charts-vendor/d3-scale");
10
10
  var _axis = require("../../models/axis");
11
11
  var _colorScale = require("../../internals/colorScale");
12
12
  var _useTicks = require("../../hooks/useTicks");
@@ -2,35 +2,34 @@ import { MakeOptional } from '../../models/helpers';
2
2
  import { AxisConfig, ScaleName } from '../../models';
3
3
  import { ChartsAxisProps } from '../../models/axis';
4
4
  export declare const defaultizeAxis: (inAxis: MakeOptional<AxisConfig<ScaleName, any, ChartsAxisProps>, "id">[] | undefined, axisName: "x" | "y") => {
5
- reverse?: boolean;
6
- fill?: string;
7
- stroke?: string;
5
+ reverse?: boolean | undefined;
6
+ fill?: string | undefined;
7
+ stroke?: string | undefined;
8
8
  data?: any[] | undefined;
9
- label?: string;
10
- max?: number | Date;
11
- min?: number | Date;
12
- classes?: Partial<import("../..").ChartsAxisClasses>;
13
- slots?: Partial<import("../../models/axis").ChartsAxisSlots>;
14
- slotProps?: Partial<import("../../models/axis").ChartsAxisSlotProps>;
15
- dataKey?: string;
9
+ label?: string | undefined;
10
+ max?: (number | Date) | undefined;
11
+ min?: (number | Date) | undefined;
12
+ classes?: Partial<import("../..").ChartsAxisClasses> | undefined;
13
+ slots?: Partial<import("../../models/axis").ChartsAxisSlots> | undefined;
14
+ slotProps?: Partial<import("../../models/axis").ChartsAxisSlotProps> | undefined;
15
+ dataKey?: string | undefined;
16
16
  valueFormatter?: ((value: any, context: import("../../models/axis").AxisValueFormatterContext) => string) | undefined;
17
17
  colorMap?: import("../../models/colorMapping").ContinuousColorConfig<number | Date> | import("../../models/colorMapping").PiecewiseColorConfig<number | Date> | import("../../models/colorMapping").OrdinalColorConfig<string | number | Date> | undefined;
18
- tickMaxStep?: number;
19
- tickMinStep?: number;
20
- tickNumber?: number;
21
- tickPlacement?: "start" | "end" | "middle" | "extremities";
22
- tickLabelPlacement?: "middle" | "tick";
23
- scaleType?: "linear" | "time" | "log" | "band" | "point" | "pow" | "sqrt" | "utc" | undefined;
24
- axisId?: import("../../models/axis").AxisId;
25
- disableLine?: boolean;
26
- disableTicks?: boolean;
27
- tickFontSize?: number;
18
+ tickMaxStep?: number | undefined;
19
+ tickMinStep?: number | undefined;
20
+ tickNumber?: number | undefined;
21
+ disableLine?: boolean | undefined;
22
+ disableTicks?: boolean | undefined;
23
+ tickFontSize?: number | undefined;
28
24
  tickLabelStyle?: import("../..").ChartsTextProps["style"];
29
25
  labelStyle?: import("../..").ChartsTextProps["style"];
30
- tickLabelInterval?: "auto" | ((value: any, index: number) => boolean);
31
- labelFontSize?: number;
32
- tickSize?: number;
33
- tickInterval?: "auto" | ((value: any, index: number) => boolean) | any[];
34
- hideTooltip?: boolean;
26
+ tickLabelInterval?: ("auto" | ((value: any, index: number) => boolean)) | undefined;
27
+ labelFontSize?: number | undefined;
28
+ tickSize?: number | undefined;
29
+ tickInterval?: ("auto" | ((value: any, index: number) => boolean) | any[]) | undefined;
30
+ tickPlacement?: ("start" | "end" | "middle" | "extremities") | undefined;
31
+ tickLabelPlacement?: ("middle" | "tick") | undefined;
32
+ scaleType?: "linear" | "time" | "log" | "band" | "point" | "pow" | "sqrt" | "utc" | undefined;
33
+ hideTooltip?: boolean | undefined;
35
34
  id: import("../../models/axis").AxisId;
36
35
  }[];
@@ -1,4 +1,4 @@
1
1
  import { AxisConfig, ExtremumGettersConfig } from '../../models';
2
2
  import { ExtremumGetterResult } from '../../models/seriesType/config';
3
- import { FormattedSeries } from '../SeriesContextProvider';
3
+ import { FormattedSeries } from '../SeriesProvider';
4
4
  export declare const getAxisExtremum: (axis: AxisConfig, getters: ExtremumGettersConfig, isDefaultAxis: boolean, formattedSeries: FormattedSeries) => ExtremumGetterResult;
@@ -13,7 +13,7 @@ const normalizeAxis = (axis, dataset, axisName) => {
13
13
  return axisConfig;
14
14
  }
15
15
  if (dataset === undefined) {
16
- throw Error(`MUI X Charts: ${axisName}-axis uses \`dataKey\` but no \`dataset\` is provided.`);
16
+ throw Error(`MUI X: ${axisName}-axis uses \`dataKey\` but no \`dataset\` is provided.`);
17
17
  }
18
18
  return (0, _extends2.default)({}, axisConfig, {
19
19
  data: dataset.map(d => d[dataKey])
@@ -38,12 +38,13 @@ export type DrawingArea = {
38
38
  * @param {Object} point The point to check.
39
39
  * @param {number} point.x The x coordinate of the point.
40
40
  * @param {number} point.y The y coordinate of the point.
41
+ * @param {Element} targetElement The target element if relevant.
41
42
  * @returns {boolean} `true` if the point is inside the drawing area, `false` otherwise.
42
43
  */
43
44
  isPointInside: (point: {
44
45
  x: number;
45
46
  y: number;
46
- }) => boolean;
47
+ }, targetElement?: Element) => boolean;
47
48
  };
48
49
  export declare const DrawingContext: React.Context<DrawingArea & {
49
50
  /**
@@ -53,7 +53,13 @@ function DrawingProvider(props) {
53
53
  const isPointInside = React.useCallback(({
54
54
  x,
55
55
  y
56
- }) => x >= drawingArea.left && x <= drawingArea.left + drawingArea.width && y >= drawingArea.top && y <= drawingArea.top + drawingArea.height, [drawingArea]);
56
+ }, targetElement) => {
57
+ // For element allowed to overflow, wrapping them in <g data-drawing-container /> make them fully part of the drawing area.
58
+ if (targetElement && targetElement.closest('[data-drawing-container]')) {
59
+ return true;
60
+ }
61
+ return x >= drawingArea.left && x <= drawingArea.left + drawingArea.width && y >= drawingArea.top && y <= drawingArea.top + drawingArea.height;
62
+ }, [drawingArea]);
57
63
  const value = React.useMemo(() => (0, _extends2.default)({
58
64
  chartId: chartId ?? ''
59
65
  }, drawingArea, {
@@ -1,12 +1,11 @@
1
1
  import * as React from 'react';
2
- import { AllSeriesType } from '../models/seriesType';
3
- import { ChartSeriesType, DatasetType, FormatterParams, FormatterResult } from '../models/seriesType/config';
4
- import { ChartsColorPalette } from '../colorPalettes';
5
- import { Initializable } from './context.types';
2
+ import { AllSeriesType } from '../../models/seriesType';
3
+ import { ChartSeriesType, DatasetType, FormatterParams, FormatterResult } from '../../models/seriesType/config';
4
+ import { ChartsColorPalette } from '../../colorPalettes';
6
5
  export type SeriesFormatterType<T extends ChartSeriesType> = (series: AllSeriesType<T>[], colors: string[], dataset?: DatasetType) => {
7
6
  [type in T]?: FormatterResult<type>;
8
7
  };
9
- export type SeriesContextProviderProps<T extends ChartSeriesType = ChartSeriesType> = {
8
+ export type SeriesProviderProps<T extends ChartSeriesType = ChartSeriesType> = {
10
9
  dataset?: DatasetType;
11
10
  /**
12
11
  * The array of series to display.
@@ -28,9 +27,6 @@ export type SeriesContextProviderProps<T extends ChartSeriesType = ChartSeriesTy
28
27
  export type FormattedSeries = {
29
28
  [type in ChartSeriesType]?: FormatterResult<type>;
30
29
  };
31
- export declare const SeriesContext: React.Context<Initializable<FormattedSeries>>;
32
30
  export type SeriesFormatterConfig<T extends ChartSeriesType = ChartSeriesType> = {
33
31
  [K in T]?: (series: FormatterParams<K>, dataset?: DatasetType) => any;
34
32
  };
35
- declare function SeriesContextProvider<T extends ChartSeriesType>(props: SeriesContextProviderProps<T>): React.JSX.Element;
36
- export { SeriesContextProvider };
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,4 @@
1
+ import * as React from 'react';
2
+ import { Initializable } from '../context.types';
3
+ import { FormattedSeries } from './Series.types';
4
+ export declare const SeriesContext: React.Context<Initializable<FormattedSeries>>;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SeriesContext = void 0;
7
+ var React = _interopRequireWildcard(require("react"));
8
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
9
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
10
+ const SeriesContext = exports.SeriesContext = /*#__PURE__*/React.createContext({
11
+ isInitialized: false,
12
+ data: {}
13
+ });
14
+ if (process.env.NODE_ENV !== 'production') {
15
+ SeriesContext.displayName = 'SeriesContext';
16
+ }
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ import { ChartSeriesType } from '../../models/seriesType/config';
3
+ import { SeriesProviderProps } from './Series.types';
4
+ declare function SeriesProvider<T extends ChartSeriesType>(props: SeriesProviderProps<T>): React.JSX.Element;
5
+ export { SeriesProvider };
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SeriesProvider = SeriesProvider;
7
+ var React = _interopRequireWildcard(require("react"));
8
+ var _styles = require("@mui/material/styles");
9
+ var _colorPalettes = require("../../colorPalettes");
10
+ var _SeriesContext = require("./SeriesContext");
11
+ var _processSeries = require("./processSeries");
12
+ var _jsxRuntime = require("react/jsx-runtime");
13
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
14
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
15
+ function SeriesProvider(props) {
16
+ const {
17
+ series,
18
+ dataset,
19
+ colors = _colorPalettes.blueberryTwilightPalette,
20
+ seriesFormatters,
21
+ children
22
+ } = props;
23
+ const theme = (0, _styles.useTheme)();
24
+ const formattedSeries = React.useMemo(() => ({
25
+ isInitialized: true,
26
+ data: (0, _processSeries.preprocessSeries)({
27
+ series,
28
+ colors: typeof colors === 'function' ? colors(theme.palette.mode) : colors,
29
+ seriesFormatters,
30
+ dataset: dataset
31
+ })
32
+ }), [series, colors, theme.palette.mode, seriesFormatters, dataset]);
33
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_SeriesContext.SeriesContext.Provider, {
34
+ value: formattedSeries,
35
+ children: children
36
+ });
37
+ }
@@ -0,0 +1,12 @@
1
+ export * from './SeriesProvider';
2
+ export * from './SeriesContext';
3
+ export * from './Series.types';
4
+ declare const seriesProviderUtils: {
5
+ preprocessSeries: <T extends import("../../internals").ChartSeriesType>({ series, colors, seriesFormatters, dataset, }: {
6
+ series: import("../..").AllSeriesType<T>[];
7
+ colors: string[];
8
+ seriesFormatters: import("./Series.types").SeriesFormatterConfig<T>;
9
+ dataset?: import("../../internals").DatasetType;
10
+ }) => import("./Series.types").FormattedSeries;
11
+ };
12
+ export { seriesProviderUtils };
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _exportNames = {
7
+ seriesProviderUtils: true
8
+ };
9
+ exports.seriesProviderUtils = void 0;
10
+ var _processSeries = require("./processSeries");
11
+ var _SeriesProvider = require("./SeriesProvider");
12
+ Object.keys(_SeriesProvider).forEach(function (key) {
13
+ if (key === "default" || key === "__esModule") return;
14
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
15
+ if (key in exports && exports[key] === _SeriesProvider[key]) return;
16
+ Object.defineProperty(exports, key, {
17
+ enumerable: true,
18
+ get: function () {
19
+ return _SeriesProvider[key];
20
+ }
21
+ });
22
+ });
23
+ var _SeriesContext = require("./SeriesContext");
24
+ Object.keys(_SeriesContext).forEach(function (key) {
25
+ if (key === "default" || key === "__esModule") return;
26
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
27
+ if (key in exports && exports[key] === _SeriesContext[key]) return;
28
+ Object.defineProperty(exports, key, {
29
+ enumerable: true,
30
+ get: function () {
31
+ return _SeriesContext[key];
32
+ }
33
+ });
34
+ });
35
+ var _Series = require("./Series.types");
36
+ Object.keys(_Series).forEach(function (key) {
37
+ if (key === "default" || key === "__esModule") return;
38
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
39
+ if (key in exports && exports[key] === _Series[key]) return;
40
+ Object.defineProperty(exports, key, {
41
+ enumerable: true,
42
+ get: function () {
43
+ return _Series[key];
44
+ }
45
+ });
46
+ });
47
+ const seriesProviderUtils = exports.seriesProviderUtils = {
48
+ preprocessSeries: _processSeries.preprocessSeries
49
+ };
@@ -0,0 +1,17 @@
1
+ import { AllSeriesType } from '../../models/seriesType';
2
+ import { ChartSeriesType, DatasetType } from '../../models/seriesType/config';
3
+ import { FormattedSeries, SeriesFormatterConfig } from './Series.types';
4
+ /**
5
+ * This methods is the interface between what the developer is providing and what components receives
6
+ * To simplify the components behaviors, it groups series by type, such that LinePlots props are not updated if some line data are modified
7
+ * It also add defaultized values such as the ids, colors
8
+ * @param series The array of series provided by the developer
9
+ * @param colors The color palette used to defaultize series colors
10
+ * @returns An object structuring all the series by type.
11
+ */
12
+ export declare const preprocessSeries: <T extends ChartSeriesType>({ series, colors, seriesFormatters, dataset, }: {
13
+ series: AllSeriesType<T>[];
14
+ colors: string[];
15
+ seriesFormatters: SeriesFormatterConfig<T>;
16
+ dataset?: DatasetType;
17
+ }) => FormattedSeries;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.preprocessSeries = void 0;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var _defaultizeColor = require("../../internals/defaultizeColor");
10
+ /**
11
+ * This methods is the interface between what the developer is providing and what components receives
12
+ * To simplify the components behaviors, it groups series by type, such that LinePlots props are not updated if some line data are modified
13
+ * It also add defaultized values such as the ids, colors
14
+ * @param series The array of series provided by the developer
15
+ * @param colors The color palette used to defaultize series colors
16
+ * @returns An object structuring all the series by type.
17
+ */
18
+ const preprocessSeries = ({
19
+ series,
20
+ colors,
21
+ seriesFormatters,
22
+ dataset
23
+ }) => {
24
+ // Group series by type
25
+ const seriesGroups = {};
26
+ series.forEach((seriesData, seriesIndex) => {
27
+ const {
28
+ id = `auto-generated-id-${seriesIndex}`,
29
+ type
30
+ } = seriesData;
31
+ if (seriesGroups[type] === undefined) {
32
+ seriesGroups[type] = {
33
+ series: {},
34
+ seriesOrder: []
35
+ };
36
+ }
37
+ if (seriesGroups[type]?.series[id] !== undefined) {
38
+ throw new Error(`MUI X: series' id "${id}" is not unique.`);
39
+ }
40
+ seriesGroups[type].series[id] = (0, _extends2.default)({
41
+ id
42
+ }, (0, _defaultizeColor.defaultizeColor)(seriesData, seriesIndex, colors));
43
+ seriesGroups[type].seriesOrder.push(id);
44
+ });
45
+ const formattedSeries = {};
46
+ // Apply formatter on a type group
47
+ Object.keys(seriesFormatters).forEach(type => {
48
+ const group = seriesGroups[type];
49
+ if (group !== undefined) {
50
+ formattedSeries[type] = seriesFormatters[type]?.(group, dataset) ?? seriesGroups[type];
51
+ }
52
+ });
53
+ return formattedSeries;
54
+ };
55
+ exports.preprocessSeries = preprocessSeries;
@@ -14,7 +14,7 @@ export type ZAxisContextProviderProps = {
14
14
  children: React.ReactNode;
15
15
  };
16
16
  type DefaultizedZAxisConfig = {
17
- [axisKey: string]: ZAxisDefaultized;
17
+ [axisId: string]: ZAxisDefaultized;
18
18
  };
19
19
  export declare const ZAxisContext: React.Context<{
20
20
  /**
@@ -32,7 +32,7 @@ function ZAxisContextProvider(props) {
32
32
  return axisConfig;
33
33
  }
34
34
  if (dataset === undefined) {
35
- throw Error('MUI X Charts: z-axis uses `dataKey` but no `dataset` is provided.');
35
+ throw Error('MUI X: z-axis uses `dataKey` but no `dataset` is provided.');
36
36
  }
37
37
  return (0, _extends2.default)({}, axisConfig, {
38
38
  data: dataset.map(d => d[dataKey])
@@ -239,7 +239,6 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
239
239
  * An array of [[AxisConfig]] objects.
240
240
  */
241
241
  xAxis: PropTypes.arrayOf(PropTypes.shape({
242
- axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
243
242
  classes: PropTypes.object,
244
243
  colorMap: PropTypes.oneOfType([PropTypes.shape({
245
244
  colors: PropTypes.arrayOf(PropTypes.string).isRequired,
@@ -292,7 +291,6 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
292
291
  * An array of [[AxisConfig]] objects.
293
292
  */
294
293
  yAxis: PropTypes.arrayOf(PropTypes.shape({
295
- axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
296
294
  classes: PropTypes.object,
297
295
  colorMap: PropTypes.oneOfType([PropTypes.shape({
298
296
  colors: PropTypes.arrayOf(PropTypes.string).isRequired,
@@ -4,11 +4,11 @@ const _excluded = ["id", "dataIndex", "classes", "color", "slots", "slotProps",
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import composeClasses from '@mui/utils/composeClasses';
7
- import { useSlotProps } from '@mui/base/utils';
7
+ import useSlotProps from '@mui/utils/useSlotProps';
8
8
  import generateUtilityClass from '@mui/utils/generateUtilityClass';
9
9
  import { styled } from '@mui/material/styles';
10
- import { color as d3Color } from 'd3-color';
11
10
  import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
11
+ import { color as d3Color } from '@mui/x-charts-vendor/d3-color';
12
12
  import { animated } from '@react-spring/web';
13
13
  import { useInteractionItemProps } from '../hooks/useInteractionItemProps';
14
14
  import { useItemHighlighted } from '../context';
@@ -3,7 +3,7 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
3
3
  const _excluded = ["seriesId", "classes", "color", "style", "dataIndex", "barLabel", "slots", "slotProps", "height", "width", "value"],
4
4
  _excluded2 = ["ownerState"];
5
5
  import * as React from 'react';
6
- import { useSlotProps } from '@mui/base/utils';
6
+ import useSlotProps from '@mui/utils/useSlotProps';
7
7
  import PropTypes from 'prop-types';
8
8
  import { useUtilityClasses } from './barLabelClasses';
9
9
  import { getBarLabel } from './getBarLabel';
@@ -66,16 +66,16 @@ const useAggregatedData = () => {
66
66
  ids: groupIds
67
67
  }, groupIndex) => {
68
68
  return groupIds.flatMap(seriesId => {
69
- const xAxisKey = series[seriesId].xAxisKey ?? defaultXAxisId;
70
- const yAxisKey = series[seriesId].yAxisKey ?? defaultYAxisId;
71
- const xAxisConfig = xAxis[xAxisKey];
72
- const yAxisConfig = yAxis[yAxisKey];
69
+ const xAxisId = series[seriesId].xAxisId ?? series[seriesId].xAxisKey ?? defaultXAxisId;
70
+ const yAxisId = series[seriesId].yAxisId ?? series[seriesId].yAxisKey ?? defaultYAxisId;
71
+ const xAxisConfig = xAxis[xAxisId];
72
+ const yAxisConfig = yAxis[yAxisId];
73
73
  const verticalLayout = series[seriesId].layout === 'vertical';
74
- checkScaleErrors(verticalLayout, seriesId, xAxisKey, xAxis, yAxisKey, yAxis);
74
+ checkScaleErrors(verticalLayout, seriesId, xAxisId, xAxis, yAxisId, yAxis);
75
75
  const baseScaleConfig = verticalLayout ? xAxisConfig : yAxisConfig;
76
76
  const xScale = xAxisConfig.scale;
77
77
  const yScale = yAxisConfig.scale;
78
- const colorGetter = getColor(series[seriesId], xAxis[xAxisKey], yAxis[yAxisKey]);
78
+ const colorGetter = getColor(series[seriesId], xAxis[xAxisId], yAxis[yAxisId]);
79
79
  const bandWidth = baseScaleConfig.scale.bandwidth();
80
80
  const {
81
81
  barWidth,
@@ -98,8 +98,8 @@ const useAggregatedData = () => {
98
98
  seriesId,
99
99
  dataIndex,
100
100
  layout: series[seriesId].layout,
101
- x: verticalLayout ? xScale(xAxis[xAxisKey].data?.[dataIndex]) + barOffset : minValueCoord,
102
- y: verticalLayout ? minValueCoord : yScale(yAxis[yAxisKey].data?.[dataIndex]) + barOffset,
101
+ x: verticalLayout ? xScale(xAxis[xAxisId].data?.[dataIndex]) + barOffset : minValueCoord,
102
+ y: verticalLayout ? minValueCoord : yScale(yAxis[yAxisId].data?.[dataIndex]) + barOffset,
103
103
  xOrigin: xScale(0),
104
104
  yOrigin: yScale(0),
105
105
  height: verticalLayout ? maxValueCoord - minValueCoord : barWidth,
@@ -1,27 +1,27 @@
1
1
  import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from '../constants';
2
2
  import { isBandScaleConfig, isPointScaleConfig } from '../models/axis';
3
- const getAxisMessage = (axisDirection, axisKey) => {
3
+ const getAxisMessage = (axisDirection, axisId) => {
4
4
  const axisName = `${axisDirection}-axis`;
5
- const axisKeyName = `${axisDirection}Axis`;
5
+ const axisIdName = `${axisDirection}Axis`;
6
6
  const axisDefaultKey = axisDirection === 'x' ? DEFAULT_X_AXIS_KEY : DEFAULT_Y_AXIS_KEY;
7
- return axisKey === axisDefaultKey ? `The first \`${axisKeyName}\`` : `The ${axisName} with id "${axisKey}"`;
7
+ return axisId === axisDefaultKey ? `The first \`${axisIdName}\`` : `The ${axisName} with id "${axisId}"`;
8
8
  };
9
- export function checkScaleErrors(verticalLayout, seriesId, xAxisKey, xAxis, yAxisKey, yAxis) {
10
- const xAxisConfig = xAxis[xAxisKey];
11
- const yAxisConfig = yAxis[yAxisKey];
9
+ export function checkScaleErrors(verticalLayout, seriesId, xAxisId, xAxis, yAxisId, yAxis) {
10
+ const xAxisConfig = xAxis[xAxisId];
11
+ const yAxisConfig = yAxis[yAxisId];
12
12
  const discreteAxisConfig = verticalLayout ? xAxisConfig : yAxisConfig;
13
13
  const continuousAxisConfig = verticalLayout ? yAxisConfig : xAxisConfig;
14
- const discreteAxisKey = verticalLayout ? xAxisKey : yAxisKey;
15
- const continuousAxisKey = verticalLayout ? yAxisKey : xAxisKey;
14
+ const discreteAxisId = verticalLayout ? xAxisId : yAxisId;
15
+ const continuousAxisId = verticalLayout ? yAxisId : xAxisId;
16
16
  const discreteAxisDirection = verticalLayout ? 'x' : 'y';
17
17
  const continuousAxisDirection = verticalLayout ? 'y' : 'x';
18
18
  if (!isBandScaleConfig(discreteAxisConfig)) {
19
- throw new Error(`MUI X Charts: ${getAxisMessage(discreteAxisDirection, discreteAxisKey)} should be of type "band" to display the bar series of id "${seriesId}".`);
19
+ throw new Error(`MUI X: ${getAxisMessage(discreteAxisDirection, discreteAxisId)} should be of type "band" to display the bar series of id "${seriesId}".`);
20
20
  }
21
21
  if (discreteAxisConfig.data === undefined) {
22
- throw new Error(`MUI X Charts: ${getAxisMessage(discreteAxisDirection, discreteAxisKey)} should have data property.`);
22
+ throw new Error(`MUI X: ${getAxisMessage(discreteAxisDirection, discreteAxisId)} should have data property.`);
23
23
  }
24
24
  if (isBandScaleConfig(continuousAxisConfig) || isPointScaleConfig(continuousAxisConfig)) {
25
- throw new Error(`MUI X Charts: ${getAxisMessage(continuousAxisDirection, continuousAxisKey)} should be a continuous type to display the bar series of id "${seriesId}".`);
25
+ throw new Error(`MUI X: ${getAxisMessage(continuousAxisDirection, continuousAxisId)} should be a continuous type to display the bar series of id "${seriesId}".`);
26
26
  }
27
27
  }
@@ -12,7 +12,10 @@ const getValueExtremum = params => {
12
12
  axis,
13
13
  isDefaultAxis
14
14
  } = params;
15
- return Object.keys(series).filter(seriesId => series[seriesId].yAxisKey === axis.id || isDefaultAxis && series[seriesId].yAxisKey === undefined).reduce((acc, seriesId) => {
15
+ return Object.keys(series).filter(seriesId => {
16
+ const yAxisId = series[seriesId].yAxisId ?? series[seriesId].yAxisKey;
17
+ return yAxisId === axis.id || isDefaultAxis && yAxisId === undefined;
18
+ }).reduce((acc, seriesId) => {
16
19
  const [seriesMin, seriesMax] = series[seriesId].stackedData?.reduce((seriesAcc, values) => [Math.min(...values, ...(seriesAcc[0] === null ? [] : [seriesAcc[0]])), Math.max(...values, ...(seriesAcc[1] === null ? [] : [seriesAcc[1]]))], series[seriesId].stackedData[0]) ?? [null, null];
17
20
  return [acc[0] === null ? seriesMin : Math.min(seriesMin, acc[0]), acc[1] === null ? seriesMax : Math.max(seriesMax, acc[1])];
18
21
  }, [null, null]);