@mui/x-charts 8.6.0 → 8.8.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 (254) hide show
  1. package/BarChart/BarChart.d.ts +1 -1
  2. package/BarChart/BarChart.js +16 -0
  3. package/BarChart/BarPlot.js +11 -150
  4. package/BarChart/useBarPlotData.d.ts +8 -0
  5. package/BarChart/useBarPlotData.js +146 -0
  6. package/CHANGELOG.md +202 -1
  7. package/ChartContainer/ChartContainer.d.ts +1 -21
  8. package/ChartContainer/ChartContainer.js +22 -8
  9. package/ChartContainer/index.d.ts +8 -1
  10. package/ChartContainer/useChartContainerProps.js +8 -2
  11. package/ChartDataProvider/ChartDataProvider.js +6 -0
  12. package/ChartDataProvider/useChartDataProviderProps.d.ts +1 -1
  13. package/ChartDataProvider/useChartDataProviderProps.js +6 -1
  14. package/ChartsAxisHighlight/ChartsXAxisHighlight.d.ts +1 -1
  15. package/ChartsAxisHighlight/ChartsXAxisHighlight.js +34 -24
  16. package/ChartsAxisHighlight/ChartsYAxisHighlight.d.ts +1 -1
  17. package/ChartsAxisHighlight/ChartsYAxisHighlight.js +34 -24
  18. package/ChartsReferenceLine/ChartsReferenceLine.d.ts +1 -1
  19. package/ChartsReferenceLine/ChartsXReferenceLine.d.ts +3 -0
  20. package/ChartsReferenceLine/ChartsXReferenceLine.js +48 -1
  21. package/ChartsReferenceLine/ChartsYReferenceLine.d.ts +3 -0
  22. package/ChartsReferenceLine/ChartsYReferenceLine.js +48 -1
  23. package/ChartsReferenceLine/index.d.ts +3 -1
  24. package/ChartsSurface/ChartsSurface.js +2 -1
  25. package/ChartsTooltip/ChartsTooltipContainer.js +6 -3
  26. package/ChartsTooltip/ChartsTooltipTable.d.ts +1 -1
  27. package/ChartsTooltip/utils.js +18 -29
  28. package/Gauge/GaugeContainer.d.ts +1 -1
  29. package/LineChart/AreaPlot.js +5 -115
  30. package/LineChart/LineChart.js +22 -0
  31. package/LineChart/LineHighlightPlot.js +10 -4
  32. package/LineChart/LinePlot.js +5 -99
  33. package/LineChart/MarkPlot.js +17 -3
  34. package/LineChart/useAreaPlotData.d.ts +12 -0
  35. package/LineChart/useAreaPlotData.js +126 -0
  36. package/LineChart/useLinePlotData.d.ts +11 -0
  37. package/LineChart/useLinePlotData.js +108 -0
  38. package/PieChart/PieChart.d.ts +1 -1
  39. package/RadarChart/RadarDataProvider/RadarDataProvider.d.ts +1 -1
  40. package/ScatterChart/Scatter.js +22 -48
  41. package/ScatterChart/ScatterChart.d.ts +1 -1
  42. package/ScatterChart/ScatterPlot.js +2 -2
  43. package/ScatterChart/seriesConfig/seriesProcessor.js +3 -0
  44. package/ScatterChart/useScatterPlotData.d.ts +8 -0
  45. package/ScatterChart/useScatterPlotData.js +33 -0
  46. package/SparkLineChart/SparkLineChart.d.ts +1 -1
  47. package/SparkLineChart/SparkLineChart.js +16 -0
  48. package/context/ChartApi.d.ts +22 -0
  49. package/context/ChartApi.js +5 -0
  50. package/context/ChartProvider/ChartContext.js +1 -0
  51. package/context/index.d.ts +2 -1
  52. package/context/useChartApiContext.d.ts +1 -1
  53. package/esm/BarChart/BarChart.d.ts +1 -1
  54. package/esm/BarChart/BarChart.js +16 -0
  55. package/esm/BarChart/BarPlot.js +12 -152
  56. package/esm/BarChart/useBarPlotData.d.ts +8 -0
  57. package/esm/BarChart/useBarPlotData.js +139 -0
  58. package/esm/ChartContainer/ChartContainer.d.ts +1 -21
  59. package/esm/ChartContainer/ChartContainer.js +22 -8
  60. package/esm/ChartContainer/index.d.ts +8 -1
  61. package/esm/ChartContainer/index.js +6 -1
  62. package/esm/ChartContainer/useChartContainerProps.js +8 -2
  63. package/esm/ChartDataProvider/ChartDataProvider.js +6 -0
  64. package/esm/ChartDataProvider/useChartDataProviderProps.d.ts +1 -1
  65. package/esm/ChartDataProvider/useChartDataProviderProps.js +7 -2
  66. package/esm/ChartsAxisHighlight/ChartsXAxisHighlight.d.ts +1 -1
  67. package/esm/ChartsAxisHighlight/ChartsXAxisHighlight.js +36 -26
  68. package/esm/ChartsAxisHighlight/ChartsYAxisHighlight.d.ts +1 -1
  69. package/esm/ChartsAxisHighlight/ChartsYAxisHighlight.js +36 -26
  70. package/esm/ChartsReferenceLine/ChartsReferenceLine.d.ts +1 -1
  71. package/esm/ChartsReferenceLine/ChartsXReferenceLine.d.ts +3 -0
  72. package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +47 -0
  73. package/esm/ChartsReferenceLine/ChartsYReferenceLine.d.ts +3 -0
  74. package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +47 -0
  75. package/esm/ChartsReferenceLine/index.d.ts +3 -1
  76. package/esm/ChartsReferenceLine/index.js +2 -1
  77. package/esm/ChartsSurface/ChartsSurface.js +2 -1
  78. package/esm/ChartsTooltip/ChartsTooltipContainer.js +6 -3
  79. package/esm/ChartsTooltip/ChartsTooltipTable.d.ts +1 -1
  80. package/esm/ChartsTooltip/utils.js +18 -29
  81. package/esm/Gauge/GaugeContainer.d.ts +1 -1
  82. package/esm/LineChart/AreaPlot.js +5 -115
  83. package/esm/LineChart/LineChart.js +22 -0
  84. package/esm/LineChart/LineHighlightPlot.js +11 -5
  85. package/esm/LineChart/LinePlot.js +5 -99
  86. package/esm/LineChart/MarkPlot.js +17 -3
  87. package/esm/LineChart/useAreaPlotData.d.ts +12 -0
  88. package/esm/LineChart/useAreaPlotData.js +119 -0
  89. package/esm/LineChart/useLinePlotData.d.ts +11 -0
  90. package/esm/LineChart/useLinePlotData.js +101 -0
  91. package/esm/PieChart/PieChart.d.ts +1 -1
  92. package/esm/RadarChart/RadarDataProvider/RadarDataProvider.d.ts +1 -1
  93. package/esm/ScatterChart/Scatter.js +23 -49
  94. package/esm/ScatterChart/ScatterChart.d.ts +1 -1
  95. package/esm/ScatterChart/ScatterPlot.js +2 -2
  96. package/esm/ScatterChart/seriesConfig/seriesProcessor.js +3 -0
  97. package/esm/ScatterChart/useScatterPlotData.d.ts +8 -0
  98. package/esm/ScatterChart/useScatterPlotData.js +26 -0
  99. package/esm/SparkLineChart/SparkLineChart.d.ts +1 -1
  100. package/esm/SparkLineChart/SparkLineChart.js +16 -0
  101. package/esm/context/ChartApi.d.ts +22 -0
  102. package/esm/context/ChartApi.js +1 -0
  103. package/esm/context/ChartProvider/ChartContext.js +2 -0
  104. package/esm/context/index.d.ts +2 -1
  105. package/esm/context/useChartApiContext.d.ts +1 -1
  106. package/esm/hooks/useAxis.d.ts +2 -2
  107. package/esm/hooks/useInteractionItemProps.d.ts +14 -9
  108. package/esm/hooks/useInteractionItemProps.js +28 -28
  109. package/esm/index.d.ts +2 -1
  110. package/esm/index.js +2 -2
  111. package/esm/internals/constants.d.ts +3 -0
  112. package/esm/internals/constants.js +4 -0
  113. package/esm/internals/getLabel.d.ts +1 -1
  114. package/esm/internals/index.d.ts +6 -0
  115. package/esm/internals/index.js +6 -0
  116. package/esm/internals/plugins/corePlugins/corePlugins.d.ts +4 -2
  117. package/esm/internals/plugins/corePlugins/corePlugins.js +3 -1
  118. package/esm/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.selectors.d.ts +1 -1
  119. package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.js +1 -29
  120. package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.d.ts +3 -3
  121. package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types.d.ts +0 -6
  122. package/esm/internals/plugins/corePlugins/useChartExperimentalFeature/index.d.ts +3 -0
  123. package/esm/internals/plugins/corePlugins/useChartExperimentalFeature/index.js +2 -0
  124. package/esm/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.d.ts +3 -0
  125. package/esm/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.js +27 -0
  126. package/esm/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.selectors.d.ts +8 -0
  127. package/esm/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.selectors.js +3 -0
  128. package/esm/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.d.ts +21 -0
  129. package/esm/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js +1 -0
  130. package/esm/internals/plugins/corePlugins/useChartId/useChartId.js +2 -0
  131. package/esm/internals/plugins/corePlugins/useChartId/useChartId.selectors.d.ts +1 -1
  132. package/esm/internals/plugins/corePlugins/useChartInteractionListener/index.d.ts +2 -0
  133. package/esm/internals/plugins/corePlugins/useChartInteractionListener/index.js +1 -0
  134. package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.d.ts +3 -0
  135. package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +77 -0
  136. package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.d.ts +31 -0
  137. package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.js +1 -0
  138. package/esm/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.d.ts +2 -2
  139. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.d.ts +5 -1
  140. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +4 -2
  141. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.d.ts +1 -0
  142. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.js +5 -2
  143. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisDomainLimit.d.ts +7 -0
  144. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisDomainLimit.js +14 -0
  145. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/index.d.ts +2 -0
  146. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/index.js +2 -0
  147. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.d.ts +4 -4
  148. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +90 -36
  149. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +18 -1
  150. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.d.ts +3 -0
  151. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.js +76 -0
  152. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +10 -5
  153. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +8 -5
  154. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.ts +47 -0
  155. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.js +48 -0
  156. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.d.ts +18 -12
  157. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +16 -2
  158. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/zoom.types.d.ts +6 -1
  159. package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.d.ts +5 -5
  160. package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +6 -6
  161. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +34 -34
  162. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.d.ts +5 -5
  163. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.d.ts +7 -8
  164. package/esm/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.js +47 -30
  165. package/esm/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.selectors.d.ts +1 -1
  166. package/esm/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.selectors.d.ts +1 -1
  167. package/esm/internals/plugins/utils/useLazySelectorEffect.d.ts +7 -0
  168. package/esm/internals/plugins/utils/useLazySelectorEffect.js +70 -0
  169. package/esm/internals/store/useCharts.d.ts +1 -1
  170. package/esm/locales/elGR.d.ts +19 -0
  171. package/esm/locales/elGR.js +15 -0
  172. package/esm/locales/index.d.ts +1 -0
  173. package/esm/locales/index.js +1 -0
  174. package/esm/models/axis.d.ts +15 -0
  175. package/esm/models/axis.js +4 -0
  176. package/esm/models/index.d.ts +1 -1
  177. package/esm/models/seriesType/scatter.d.ts +11 -2
  178. package/esm/themeAugmentation/components.d.ts +3 -0
  179. package/esm/themeAugmentation/props.d.ts +2 -0
  180. package/hooks/useAxis.d.ts +2 -2
  181. package/hooks/useInteractionItemProps.d.ts +14 -9
  182. package/hooks/useInteractionItemProps.js +29 -28
  183. package/index.d.ts +2 -1
  184. package/index.js +37 -11
  185. package/internals/constants.d.ts +3 -0
  186. package/internals/constants.js +5 -1
  187. package/internals/getLabel.d.ts +1 -1
  188. package/internals/index.d.ts +6 -0
  189. package/internals/index.js +52 -0
  190. package/internals/plugins/corePlugins/corePlugins.d.ts +4 -2
  191. package/internals/plugins/corePlugins/corePlugins.js +3 -1
  192. package/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.selectors.d.ts +1 -1
  193. package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.js +1 -29
  194. package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.d.ts +3 -3
  195. package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types.d.ts +0 -6
  196. package/internals/plugins/corePlugins/useChartExperimentalFeature/index.d.ts +3 -0
  197. package/internals/plugins/corePlugins/useChartExperimentalFeature/index.js +27 -0
  198. package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.d.ts +3 -0
  199. package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.js +34 -0
  200. package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.selectors.d.ts +8 -0
  201. package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.selectors.js +10 -0
  202. package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.d.ts +21 -0
  203. package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js +5 -0
  204. package/internals/plugins/corePlugins/useChartId/useChartId.js +1 -0
  205. package/internals/plugins/corePlugins/useChartId/useChartId.selectors.d.ts +1 -1
  206. package/internals/plugins/corePlugins/useChartInteractionListener/index.d.ts +2 -0
  207. package/internals/plugins/corePlugins/useChartInteractionListener/index.js +12 -0
  208. package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.d.ts +3 -0
  209. package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +84 -0
  210. package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.d.ts +31 -0
  211. package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.js +5 -0
  212. package/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.d.ts +2 -2
  213. package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.d.ts +5 -1
  214. package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +4 -2
  215. package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.d.ts +1 -0
  216. package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.js +4 -1
  217. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisDomainLimit.d.ts +7 -0
  218. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisDomainLimit.js +21 -0
  219. package/internals/plugins/featurePlugins/useChartCartesianAxis/index.d.ts +2 -0
  220. package/internals/plugins/featurePlugins/useChartCartesianAxis/index.js +24 -0
  221. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.d.ts +4 -4
  222. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +90 -36
  223. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +18 -1
  224. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.d.ts +3 -0
  225. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.js +82 -0
  226. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +10 -5
  227. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +9 -6
  228. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.ts +47 -0
  229. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.js +55 -0
  230. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.d.ts +18 -12
  231. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +18 -3
  232. package/internals/plugins/featurePlugins/useChartCartesianAxis/zoom.types.d.ts +6 -1
  233. package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.d.ts +5 -5
  234. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +6 -6
  235. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +34 -34
  236. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.d.ts +5 -5
  237. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.d.ts +7 -8
  238. package/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.js +46 -30
  239. package/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.selectors.d.ts +1 -1
  240. package/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.selectors.d.ts +1 -1
  241. package/internals/plugins/utils/useLazySelectorEffect.d.ts +7 -0
  242. package/internals/plugins/utils/useLazySelectorEffect.js +77 -0
  243. package/internals/store/useCharts.d.ts +1 -1
  244. package/locales/elGR.d.ts +19 -0
  245. package/locales/elGR.js +21 -0
  246. package/locales/index.d.ts +1 -0
  247. package/locales/index.js +11 -0
  248. package/models/axis.d.ts +15 -0
  249. package/models/axis.js +4 -0
  250. package/models/index.d.ts +1 -1
  251. package/models/seriesType/scatter.d.ts +11 -2
  252. package/package.json +4 -3
  253. package/themeAugmentation/components.d.ts +3 -0
  254. package/themeAugmentation/props.d.ts +2 -0
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.useLinePlotData = useLinePlotData;
8
+ var React = _interopRequireWildcard(require("react"));
9
+ var _warning = require("@mui/x-internals/warning");
10
+ var _d3Shape = require("@mui/x-charts-vendor/d3-shape");
11
+ var _useChartGradientId = require("../hooks/useChartGradientId");
12
+ var _isBandScale = require("../internals/isBandScale");
13
+ var _getCurve = require("../internals/getCurve");
14
+ var _hooks = require("../hooks");
15
+ var _constants = require("../constants");
16
+ function useLinePlotData(xAxes, yAxes) {
17
+ const seriesData = (0, _hooks.useLineSeriesContext)();
18
+ const defaultXAxisId = (0, _hooks.useXAxes)().xAxisIds[0];
19
+ const defaultYAxisId = (0, _hooks.useYAxes)().yAxisIds[0];
20
+ const getGradientId = (0, _useChartGradientId.useChartGradientIdBuilder)();
21
+
22
+ // This memo prevents odd line chart behavior when hydrating.
23
+ const allData = React.useMemo(() => {
24
+ if (seriesData === undefined) {
25
+ return [];
26
+ }
27
+ const {
28
+ series,
29
+ stackingGroups
30
+ } = seriesData;
31
+ const linePlotData = [];
32
+ for (const stackingGroup of stackingGroups) {
33
+ const groupIds = stackingGroup.ids;
34
+ for (const seriesId of groupIds) {
35
+ const {
36
+ xAxisId = defaultXAxisId,
37
+ yAxisId = defaultYAxisId,
38
+ stackedData,
39
+ data,
40
+ connectNulls,
41
+ curve,
42
+ strictStepCurve
43
+ } = series[seriesId];
44
+ if (!(xAxisId in xAxes) || !(yAxisId in yAxes)) {
45
+ continue;
46
+ }
47
+ const xScale = xAxes[xAxisId].scale;
48
+ const xPosition = (0, _hooks.getValueToPositionMapper)(xScale);
49
+ const yScale = yAxes[yAxisId].scale;
50
+ const xData = xAxes[xAxisId].data;
51
+ const gradientId = yAxes[yAxisId].colorScale && getGradientId(yAxisId) || xAxes[xAxisId].colorScale && getGradientId(xAxisId) || undefined;
52
+ if (process.env.NODE_ENV !== 'production') {
53
+ if (xData === undefined) {
54
+ throw new Error(`MUI X Charts: ${xAxisId === _constants.DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisId}"`} should have data property to be able to display a line plot.`);
55
+ }
56
+ if (xData.length < stackedData.length) {
57
+ (0, _warning.warnOnce)(`MUI X Charts: The data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items).`, 'error');
58
+ }
59
+ }
60
+ const shouldExpand = curve?.includes('step') && !strictStepCurve && (0, _isBandScale.isBandScale)(xScale);
61
+ const formattedData = xData?.flatMap((x, index) => {
62
+ const nullData = data[index] == null;
63
+ if (shouldExpand) {
64
+ const rep = [{
65
+ x,
66
+ y: stackedData[index],
67
+ nullData,
68
+ isExtension: false
69
+ }];
70
+ if (!nullData && (index === 0 || data[index - 1] == null)) {
71
+ rep.unshift({
72
+ x: (xScale(x) ?? 0) - (xScale.step() - xScale.bandwidth()) / 2,
73
+ y: stackedData[index],
74
+ nullData,
75
+ isExtension: true
76
+ });
77
+ }
78
+ if (!nullData && (index === data.length - 1 || data[index + 1] == null)) {
79
+ rep.push({
80
+ x: (xScale(x) ?? 0) + (xScale.step() + xScale.bandwidth()) / 2,
81
+ y: stackedData[index],
82
+ nullData,
83
+ isExtension: true
84
+ });
85
+ }
86
+ return rep;
87
+ }
88
+ return {
89
+ x,
90
+ y: stackedData[index],
91
+ nullData
92
+ };
93
+ }) ?? [];
94
+ const d3Data = connectNulls ? formattedData.filter(d => !d.nullData) : formattedData;
95
+ const linePath = (0, _d3Shape.line)().x(d => d.isExtension ? d.x : xPosition(d.x)).defined(d => connectNulls || !d.nullData || !!d.isExtension).y(d => yScale(d.y[1]));
96
+ const d = linePath.curve((0, _getCurve.getCurveFactory)(curve))(d3Data) || '';
97
+ linePlotData.push({
98
+ color: series[seriesId].color,
99
+ gradientId,
100
+ d,
101
+ seriesId
102
+ });
103
+ }
104
+ }
105
+ return linePlotData;
106
+ }, [seriesData, defaultXAxisId, defaultYAxisId, xAxes, yAxes, getGradientId]);
107
+ return allData;
108
+ }
@@ -12,7 +12,7 @@ import { ChartsOverlayProps, ChartsOverlaySlotProps, ChartsOverlaySlots } from "
12
12
  import { PieChartPluginSignatures } from "./PieChart.plugins.js";
13
13
  export interface PieChartSlots extends PiePlotSlots, ChartsLegendSlots, ChartsOverlaySlots, ChartsTooltipSlots, ChartsToolbarSlots, Partial<ChartsSlots> {}
14
14
  export interface PieChartSlotProps extends PiePlotSlotProps, ChartsLegendSlotProps, ChartsOverlaySlotProps, ChartsTooltipSlotProps, ChartsToolbarSlotProps, Partial<ChartsSlotProps> {}
15
- export interface PieChartProps extends Omit<ChartContainerProps<'pie', PieChartPluginSignatures>, 'series' | 'slots' | 'slotProps'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'>, Pick<PiePlotProps, 'skipAnimation'> {
15
+ export interface PieChartProps extends Omit<ChartContainerProps<'pie', PieChartPluginSignatures>, 'series' | 'slots' | 'slotProps' | 'experimentalFeatures'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'>, Pick<PiePlotProps, 'skipAnimation'> {
16
16
  /**
17
17
  * The series to display in the pie chart.
18
18
  * An array of [[PieSeriesType]] objects.
@@ -5,7 +5,7 @@ import { RadarSeriesType } from "../../models/seriesType/radar.js";
5
5
  import { ChartDataProviderProps } from "../../ChartDataProvider/index.js";
6
6
  import { RadarConfig } from "./radar.types.js";
7
7
  import { ChartAnyPluginSignature } from "../../internals/plugins/models/plugin.js";
8
- export type RadarDataProviderProps<TSignatures extends readonly ChartAnyPluginSignature[] = RadarChartPluginsSignatures> = Omit<ChartDataProviderProps<'radar', TSignatures>, 'series' | 'rotationAxis' | 'radiusAxis' | 'dataset'> & {
8
+ export type RadarDataProviderProps<TSignatures extends readonly ChartAnyPluginSignature[] = RadarChartPluginsSignatures> = Omit<ChartDataProviderProps<'radar', TSignatures>, 'series' | 'rotationAxis' | 'radiusAxis' | 'dataset' | 'experimentalFeatures'> & {
9
9
  /**
10
10
  * The series to display in the bar chart.
11
11
  * An array of [[RadarSeriesType]] objects.
@@ -12,15 +12,15 @@ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runt
12
12
  var React = _interopRequireWildcard(require("react"));
13
13
  var _propTypes = _interopRequireDefault(require("prop-types"));
14
14
  var _useSlotProps2 = _interopRequireDefault(require("@mui/utils/useSlotProps"));
15
- var _useScale = require("../hooks/useScale");
16
15
  var _useInteractionItemProps = require("../hooks/useInteractionItemProps");
17
16
  var _useStore = require("../internals/store/useStore");
18
17
  var _useSelector = require("../internals/store/useSelector");
19
18
  var _useItemHighlightedGetter = require("../hooks/useItemHighlightedGetter");
20
19
  var _useChartVoronoi = require("../internals/plugins/featurePlugins/useChartVoronoi");
21
- var _ChartProvider = require("../context/ChartProvider");
22
20
  var _ScatterMarker = require("./ScatterMarker");
23
21
  var _scatterClasses = require("./scatterClasses");
22
+ var _useScatterPlotData = require("./useScatterPlotData");
23
+ var _ChartProvider = require("../context/ChartProvider");
24
24
  var _jsxRuntime = require("react/jsx-runtime");
25
25
  const _excluded = ["ownerState"];
26
26
  /**
@@ -55,37 +55,7 @@ function Scatter(props) {
55
55
  isFaded,
56
56
  isHighlighted
57
57
  } = (0, _useItemHighlightedGetter.useItemHighlightedGetter)();
58
- const cleanData = React.useMemo(() => {
59
- const getXPosition = (0, _useScale.getValueToPositionMapper)(xScale);
60
- const getYPosition = (0, _useScale.getValueToPositionMapper)(yScale);
61
- const temp = [];
62
- for (let i = 0; i < series.data.length; i += 1) {
63
- const scatterPoint = series.data[i];
64
- const x = getXPosition(scatterPoint.x);
65
- const y = getYPosition(scatterPoint.y);
66
- const isInRange = instance.isPointInside(x, y);
67
- if (isInRange) {
68
- const currentItem = {
69
- seriesId: series.id,
70
- dataIndex: i
71
- };
72
- const isItemHighlighted = isHighlighted(currentItem);
73
- temp.push({
74
- x,
75
- y,
76
- isHighlighted: isItemHighlighted,
77
- isFaded: !isItemHighlighted && isFaded(currentItem),
78
- id: scatterPoint.id,
79
- seriesId: series.id,
80
- type: 'scatter',
81
- dataIndex: i,
82
- color: colorGetter ? colorGetter(i) : color
83
- });
84
- }
85
- }
86
- return temp;
87
- }, [xScale, yScale, series.data, series.id, isHighlighted, isFaded, colorGetter, color, instance]);
88
- const interactionItemProps = (0, _useInteractionItemProps.useInteractionAllItemProps)(cleanData, skipInteractionHandlers);
58
+ const scatterPlotData = (0, _useScatterPlotData.useScatterPlotData)(series, xScale, yScale, instance.isPointInside);
89
59
  const Marker = slots?.marker ?? _ScatterMarker.ScatterMarker;
90
60
  const _useSlotProps = (0, _useSlotProps2.default)({
91
61
  elementType: Marker,
@@ -101,21 +71,25 @@ function Scatter(props) {
101
71
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {
102
72
  "data-series": series.id,
103
73
  className: classes.root,
104
- children: cleanData.map((dataPoint, i) => /*#__PURE__*/(0, _jsxRuntime.jsx)(Marker, (0, _extends2.default)({
105
- dataIndex: dataPoint.dataIndex,
106
- color: dataPoint.color,
107
- isHighlighted: dataPoint.isHighlighted,
108
- isFaded: dataPoint.isFaded,
109
- x: dataPoint.x,
110
- y: dataPoint.y,
111
- onClick: onItemClick && (event => onItemClick(event, {
112
- type: 'scatter',
113
- seriesId: series.id,
114
- dataIndex: dataPoint.dataIndex
115
- })),
116
- "data-highlighted": dataPoint.isHighlighted || undefined,
117
- "data-faded": dataPoint.isFaded || undefined
118
- }, interactionItemProps[i], markerProps), dataPoint.id ?? dataPoint.dataIndex))
74
+ children: scatterPlotData.map((dataPoint, i) => {
75
+ const isItemHighlighted = isHighlighted(dataPoint);
76
+ const isItemFaded = !isItemHighlighted && isFaded(dataPoint);
77
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(Marker, (0, _extends2.default)({
78
+ dataIndex: dataPoint.dataIndex,
79
+ color: colorGetter ? colorGetter(i) : color,
80
+ isHighlighted: isItemHighlighted,
81
+ isFaded: isItemFaded,
82
+ x: dataPoint.x,
83
+ y: dataPoint.y,
84
+ onClick: onItemClick && (event => onItemClick(event, {
85
+ type: 'scatter',
86
+ seriesId: series.id,
87
+ dataIndex: dataPoint.dataIndex
88
+ })),
89
+ "data-highlighted": isItemHighlighted || undefined,
90
+ "data-faded": isItemFaded || undefined
91
+ }, skipInteractionHandlers ? undefined : (0, _useInteractionItemProps.getInteractionItemProps)(instance, dataPoint), markerProps), dataPoint.id ?? dataPoint.dataIndex);
92
+ })
119
93
  });
120
94
  }
121
95
  process.env.NODE_ENV !== "production" ? Scatter.propTypes = {
@@ -16,7 +16,7 @@ import { UseChartVoronoiSignature } from "../internals/plugins/featurePlugins/us
16
16
  import { ScatterChartPluginsSignatures } from "./ScatterChart.plugins.js";
17
17
  export interface ScatterChartSlots extends ChartsAxisSlots, ScatterPlotSlots, ChartsLegendSlots, ChartsOverlaySlots, ChartsTooltipSlots, ChartsToolbarSlots, Partial<ChartsSlots> {}
18
18
  export interface ScatterChartSlotProps extends ChartsAxisSlotProps, ScatterPlotSlotProps, ChartsLegendSlotProps, ChartsOverlaySlotProps, ChartsTooltipSlotProps, ChartsToolbarSlotProps, Partial<ChartsSlotProps> {}
19
- export interface ScatterChartProps extends Omit<ChartContainerProps<'scatter', ScatterChartPluginsSignatures>, 'series' | 'plugins' | 'onItemClick'>, Omit<ChartsAxisProps, 'slots' | 'slotProps'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'> {
19
+ export interface ScatterChartProps extends Omit<ChartContainerProps<'scatter', ScatterChartPluginsSignatures>, 'series' | 'plugins' | 'onItemClick' | 'experimentalFeatures' | 'highlightedAxis' | 'onHighlightedAxisChange'>, Omit<ChartsAxisProps, 'slots' | 'slotProps'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'> {
20
20
  /**
21
21
  * The series to display in the scatter chart.
22
22
  * An array of [[ScatterSeriesType]] objects.
@@ -12,9 +12,9 @@ var React = _interopRequireWildcard(require("react"));
12
12
  var _propTypes = _interopRequireDefault(require("prop-types"));
13
13
  var _Scatter = require("./Scatter");
14
14
  var _useScatterSeries = require("../hooks/useScatterSeries");
15
- var _getColor = _interopRequireDefault(require("./seriesConfig/getColor"));
16
15
  var _hooks = require("../hooks");
17
16
  var _useZAxis = require("../hooks/useZAxis");
17
+ var _seriesConfig = require("./seriesConfig");
18
18
  var _jsxRuntime = require("react/jsx-runtime");
19
19
  /**
20
20
  * Demos:
@@ -65,7 +65,7 @@ function ScatterPlot(props) {
65
65
  zAxisId,
66
66
  color
67
67
  } = series[seriesId];
68
- const colorGetter = (0, _getColor.default)(series[seriesId], xAxis[xAxisId ?? defaultXAxisId], yAxis[yAxisId ?? defaultYAxisId], zAxis[zAxisId ?? defaultZAxisId]);
68
+ const colorGetter = _seriesConfig.seriesConfig.colorProcessor(series[seriesId], xAxis[xAxisId ?? defaultXAxisId], yAxis[yAxisId ?? defaultYAxisId], zAxis[zAxisId ?? defaultZAxisId]);
69
69
  const xScale = xAxis[xAxisId ?? defaultXAxisId].scale;
70
70
  const yScale = yAxis[yAxisId ?? defaultYAxisId].scale;
71
71
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(ScatterItems, (0, _extends2.default)({
@@ -28,6 +28,9 @@ const seriesProcessor = ({
28
28
  labelMarkType: 'circle',
29
29
  markerSize: 4
30
30
  }, seriesData, {
31
+ preview: (0, _extends2.default)({
32
+ markerSize: 1
33
+ }, seriesData?.preview),
31
34
  data,
32
35
  valueFormatter: seriesData.valueFormatter ?? (v => v && `(${v.x}, ${v.y})`)
33
36
  })];
@@ -0,0 +1,8 @@
1
+ import { SeriesId } from "../models/seriesType/common.js";
2
+ import { D3Scale } from "../models/axis.js";
3
+ import { DefaultizedScatterSeriesType, ScatterValueType } from "../models/index.js";
4
+ export declare function useScatterPlotData(series: DefaultizedScatterSeriesType, xScale: D3Scale, yScale: D3Scale, isPointInside: (x: number, y: number) => boolean): (ScatterValueType & {
5
+ dataIndex: number;
6
+ seriesId: SeriesId;
7
+ type: "scatter";
8
+ })[];
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.useScatterPlotData = useScatterPlotData;
8
+ var React = _interopRequireWildcard(require("react"));
9
+ var _hooks = require("../hooks");
10
+ function useScatterPlotData(series, xScale, yScale, isPointInside) {
11
+ return React.useMemo(() => {
12
+ const getXPosition = (0, _hooks.getValueToPositionMapper)(xScale);
13
+ const getYPosition = (0, _hooks.getValueToPositionMapper)(yScale);
14
+ const temp = [];
15
+ for (let i = 0; i < series.data.length; i += 1) {
16
+ const scatterPoint = series.data[i];
17
+ const x = getXPosition(scatterPoint.x);
18
+ const y = getYPosition(scatterPoint.y);
19
+ const isInRange = isPointInside(x, y);
20
+ if (isInRange) {
21
+ temp.push({
22
+ x,
23
+ y,
24
+ id: scatterPoint.id,
25
+ seriesId: series.id,
26
+ type: 'scatter',
27
+ dataIndex: i
28
+ });
29
+ }
30
+ }
31
+ return temp;
32
+ }, [xScale, yScale, series.data, series.id, isPointInside]);
33
+ }
@@ -13,7 +13,7 @@ import { BarPlotSlots, BarPlotSlotProps } from "../BarChart/BarPlot.js";
13
13
  import { ChartMargin } from "../internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types.js";
14
14
  export interface SparkLineChartSlots extends AreaPlotSlots, LinePlotSlots, MarkPlotSlots, LineHighlightPlotSlots, Omit<BarPlotSlots, 'barLabel'>, ChartsTooltipSlots {}
15
15
  export interface SparkLineChartSlotProps extends AreaPlotSlotProps, LinePlotSlotProps, MarkPlotSlotProps, LineHighlightPlotSlotProps, BarPlotSlotProps, ChartsTooltipSlotProps {}
16
- export interface SparkLineChartProps extends Omit<ChartContainerProps, 'series' | 'xAxis' | 'yAxis' | 'zAxis' | 'radiusAxis' | 'rotationAxis' | 'margin' | 'plugins' | 'colors' | 'slots' | 'slotProps'> {
16
+ export interface SparkLineChartProps extends Omit<ChartContainerProps, 'series' | 'xAxis' | 'yAxis' | 'zAxis' | 'radiusAxis' | 'rotationAxis' | 'margin' | 'plugins' | 'colors' | 'slots' | 'slotProps' | 'experimentalFeatures'> {
17
17
  /**
18
18
  * The xAxis configuration.
19
19
  * Notice it is a single [[AxisConfig]] object, not an array of configuration.
@@ -213,6 +213,14 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
213
213
  * The height of the chart in px. If not defined, it takes the height of the parent element.
214
214
  */
215
215
  height: _propTypes.default.number,
216
+ /**
217
+ * The controlled axis highlight.
218
+ * Identified by the axis id, and data index.
219
+ */
220
+ highlightedAxis: _propTypes.default.arrayOf(_propTypes.default.shape({
221
+ axisId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
222
+ dataIndex: _propTypes.default.number.isRequired
223
+ })),
216
224
  /**
217
225
  * The highlighted item.
218
226
  * Used when the highlight is controlled.
@@ -256,6 +264,14 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
256
264
  * @param {HighlightItemData | null} highlightedItem The newly highlighted item.
257
265
  */
258
266
  onHighlightChange: _propTypes.default.func,
267
+ /**
268
+ * The function called when the pointer position corresponds to a new axis data item.
269
+ * This update can either be caused by a pointer movement, or an axis update.
270
+ * In case of multiple axes, the function is called if at least one axis is updated.
271
+ * The argument contains the identifier for all axes with a `data` property.
272
+ * @param {AxisItemIdentifier[]} axisItems The array of axes item identifiers.
273
+ */
274
+ onHighlightedAxisChange: _propTypes.default.func,
259
275
  /**
260
276
  * Callback fired when clicking close to an item.
261
277
  * This is only available for scatter plot for now.
@@ -0,0 +1,22 @@
1
+ import type { PieChartPluginSignatures } from "../PieChart/PieChart.plugins.js";
2
+ import type { BarChartPluginsSignatures } from "../BarChart/BarChart.plugins.js";
3
+ import type { ScatterChartPluginsSignatures } from "../ScatterChart/ScatterChart.plugins.js";
4
+ import type { LineChartPluginsSignatures } from "../LineChart/LineChart.plugins.js";
5
+ import type { AllPluginSignatures, DefaultPluginSignatures } from "../internals/plugins/allPlugins.js";
6
+ import type { ChartAnyPluginSignature } from "../internals/plugins/models/plugin.js";
7
+ import type { ChartPublicAPI } from "../internals/plugins/models/index.js";
8
+ export type PluginsPerSeriesType = {
9
+ line: LineChartPluginsSignatures;
10
+ scatter: ScatterChartPluginsSignatures;
11
+ bar: BarChartPluginsSignatures;
12
+ pie: PieChartPluginSignatures;
13
+ composition: DefaultPluginSignatures;
14
+ };
15
+ /**
16
+ * The API of the chart `apiRef` object.
17
+ * The chart type can be passed as the first generic parameter to narrow down the API to the specific chart type.
18
+ * @example ChartApi<'bar'>
19
+ * If the chart is being created using composition, the `composition` value can be used.
20
+ * @example ChartApi<'composition'>
21
+ */
22
+ export type ChartApi<TSeries extends keyof PluginsPerSeriesType | undefined = undefined, TSignatures extends readonly ChartAnyPluginSignature[] = (TSeries extends keyof PluginsPerSeriesType ? PluginsPerSeriesType[TSeries] : AllPluginSignatures)> = ChartPublicAPI<TSignatures>;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ 'use client';
2
3
 
3
4
  var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
5
  Object.defineProperty(exports, "__esModule", {
@@ -1,2 +1,3 @@
1
1
  export type { HighlightScope, FadeOptions, HighlightItemData, HighlightOptions } from "../internals/plugins/featurePlugins/useChartHighlight/index.js";
2
- export * from "./useChartApiContext.js";
2
+ export * from "./useChartApiContext.js";
3
+ export type { ChartApi } from "./ChartApi.js";
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { ChartApi } from "../ChartContainer/index.js";
2
+ import { ChartApi } from "./ChartApi.js";
3
3
  /**
4
4
  * The `useChartApiContext` hook provides access to the chart API.
5
5
  * This is only available when the chart is rendered within a chart or a `ChartDataProvider` component.
@@ -15,7 +15,7 @@ import { ChartsOverlayProps, ChartsOverlaySlotProps, ChartsOverlaySlots } from "
15
15
  import { BarChartPluginsSignatures } from "./BarChart.plugins.js";
16
16
  export interface BarChartSlots extends ChartsAxisSlots, BarPlotSlots, ChartsLegendSlots, ChartsOverlaySlots, ChartsTooltipSlots, ChartsToolbarSlots, Partial<ChartsSlots> {}
17
17
  export interface BarChartSlotProps extends ChartsAxisSlotProps, BarPlotSlotProps, ChartsLegendSlotProps, ChartsOverlaySlotProps, ChartsTooltipSlotProps, ChartsToolbarSlotProps, Partial<ChartsSlotProps> {}
18
- export interface BarChartProps extends Omit<ChartContainerProps<'bar', BarChartPluginsSignatures>, 'series' | 'plugins' | 'zAxis'>, Omit<ChartsAxisProps, 'slots' | 'slotProps'>, Omit<BarPlotProps, 'slots' | 'slotProps'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'> {
18
+ export interface BarChartProps extends Omit<ChartContainerProps<'bar', BarChartPluginsSignatures>, 'series' | 'plugins' | 'zAxis' | 'experimentalFeatures'>, Omit<ChartsAxisProps, 'slots' | 'slotProps'>, Omit<BarPlotProps, 'slots' | 'slotProps'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'> {
19
19
  /**
20
20
  * The series to display in the bar chart.
21
21
  * An array of [[BarSeriesType]] objects.
@@ -127,6 +127,14 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
127
127
  * If `true`, the legend is not rendered.
128
128
  */
129
129
  hideLegend: PropTypes.bool,
130
+ /**
131
+ * The controlled axis highlight.
132
+ * Identified by the axis id, and data index.
133
+ */
134
+ highlightedAxis: PropTypes.arrayOf(PropTypes.shape({
135
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
136
+ dataIndex: PropTypes.number.isRequired
137
+ })),
130
138
  /**
131
139
  * The highlighted item.
132
140
  * Used when the highlight is controlled.
@@ -179,6 +187,14 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
179
187
  * @param {HighlightItemData | null} highlightedItem The newly highlighted item.
180
188
  */
181
189
  onHighlightChange: PropTypes.func,
190
+ /**
191
+ * The function called when the pointer position corresponds to a new axis data item.
192
+ * This update can either be caused by a pointer movement, or an axis update.
193
+ * In case of multiple axes, the function is called if at least one axis is updated.
194
+ * The argument contains the identifier for all axes with a `data` property.
195
+ * @param {AxisItemIdentifier[]} axisItems The array of axes item identifiers.
196
+ */
197
+ onHighlightedAxisChange: PropTypes.func,
182
198
  /**
183
199
  * Callback fired when a bar item is clicked.
184
200
  * @param {React.MouseEvent<SVGElement, MouseEvent>} event The event source of the callback.
@@ -8,160 +8,14 @@ import PropTypes from 'prop-types';
8
8
  import { styled } from '@mui/material/styles';
9
9
  import { barElementClasses } from "./barElementClasses.js";
10
10
  import { BarElement } from "./BarElement.js";
11
- import getColor from "./seriesConfig/getColor.js";
12
- import { useChartId, useDrawingArea, useXAxes, useYAxes } from "../hooks/index.js";
11
+ import { useDrawingArea, useXAxes, useYAxes } from "../hooks/index.js";
13
12
  import { BarClipPath } from "./BarClipPath.js";
14
13
  import { BarLabelPlot } from "./BarLabel/BarLabelPlot.js";
15
- import { checkScaleErrors } from "./checkScaleErrors.js";
16
- import { useBarSeriesContext } from "../hooks/useBarSeries.js";
17
14
  import { useSkipAnimation } from "../hooks/useSkipAnimation.js";
18
15
  import { useInternalIsZoomInteracting } from "../internals/plugins/featurePlugins/useChartCartesianAxis/useInternalIsZoomInteracting.js";
16
+ import { useBarPlotData } from "./useBarPlotData.js";
19
17
  import { useUtilityClasses } from "./barClasses.js";
20
-
21
- /**
22
- * Solution of the equations
23
- * W = barWidth * N + offset * (N-1)
24
- * offset / (offset + barWidth) = r
25
- * @param bandWidth The width available to place bars.
26
- * @param numberOfGroups The number of bars to place in that space.
27
- * @param gapRatio The ratio of the gap between bars over the bar width.
28
- * @returns The bar width and the offset between bars.
29
- */
30
18
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
31
- function getBandSize({
32
- bandWidth: W,
33
- numberOfGroups: N,
34
- gapRatio: r
35
- }) {
36
- if (r === 0) {
37
- return {
38
- barWidth: W / N,
39
- offset: 0
40
- };
41
- }
42
- const barWidth = W / (N + (N - 1) * r);
43
- const offset = r * barWidth;
44
- return {
45
- barWidth,
46
- offset
47
- };
48
- }
49
- const useAggregatedData = () => {
50
- const seriesData = useBarSeriesContext() ?? {
51
- series: {},
52
- stackingGroups: [],
53
- seriesOrder: []
54
- };
55
- const drawingArea = useDrawingArea();
56
- const chartId = useChartId();
57
- const {
58
- series,
59
- stackingGroups
60
- } = seriesData;
61
- const {
62
- xAxis,
63
- xAxisIds
64
- } = useXAxes();
65
- const {
66
- yAxis,
67
- yAxisIds
68
- } = useYAxes();
69
- const defaultXAxisId = xAxisIds[0];
70
- const defaultYAxisId = yAxisIds[0];
71
- const masks = {};
72
- const data = stackingGroups.flatMap(({
73
- ids: seriesIds
74
- }, groupIndex) => {
75
- const xMin = drawingArea.left;
76
- const xMax = drawingArea.left + drawingArea.width;
77
- const yMin = drawingArea.top;
78
- const yMax = drawingArea.top + drawingArea.height;
79
- return seriesIds.map(seriesId => {
80
- const xAxisId = series[seriesId].xAxisId ?? defaultXAxisId;
81
- const yAxisId = series[seriesId].yAxisId ?? defaultYAxisId;
82
- const xAxisConfig = xAxis[xAxisId];
83
- const yAxisConfig = yAxis[yAxisId];
84
- const verticalLayout = series[seriesId].layout === 'vertical';
85
- checkScaleErrors(verticalLayout, seriesId, series[seriesId], xAxisId, xAxis, yAxisId, yAxis);
86
- const baseScaleConfig = verticalLayout ? xAxisConfig : yAxisConfig;
87
- const xScale = xAxisConfig.scale;
88
- const yScale = yAxisConfig.scale;
89
- const colorGetter = getColor(series[seriesId], xAxis[xAxisId], yAxis[yAxisId]);
90
- const bandWidth = baseScaleConfig.scale.bandwidth();
91
- const {
92
- barWidth,
93
- offset
94
- } = getBandSize({
95
- bandWidth,
96
- numberOfGroups: stackingGroups.length,
97
- gapRatio: baseScaleConfig.barGapRatio
98
- });
99
- const barOffset = groupIndex * (barWidth + offset);
100
- const {
101
- stackedData,
102
- data: currentSeriesData,
103
- layout
104
- } = series[seriesId];
105
- const seriesDataPoints = baseScaleConfig.data.map((baseValue, dataIndex) => {
106
- if (currentSeriesData[dataIndex] == null) {
107
- return null;
108
- }
109
- const values = stackedData[dataIndex];
110
- const valueCoordinates = values.map(v => verticalLayout ? yScale(v) : xScale(v));
111
- const minValueCoord = Math.round(Math.min(...valueCoordinates));
112
- const maxValueCoord = Math.round(Math.max(...valueCoordinates));
113
- const stackId = series[seriesId].stack;
114
- const result = {
115
- seriesId,
116
- dataIndex,
117
- layout,
118
- x: verticalLayout ? xScale(baseValue) + barOffset : minValueCoord,
119
- y: verticalLayout ? minValueCoord : yScale(baseValue) + barOffset,
120
- xOrigin: xScale(0) ?? 0,
121
- yOrigin: yScale(0) ?? 0,
122
- height: verticalLayout ? maxValueCoord - minValueCoord : barWidth,
123
- width: verticalLayout ? barWidth : maxValueCoord - minValueCoord,
124
- color: colorGetter(dataIndex),
125
- value: currentSeriesData[dataIndex],
126
- maskId: `${chartId}_${stackId || seriesId}_${groupIndex}_${dataIndex}`
127
- };
128
- if (result.x > xMax || result.x + result.width < xMin || result.y > yMax || result.y + result.height < yMin) {
129
- return null;
130
- }
131
- if (!masks[result.maskId]) {
132
- masks[result.maskId] = {
133
- id: result.maskId,
134
- width: 0,
135
- height: 0,
136
- hasNegative: false,
137
- hasPositive: false,
138
- layout: result.layout,
139
- xOrigin: xScale(0),
140
- yOrigin: yScale(0),
141
- x: 0,
142
- y: 0
143
- };
144
- }
145
- const mask = masks[result.maskId];
146
- mask.width = result.layout === 'vertical' ? result.width : mask.width + result.width;
147
- mask.height = result.layout === 'vertical' ? mask.height + result.height : result.height;
148
- mask.x = Math.min(mask.x === 0 ? Infinity : mask.x, result.x);
149
- mask.y = Math.min(mask.y === 0 ? Infinity : mask.y, result.y);
150
- mask.hasNegative = mask.hasNegative || (result.value ?? 0) < 0;
151
- mask.hasPositive = mask.hasPositive || (result.value ?? 0) > 0;
152
- return result;
153
- }).filter(rectangle => rectangle !== null);
154
- return {
155
- seriesId,
156
- data: seriesDataPoints
157
- };
158
- });
159
- });
160
- return {
161
- completedData: data,
162
- masksData: Object.values(masks)
163
- };
164
- };
165
19
  const BarPlotRoot = styled('g', {
166
20
  name: 'MuiBarPlot',
167
21
  slot: 'Root'
@@ -183,10 +37,6 @@ const BarPlotRoot = styled('g', {
183
37
  * - [BarPlot API](https://mui.com/x/api/charts/bar-plot/)
184
38
  */
185
39
  function BarPlot(props) {
186
- const {
187
- completedData,
188
- masksData
189
- } = useAggregatedData();
190
40
  const {
191
41
  skipAnimation: inSkipAnimation,
192
42
  onItemClick,
@@ -196,6 +46,16 @@ function BarPlot(props) {
196
46
  other = _objectWithoutPropertiesLoose(props, _excluded);
197
47
  const isZoomInteracting = useInternalIsZoomInteracting();
198
48
  const skipAnimation = useSkipAnimation(isZoomInteracting || inSkipAnimation);
49
+ const {
50
+ xAxis: xAxes
51
+ } = useXAxes();
52
+ const {
53
+ yAxis: yAxes
54
+ } = useYAxes();
55
+ const {
56
+ completedData,
57
+ masksData
58
+ } = useBarPlotData(useDrawingArea(), xAxes, yAxes);
199
59
  const withoutBorderRadius = !borderRadius || borderRadius <= 0;
200
60
  const classes = useUtilityClasses();
201
61
  return /*#__PURE__*/_jsxs(BarPlotRoot, {
@@ -0,0 +1,8 @@
1
+ import { ChartsXAxisProps, ChartsYAxisProps } from "../models/axis.js";
2
+ import { ChartDrawingArea } from "../hooks/index.js";
3
+ import { MaskData, ProcessedBarSeriesData } from "./types.js";
4
+ import { ComputedAxisConfig } from "../internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.js";
5
+ export declare function useBarPlotData(drawingArea: ChartDrawingArea, xAxes: ComputedAxisConfig<ChartsXAxisProps>, yAxes: ComputedAxisConfig<ChartsYAxisProps>): {
6
+ completedData: ProcessedBarSeriesData[];
7
+ masksData: MaskData[];
8
+ };