@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
@@ -12,55 +12,44 @@ exports.usePointerType = usePointerType;
12
12
  exports.utcFormatter = utcFormatter;
13
13
  var React = _interopRequireWildcard(require("react"));
14
14
  var _useMediaQuery = _interopRequireDefault(require("@mui/material/useMediaQuery"));
15
+ var _ChartProvider = require("../context/ChartProvider");
15
16
  var _hooks = require("../hooks");
16
17
  /**
17
18
  * @deprecated We recommend using vanilla JS to let popper track mouse position.
18
19
  */
19
20
  function useMouseTracker() {
20
- const svgRef = (0, _hooks.useSvgRef)();
21
+ const {
22
+ instance
23
+ } = (0, _ChartProvider.useChartContext)();
21
24
 
22
25
  // Use a ref to avoid rerendering on every mousemove event.
23
26
  const [mousePosition, setMousePosition] = React.useState(null);
24
27
  React.useEffect(() => {
25
- const element = svgRef.current;
26
- if (element === null) {
27
- return () => {};
28
- }
29
- const controller = new AbortController();
30
- const handleOut = event => {
31
- if (event.pointerType !== 'mouse') {
28
+ const moveEndHandler = instance.addInteractionListener('moveEnd', event => {
29
+ if (!event.detail.activeGestures.pan) {
32
30
  setMousePosition(null);
33
31
  }
34
- };
35
- const handleMove = event => {
32
+ });
33
+ const gestureHandler = event => {
36
34
  setMousePosition({
37
- x: event.clientX,
38
- y: event.clientY,
39
- height: event.height,
40
- pointerType: event.pointerType
35
+ x: event.detail.centroid.x,
36
+ y: event.detail.centroid.y,
37
+ height: event.detail.srcEvent.height,
38
+ pointerType: event.detail.srcEvent.pointerType
41
39
  });
42
40
  };
43
- element.addEventListener('pointerdown', handleMove, {
44
- signal: controller.signal
45
- });
46
- element.addEventListener('pointermove', handleMove, {
47
- signal: controller.signal
48
- });
49
- element.addEventListener('pointerup', handleOut, {
50
- signal: controller.signal
51
- });
41
+ const moveHandler = instance.addInteractionListener('move', gestureHandler);
42
+ const panHandler = instance.addInteractionListener('pan', gestureHandler);
52
43
  return () => {
53
- // Calling `.abort()` removes ALL event listeners
54
- // For more info, see https://kettanaito.com/blog/dont-sleep-on-abort-controller
55
- controller.abort();
44
+ moveHandler.cleanup();
45
+ panHandler.cleanup();
46
+ moveEndHandler.cleanup();
56
47
  };
57
- }, [svgRef]);
48
+ }, [instance]);
58
49
  return mousePosition;
59
50
  }
60
51
  function usePointerType() {
61
52
  const svgRef = (0, _hooks.useSvgRef)();
62
-
63
- // Use a ref to avoid rerendering on every mousemove event.
64
53
  const [pointerType, setPointerType] = React.useState(null);
65
54
  React.useEffect(() => {
66
55
  const element = svgRef.current;
@@ -3,7 +3,7 @@ import { ChartsSurfaceProps } from "../ChartsSurface/index.js";
3
3
  import { GaugeProviderProps } from "./GaugeProvider.js";
4
4
  import { MergeSignaturesProperty } from "../internals/plugins/models/index.js";
5
5
  import { ChartCorePluginSignatures } from "../internals/plugins/corePlugins/index.js";
6
- export interface GaugeContainerProps extends Omit<ChartsSurfaceProps, 'children'>, Omit<MergeSignaturesProperty<ChartCorePluginSignatures, 'params'>, 'series' | 'dataset' | 'colors' | 'theme'>, Omit<GaugeProviderProps, 'children'>, Omit<React.SVGProps<SVGSVGElement>, 'width' | 'height'> {
6
+ export interface GaugeContainerProps extends Omit<ChartsSurfaceProps, 'children'>, Omit<MergeSignaturesProperty<ChartCorePluginSignatures, 'params'>, 'series' | 'dataset' | 'colors' | 'theme' | 'experimentalFeatures'>, Omit<GaugeProviderProps, 'children'>, Omit<React.SVGProps<SVGSVGElement>, 'width' | 'height'> {
7
7
  children?: React.ReactNode;
8
8
  }
9
9
  declare const GaugeContainer: React.ForwardRefExoticComponent<Omit<GaugeContainerProps, "ref"> & React.RefAttributes<SVGSVGElement>>;
@@ -7,22 +7,16 @@ Object.defineProperty(exports, "__esModule", {
7
7
  value: true
8
8
  });
9
9
  exports.AreaPlot = AreaPlot;
10
- var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
11
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
+ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
12
12
  var React = _interopRequireWildcard(require("react"));
13
13
  var _propTypes = _interopRequireDefault(require("prop-types"));
14
14
  var _styles = require("@mui/material/styles");
15
- var _d3Shape = require("@mui/x-charts-vendor/d3-shape");
16
15
  var _AreaElement = require("./AreaElement");
17
- var _useScale = require("../hooks/useScale");
18
- var _getCurve = require("../internals/getCurve");
19
- var _isBandScale = require("../internals/isBandScale");
20
- var _constants = require("../constants");
21
- var _useLineSeries = require("../hooks/useLineSeries");
22
16
  var _useSkipAnimation = require("../hooks/useSkipAnimation");
23
- var _useChartGradientId = require("../hooks/useChartGradientId");
24
17
  var _useAxis = require("../hooks/useAxis");
25
18
  var _useInternalIsZoomInteracting = require("../internals/plugins/featurePlugins/useChartCartesianAxis/useInternalIsZoomInteracting");
19
+ var _useAreaPlotData = require("./useAreaPlotData");
26
20
  var _jsxRuntime = require("react/jsx-runtime");
27
21
  const _excluded = ["slots", "slotProps", "onItemClick", "skipAnimation"];
28
22
  const AreaPlotRoot = (0, _styles.styled)('g', {
@@ -34,117 +28,13 @@ const AreaPlotRoot = (0, _styles.styled)('g', {
34
28
  }
35
29
  });
36
30
  const useAggregatedData = () => {
37
- const seriesData = (0, _useLineSeries.useLineSeriesContext)();
38
31
  const {
39
- xAxis,
40
- xAxisIds
32
+ xAxis: xAxes
41
33
  } = (0, _useAxis.useXAxes)();
42
34
  const {
43
- yAxis,
44
- yAxisIds
35
+ yAxis: yAxes
45
36
  } = (0, _useAxis.useYAxes)();
46
- const getGradientId = (0, _useChartGradientId.useChartGradientIdBuilder)();
47
-
48
- // This memo prevents odd line chart behavior when hydrating.
49
- const allData = React.useMemo(() => {
50
- if (seriesData === undefined) {
51
- return [];
52
- }
53
- const {
54
- series,
55
- stackingGroups
56
- } = seriesData;
57
- const defaultXAxisId = xAxisIds[0];
58
- const defaultYAxisId = yAxisIds[0];
59
- return stackingGroups.flatMap(({
60
- ids: groupIds
61
- }) => {
62
- return [...groupIds].reverse() // Revert stacked area for a more pleasant animation
63
- .map(seriesId => {
64
- const {
65
- xAxisId = defaultXAxisId,
66
- yAxisId = defaultYAxisId,
67
- stackedData,
68
- data,
69
- connectNulls,
70
- baseline,
71
- curve,
72
- strictStepCurve
73
- } = series[seriesId];
74
- const xScale = xAxis[xAxisId].scale;
75
- const xPosition = (0, _useScale.getValueToPositionMapper)(xScale);
76
- const yScale = yAxis[yAxisId].scale;
77
- const xData = xAxis[xAxisId].data;
78
- const gradientId = yAxis[yAxisId].colorScale && getGradientId(yAxisId) || xAxis[xAxisId].colorScale && getGradientId(xAxisId) || undefined;
79
- if (process.env.NODE_ENV !== 'production') {
80
- if (xData === undefined) {
81
- 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.`);
82
- }
83
- if (xData.length < stackedData.length) {
84
- throw new Error(`MUI X Charts: The data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items).`);
85
- }
86
- }
87
- const shouldExpand = curve?.includes('step') && !strictStepCurve && (0, _isBandScale.isBandScale)(xScale);
88
- const formattedData = xData?.flatMap((x, index) => {
89
- const nullData = data[index] == null;
90
- if (shouldExpand) {
91
- const rep = [{
92
- x,
93
- y: stackedData[index],
94
- nullData,
95
- isExtension: false
96
- }];
97
- if (!nullData && (index === 0 || data[index - 1] == null)) {
98
- rep.unshift({
99
- x: (xScale(x) ?? 0) - (xScale.step() - xScale.bandwidth()) / 2,
100
- y: stackedData[index],
101
- nullData,
102
- isExtension: true
103
- });
104
- }
105
- if (!nullData && (index === data.length - 1 || data[index + 1] == null)) {
106
- rep.push({
107
- x: (xScale(x) ?? 0) + (xScale.step() + xScale.bandwidth()) / 2,
108
- y: stackedData[index],
109
- nullData,
110
- isExtension: true
111
- });
112
- }
113
- return rep;
114
- }
115
- return {
116
- x,
117
- y: stackedData[index],
118
- nullData
119
- };
120
- }) ?? [];
121
- const d3Data = connectNulls ? formattedData.filter(d => !d.nullData) : formattedData;
122
- const areaPath = (0, _d3Shape.area)().x(d => d.isExtension ? d.x : xPosition(d.x)).defined(d => connectNulls || !d.nullData || !!d.isExtension).y0(d => {
123
- if (typeof baseline === 'number') {
124
- return yScale(baseline);
125
- }
126
- if (baseline === 'max') {
127
- return yScale.range()[1];
128
- }
129
- if (baseline === 'min') {
130
- return yScale.range()[0];
131
- }
132
- const value = d.y && yScale(d.y[0]);
133
- if (Number.isNaN(value)) {
134
- return yScale.range()[0];
135
- }
136
- return value;
137
- }).y1(d => d.y && yScale(d.y[1]));
138
- const d = areaPath.curve((0, _getCurve.getCurveFactory)(curve))(d3Data) || '';
139
- return (0, _extends2.default)({}, series[seriesId], {
140
- gradientId,
141
- d,
142
- seriesId
143
- });
144
- });
145
- });
146
- }, [seriesData, xAxisIds, yAxisIds, xAxis, yAxis, getGradientId]);
147
- return allData;
37
+ return (0, _useAreaPlotData.useAreaPlotData)(xAxes, yAxes);
148
38
  };
149
39
 
150
40
  /**
@@ -118,6 +118,12 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
118
118
  * If `true`, render the line highlight item.
119
119
  */
120
120
  disableLineItemHighlight: _propTypes.default.bool,
121
+ /**
122
+ * Options to enable features planned for the next major.
123
+ */
124
+ experimentalFeatures: _propTypes.default.shape({
125
+ preferStrictDomainInLineCharts: _propTypes.default.bool
126
+ }),
121
127
  /**
122
128
  * Option to display a cartesian grid in the background.
123
129
  */
@@ -133,6 +139,14 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
133
139
  * If `true`, the legend is not rendered.
134
140
  */
135
141
  hideLegend: _propTypes.default.bool,
142
+ /**
143
+ * The controlled axis highlight.
144
+ * Identified by the axis id, and data index.
145
+ */
146
+ highlightedAxis: _propTypes.default.arrayOf(_propTypes.default.shape({
147
+ axisId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
148
+ dataIndex: _propTypes.default.number.isRequired
149
+ })),
136
150
  /**
137
151
  * The highlighted item.
138
152
  * Used when the highlight is controlled.
@@ -184,6 +198,14 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
184
198
  * @param {HighlightItemData | null} highlightedItem The newly highlighted item.
185
199
  */
186
200
  onHighlightChange: _propTypes.default.func,
201
+ /**
202
+ * The function called when the pointer position corresponds to a new axis data item.
203
+ * This update can either be caused by a pointer movement, or an axis update.
204
+ * In case of multiple axes, the function is called if at least one axis is updated.
205
+ * The argument contains the identifier for all axes with a `data` property.
206
+ * @param {AxisItemIdentifier[]} axisItems The array of axes item identifiers.
207
+ */
208
+ onHighlightedAxisChange: _propTypes.default.func,
187
209
  /**
188
210
  * Callback fired when a line element is clicked.
189
211
  */
@@ -52,8 +52,8 @@ function LineHighlightPlot(props) {
52
52
  instance
53
53
  } = (0, _ChartProvider.useChartContext)();
54
54
  const store = (0, _useStore.useStore)();
55
- const highlightedIndex = (0, _useSelector.useSelector)(store, _useChartCartesianAxis.selectorChartsInteractionXAxisIndex);
56
- if (highlightedIndex === null) {
55
+ const highlightedIndexes = (0, _useSelector.useSelector)(store, _useChartCartesianAxis.selectorChartsHighlightXAxisIndex);
56
+ if (highlightedIndexes.length === 0) {
57
57
  return null;
58
58
  }
59
59
  if (seriesData === undefined) {
@@ -67,7 +67,10 @@ function LineHighlightPlot(props) {
67
67
  const defaultYAxisId = yAxisIds[0];
68
68
  const Element = slots?.lineHighlight ?? _LineHighlightElement.LineHighlightElement;
69
69
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("g", (0, _extends2.default)({}, other, {
70
- children: stackingGroups.flatMap(({
70
+ children: highlightedIndexes.flatMap(({
71
+ dataIndex: highlightedIndex,
72
+ axisId: highlightedAxisId
73
+ }) => stackingGroups.flatMap(({
71
74
  ids: groupIds
72
75
  }) => {
73
76
  return groupIds.flatMap(seriesId => {
@@ -82,6 +85,9 @@ function LineHighlightPlot(props) {
82
85
  if (disableHighlight || data[highlightedIndex] == null) {
83
86
  return null;
84
87
  }
88
+ if (highlightedAxisId !== xAxisId) {
89
+ return null;
90
+ }
85
91
  const xScale = (0, _useScale.getValueToPositionMapper)(xAxis[xAxisId].scale);
86
92
  const yScale = yAxis[yAxisId].scale;
87
93
  const xData = xAxis[xAxisId].data;
@@ -103,7 +109,7 @@ function LineHighlightPlot(props) {
103
109
  shape: shape
104
110
  }, slotProps?.lineHighlight), `${seriesId}`);
105
111
  });
106
- })
112
+ }))
107
113
  }));
108
114
  }
109
115
  process.env.NODE_ENV !== "production" ? LineHighlightPlot.propTypes = {
@@ -7,23 +7,16 @@ Object.defineProperty(exports, "__esModule", {
7
7
  value: true
8
8
  });
9
9
  exports.LinePlot = LinePlot;
10
- var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
11
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
+ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
12
12
  var React = _interopRequireWildcard(require("react"));
13
13
  var _propTypes = _interopRequireDefault(require("prop-types"));
14
14
  var _styles = require("@mui/material/styles");
15
- var _warning = require("@mui/x-internals/warning");
16
- var _d3Shape = require("@mui/x-charts-vendor/d3-shape");
17
15
  var _LineElement = require("./LineElement");
18
- var _useScale = require("../hooks/useScale");
19
- var _getCurve = require("../internals/getCurve");
20
- var _isBandScale = require("../internals/isBandScale");
21
- var _constants = require("../constants");
22
- var _useLineSeries = require("../hooks/useLineSeries");
23
16
  var _useSkipAnimation = require("../hooks/useSkipAnimation");
24
- var _useChartGradientId = require("../hooks/useChartGradientId");
25
17
  var _hooks = require("../hooks");
26
18
  var _useInternalIsZoomInteracting = require("../internals/plugins/featurePlugins/useChartCartesianAxis/useInternalIsZoomInteracting");
19
+ var _useLinePlotData = require("./useLinePlotData");
27
20
  var _jsxRuntime = require("react/jsx-runtime");
28
21
  const _excluded = ["slots", "slotProps", "skipAnimation", "onItemClick"];
29
22
  const LinePlotRoot = (0, _styles.styled)('g', {
@@ -35,100 +28,13 @@ const LinePlotRoot = (0, _styles.styled)('g', {
35
28
  }
36
29
  });
37
30
  const useAggregatedData = () => {
38
- const seriesData = (0, _useLineSeries.useLineSeriesContext)();
39
31
  const {
40
- xAxis,
41
- xAxisIds
32
+ xAxis: xAxes
42
33
  } = (0, _hooks.useXAxes)();
43
34
  const {
44
- yAxis,
45
- yAxisIds
35
+ yAxis: yAxes
46
36
  } = (0, _hooks.useYAxes)();
47
- const getGradientId = (0, _useChartGradientId.useChartGradientIdBuilder)();
48
-
49
- // This memo prevents odd line chart behavior when hydrating.
50
- const allData = React.useMemo(() => {
51
- if (seriesData === undefined) {
52
- return [];
53
- }
54
- const {
55
- series,
56
- stackingGroups
57
- } = seriesData;
58
- const defaultXAxisId = xAxisIds[0];
59
- const defaultYAxisId = yAxisIds[0];
60
- return stackingGroups.flatMap(({
61
- ids: groupIds
62
- }) => {
63
- return groupIds.flatMap(seriesId => {
64
- const {
65
- xAxisId = defaultXAxisId,
66
- yAxisId = defaultYAxisId,
67
- stackedData,
68
- data,
69
- connectNulls,
70
- curve,
71
- strictStepCurve
72
- } = series[seriesId];
73
- const xScale = xAxis[xAxisId].scale;
74
- const xPosition = (0, _useScale.getValueToPositionMapper)(xScale);
75
- const yScale = yAxis[yAxisId].scale;
76
- const xData = xAxis[xAxisId].data;
77
- const gradientId = yAxis[yAxisId].colorScale && getGradientId(yAxisId) || xAxis[xAxisId].colorScale && getGradientId(xAxisId) || undefined;
78
- if (process.env.NODE_ENV !== 'production') {
79
- if (xData === undefined) {
80
- 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.`);
81
- }
82
- if (xData.length < stackedData.length) {
83
- (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');
84
- }
85
- }
86
- const shouldExpand = curve?.includes('step') && !strictStepCurve && (0, _isBandScale.isBandScale)(xScale);
87
- const formattedData = xData?.flatMap((x, index) => {
88
- const nullData = data[index] == null;
89
- if (shouldExpand) {
90
- const rep = [{
91
- x,
92
- y: stackedData[index],
93
- nullData,
94
- isExtension: false
95
- }];
96
- if (!nullData && (index === 0 || data[index - 1] == null)) {
97
- rep.unshift({
98
- x: (xScale(x) ?? 0) - (xScale.step() - xScale.bandwidth()) / 2,
99
- y: stackedData[index],
100
- nullData,
101
- isExtension: true
102
- });
103
- }
104
- if (!nullData && (index === data.length - 1 || data[index + 1] == null)) {
105
- rep.push({
106
- x: (xScale(x) ?? 0) + (xScale.step() + xScale.bandwidth()) / 2,
107
- y: stackedData[index],
108
- nullData,
109
- isExtension: true
110
- });
111
- }
112
- return rep;
113
- }
114
- return {
115
- x,
116
- y: stackedData[index],
117
- nullData
118
- };
119
- }) ?? [];
120
- const d3Data = connectNulls ? formattedData.filter(d => !d.nullData) : formattedData;
121
- 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]));
122
- const d = linePath.curve((0, _getCurve.getCurveFactory)(curve))(d3Data) || '';
123
- return (0, _extends2.default)({}, series[seriesId], {
124
- gradientId,
125
- d,
126
- seriesId
127
- });
128
- });
129
- });
130
- }, [seriesData, xAxisIds, yAxisIds, xAxis, yAxis, getGradientId]);
131
- return allData;
37
+ return (0, _useLinePlotData.useLinePlotData)(xAxes, yAxes);
132
38
  };
133
39
 
134
40
  /**
@@ -11,7 +11,6 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
11
11
  var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
12
12
  var _propTypes = _interopRequireDefault(require("prop-types"));
13
13
  var React = _interopRequireWildcard(require("react"));
14
- var _useChartCartesianInteraction = require("../internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors");
15
14
  var _constants = require("../constants");
16
15
  var _useSkipAnimation = require("../hooks/useSkipAnimation");
17
16
  var _useChartId = require("../hooks/useChartId");
@@ -24,6 +23,7 @@ var _MarkElement = require("./MarkElement");
24
23
  var _ChartProvider = require("../context/ChartProvider");
25
24
  var _hooks = require("../hooks");
26
25
  var _useInternalIsZoomInteracting = require("../internals/plugins/featurePlugins/useChartCartesianAxis/useInternalIsZoomInteracting");
26
+ var _useChartCartesianAxis = require("../internals/plugins/featurePlugins/useChartCartesianAxis");
27
27
  var _useSelector = require("../internals/store/useSelector");
28
28
  var _jsxRuntime = require("react/jsx-runtime");
29
29
  const _excluded = ["slots", "slotProps", "skipAnimation", "onItemClick"];
@@ -65,7 +65,21 @@ function MarkPlot(props) {
65
65
  isFaded,
66
66
  isHighlighted
67
67
  } = (0, _hooks.useItemHighlightedGetter)();
68
- const xAxisInteractionIndex = (0, _useSelector.useSelector)(store, _useChartCartesianInteraction.selectorChartsInteractionXAxisIndex);
68
+ const xAxisHighlightIndexes = (0, _useSelector.useSelector)(store, _useChartCartesianAxis.selectorChartsHighlightXAxisIndex);
69
+ const highlightedItems = React.useMemo(() => {
70
+ const rep = {};
71
+ for (const {
72
+ dataIndex,
73
+ axisId
74
+ } of xAxisHighlightIndexes) {
75
+ if (rep[axisId] === undefined) {
76
+ rep[axisId] = new Set([dataIndex]);
77
+ } else {
78
+ rep[axisId].add(dataIndex);
79
+ }
80
+ }
81
+ return rep;
82
+ }, [xAxisHighlightIndexes]);
69
83
  if (seriesData === undefined) {
70
84
  return null;
71
85
  }
@@ -163,7 +177,7 @@ function MarkPlot(props) {
163
177
  seriesId,
164
178
  dataIndex: index
165
179
  })),
166
- isHighlighted: xAxisInteractionIndex === index || isSeriesHighlighted,
180
+ isHighlighted: highlightedItems[xAxisId]?.has(index) || isSeriesHighlighted,
167
181
  isFaded: isSeriesFaded
168
182
  }, slotProps?.mark), `${seriesId}-${index}`);
169
183
  })
@@ -0,0 +1,12 @@
1
+ import { ComputedAxisConfig } from "../internals/plugins/featurePlugins/useChartCartesianAxis/index.js";
2
+ import { ChartsXAxisProps, ChartsYAxisProps } from "../models/index.js";
3
+ import { SeriesId } from "../models/seriesType/common.js";
4
+ interface AreaPlotDataPoint {
5
+ d: string;
6
+ seriesId: SeriesId;
7
+ color: string;
8
+ area?: boolean;
9
+ gradientId?: string;
10
+ }
11
+ export declare function useAreaPlotData(xAxes: ComputedAxisConfig<ChartsXAxisProps>, yAxes: ComputedAxisConfig<ChartsYAxisProps>): AreaPlotDataPoint[];
12
+ export {};
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.useAreaPlotData = useAreaPlotData;
8
+ var React = _interopRequireWildcard(require("react"));
9
+ var _d3Shape = require("@mui/x-charts-vendor/d3-shape");
10
+ var _useChartGradientId = require("../hooks/useChartGradientId");
11
+ var _isBandScale = require("../internals/isBandScale");
12
+ var _getCurve = require("../internals/getCurve");
13
+ var _hooks = require("../hooks");
14
+ var _constants = require("../constants");
15
+ function useAreaPlotData(xAxes, yAxes) {
16
+ const seriesData = (0, _hooks.useLineSeriesContext)();
17
+ const defaultXAxisId = (0, _hooks.useXAxes)().xAxisIds[0];
18
+ const defaultYAxisId = (0, _hooks.useYAxes)().yAxisIds[0];
19
+ const getGradientId = (0, _useChartGradientId.useChartGradientIdBuilder)();
20
+
21
+ // This memo prevents odd line chart behavior when hydrating.
22
+ const allData = React.useMemo(() => {
23
+ if (seriesData === undefined) {
24
+ return [];
25
+ }
26
+ const {
27
+ series,
28
+ stackingGroups
29
+ } = seriesData;
30
+ const areaPlotData = [];
31
+ for (const stackingGroup of stackingGroups) {
32
+ const groupIds = stackingGroup.ids;
33
+ for (let i = groupIds.length - 1; i >= 0; i -= 1) {
34
+ const seriesId = groupIds[i];
35
+ const {
36
+ xAxisId = defaultXAxisId,
37
+ yAxisId = defaultYAxisId,
38
+ stackedData,
39
+ data,
40
+ connectNulls,
41
+ baseline,
42
+ curve,
43
+ strictStepCurve,
44
+ area
45
+ } = series[seriesId];
46
+ if (!area || !(xAxisId in xAxes) || !(yAxisId in yAxes)) {
47
+ continue;
48
+ }
49
+ const xScale = xAxes[xAxisId].scale;
50
+ const xPosition = (0, _hooks.getValueToPositionMapper)(xScale);
51
+ const yScale = yAxes[yAxisId].scale;
52
+ const xData = xAxes[xAxisId].data;
53
+ const gradientId = yAxes[yAxisId].colorScale && getGradientId(yAxisId) || xAxes[xAxisId].colorScale && getGradientId(xAxisId) || undefined;
54
+ if (process.env.NODE_ENV !== 'production') {
55
+ if (xData === undefined) {
56
+ 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.`);
57
+ }
58
+ if (xData.length < stackedData.length) {
59
+ throw new Error(`MUI X Charts: The data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items).`);
60
+ }
61
+ }
62
+ const shouldExpand = curve?.includes('step') && !strictStepCurve && (0, _isBandScale.isBandScale)(xScale);
63
+ const formattedData = xData?.flatMap((x, index) => {
64
+ const nullData = data[index] == null;
65
+ if (shouldExpand) {
66
+ const rep = [{
67
+ x,
68
+ y: stackedData[index],
69
+ nullData,
70
+ isExtension: false
71
+ }];
72
+ if (!nullData && (index === 0 || data[index - 1] == null)) {
73
+ rep.unshift({
74
+ x: (xScale(x) ?? 0) - (xScale.step() - xScale.bandwidth()) / 2,
75
+ y: stackedData[index],
76
+ nullData,
77
+ isExtension: true
78
+ });
79
+ }
80
+ if (!nullData && (index === data.length - 1 || data[index + 1] == null)) {
81
+ rep.push({
82
+ x: (xScale(x) ?? 0) + (xScale.step() + xScale.bandwidth()) / 2,
83
+ y: stackedData[index],
84
+ nullData,
85
+ isExtension: true
86
+ });
87
+ }
88
+ return rep;
89
+ }
90
+ return {
91
+ x,
92
+ y: stackedData[index],
93
+ nullData
94
+ };
95
+ }) ?? [];
96
+ const d3Data = connectNulls ? formattedData.filter(d => !d.nullData) : formattedData;
97
+ const areaPath = (0, _d3Shape.area)().x(d => d.isExtension ? d.x : xPosition(d.x)).defined(d => connectNulls || !d.nullData || !!d.isExtension).y0(d => {
98
+ if (typeof baseline === 'number') {
99
+ return yScale(baseline);
100
+ }
101
+ if (baseline === 'max') {
102
+ return yScale.range()[1];
103
+ }
104
+ if (baseline === 'min') {
105
+ return yScale.range()[0];
106
+ }
107
+ const value = d.y && yScale(d.y[0]);
108
+ if (Number.isNaN(value)) {
109
+ return yScale.range()[0];
110
+ }
111
+ return value;
112
+ }).y1(d => d.y && yScale(d.y[1]));
113
+ const d = areaPath.curve((0, _getCurve.getCurveFactory)(curve))(d3Data) || '';
114
+ areaPlotData.push({
115
+ area: series[seriesId].area,
116
+ color: series[seriesId].color,
117
+ gradientId,
118
+ d,
119
+ seriesId
120
+ });
121
+ }
122
+ }
123
+ return areaPlotData;
124
+ }, [seriesData, defaultXAxisId, defaultYAxisId, xAxes, yAxes, getGradientId]);
125
+ return allData;
126
+ }
@@ -0,0 +1,11 @@
1
+ import { ComputedAxisConfig } from "../internals/plugins/featurePlugins/useChartCartesianAxis/index.js";
2
+ import { ChartsXAxisProps, ChartsYAxisProps } from "../models/index.js";
3
+ import { SeriesId } from "../models/seriesType/common.js";
4
+ interface LinePlotDataPoint {
5
+ d: string;
6
+ seriesId: SeriesId;
7
+ color: string;
8
+ gradientId?: string;
9
+ }
10
+ export declare function useLinePlotData(xAxes: ComputedAxisConfig<ChartsXAxisProps>, yAxes: ComputedAxisConfig<ChartsYAxisProps>): LinePlotDataPoint[];
11
+ export {};