@mui/x-charts 8.0.0-alpha.0 → 8.0.0-alpha.2

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 (417) hide show
  1. package/BarChart/AnimatedBarElement.d.ts +15 -0
  2. package/BarChart/AnimatedBarElement.js +21 -0
  3. package/BarChart/BarChart.d.ts +4 -9
  4. package/BarChart/BarChart.js +3 -35
  5. package/BarChart/BarElement.d.ts +5 -1342
  6. package/BarChart/BarElement.js +10 -20
  7. package/BarChart/BarLabel/BarLabel.d.ts +298 -298
  8. package/BarChart/BarPlot.js +12 -2
  9. package/BarChart/useBarChartProps.d.ts +0 -2
  10. package/BarChart/useBarChartProps.js +2 -8
  11. package/CHANGELOG.md +651 -6
  12. package/ChartContainer/ChartContainer.d.ts +26 -19
  13. package/ChartContainer/ChartContainer.js +31 -25
  14. package/ChartContainer/useChartContainerProps.d.ts +5 -7
  15. package/ChartContainer/useChartContainerProps.js +12 -27
  16. package/ChartsAxis/axisClasses.js +2 -1
  17. package/ChartsAxisHighlight/ChartsAxisHighlight.d.ts +1 -17
  18. package/ChartsAxisHighlight/ChartsAxisHighlight.js +10 -96
  19. package/ChartsAxisHighlight/ChartsAxisHighlight.types.d.ts +5 -0
  20. package/ChartsAxisHighlight/ChartsAxisHighlight.types.js +1 -0
  21. package/ChartsAxisHighlight/ChartsAxisHighlightPath.d.ts +6 -0
  22. package/ChartsAxisHighlight/ChartsAxisHighlightPath.js +34 -0
  23. package/ChartsAxisHighlight/ChartsXAxisHighlight.d.ts +10 -0
  24. package/ChartsAxisHighlight/ChartsXAxisHighlight.js +53 -0
  25. package/ChartsAxisHighlight/ChartsYAxisHighlight.d.ts +10 -0
  26. package/ChartsAxisHighlight/ChartsYAxisHighlight.js +53 -0
  27. package/ChartsAxisHighlight/chartsAxisHighlightClasses.d.ts +7 -0
  28. package/ChartsAxisHighlight/chartsAxisHighlightClasses.js +6 -0
  29. package/ChartsAxisHighlight/index.d.ts +3 -0
  30. package/ChartsAxisHighlight/index.js +4 -1
  31. package/ChartsGrid/ChartsGrid.js +1 -1
  32. package/ChartsGrid/ChartsHorizontalGrid.d.ts +2 -2
  33. package/ChartsGrid/ChartsHorizontalGrid.js +3 -3
  34. package/ChartsGrid/ChartsVerticalGrid.d.ts +2 -2
  35. package/ChartsGrid/ChartsVerticalGrid.js +3 -3
  36. package/ChartsLegend/LegendPerItem.d.ts +2 -2
  37. package/ChartsLegend/chartsLegendClasses.js +2 -1
  38. package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +9 -7
  39. package/ChartsSurface/ChartsSurface.d.ts +14 -15
  40. package/ChartsSurface/ChartsSurface.js +68 -35
  41. package/ChartsTooltip/ChartTooltip.types.d.ts +15 -0
  42. package/ChartsTooltip/ChartTooltip.types.js +1 -0
  43. package/ChartsTooltip/ChartsAxisTooltipContent.d.ts +7 -39
  44. package/ChartsTooltip/ChartsAxisTooltipContent.js +83 -72
  45. package/ChartsTooltip/ChartsItemTooltipContent.d.ts +5 -28
  46. package/ChartsTooltip/ChartsItemTooltipContent.js +54 -44
  47. package/ChartsTooltip/ChartsTooltip.d.ts +3 -69
  48. package/ChartsTooltip/ChartsTooltip.js +143 -145
  49. package/ChartsTooltip/ChartsTooltipContainer.d.ts +33 -0
  50. package/ChartsTooltip/ChartsTooltipContainer.js +280 -0
  51. package/ChartsTooltip/ChartsTooltipTable.js +1 -1
  52. package/ChartsTooltip/chartsTooltipClasses.d.ts +1 -0
  53. package/ChartsTooltip/chartsTooltipClasses.js +18 -2
  54. package/ChartsTooltip/index.d.ts +3 -3
  55. package/ChartsTooltip/index.js +2 -3
  56. package/ChartsTooltip/useAxisTooltip.d.ts +2 -2
  57. package/ChartsTooltip/useAxisTooltip.js +19 -19
  58. package/ChartsTooltip/useItemTooltip.d.ts +2 -3
  59. package/ChartsTooltip/useItemTooltip.js +5 -4
  60. package/ChartsTooltip/utils.d.ts +0 -3
  61. package/ChartsTooltip/utils.js +0 -8
  62. package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +49 -36
  63. package/ChartsXAxis/ChartsXAxis.js +3 -17
  64. package/ChartsYAxis/ChartsYAxis.js +2 -17
  65. package/Gauge/Gauge.d.ts +1 -1
  66. package/Gauge/Gauge.js +0 -6
  67. package/Gauge/GaugeContainer.d.ts +3 -3
  68. package/Gauge/GaugeContainer.js +42 -76
  69. package/LineChart/AnimatedArea.d.ts +0 -1333
  70. package/LineChart/AnimatedArea.js +9 -18
  71. package/LineChart/AnimatedLine.d.ts +0 -1333
  72. package/LineChart/AnimatedLine.js +9 -20
  73. package/LineChart/AreaPlot.js +12 -2
  74. package/LineChart/CircleMarkElement.js +6 -5
  75. package/LineChart/LineChart.d.ts +4 -10
  76. package/LineChart/LineChart.js +3 -36
  77. package/LineChart/LineHighlightPlot.js +6 -5
  78. package/LineChart/LinePlot.js +12 -2
  79. package/LineChart/MarkElement.js +6 -5
  80. package/LineChart/useLineChartProps.d.ts +0 -2
  81. package/LineChart/useLineChartProps.js +2 -8
  82. package/PieChart/PieChart.d.ts +3 -9
  83. package/PieChart/PieChart.js +5 -41
  84. package/PieChart/PiePlot.js +2 -2
  85. package/PieChart/getPieCoordinates.d.ts +2 -2
  86. package/README.md +2 -2
  87. package/ScatterChart/Scatter.js +6 -5
  88. package/ScatterChart/ScatterChart.d.ts +4 -10
  89. package/ScatterChart/ScatterChart.js +5 -36
  90. package/ScatterChart/useScatterChartProps.d.ts +0 -2
  91. package/ScatterChart/useScatterChartProps.js +1 -9
  92. package/SparkLineChart/SparkLineChart.d.ts +3 -4
  93. package/SparkLineChart/SparkLineChart.js +4 -35
  94. package/context/CartesianProvider/defaultizeAxis.d.ts +9 -11
  95. package/context/ChartDataProvider/ChartDataProvider.d.ts +36 -19
  96. package/context/ChartDataProvider/ChartDataProvider.js +55 -48
  97. package/context/ChartDataProvider/useChartDataProviderProps.d.ts +25 -32
  98. package/context/ChartDataProvider/useChartDataProviderProps.js +22 -42
  99. package/context/ChartDataProvider/useDefaultizeAxis.d.ts +9 -11
  100. package/context/ChartProvider/ChartContext.d.ts +6 -0
  101. package/context/ChartProvider/ChartContext.js +8 -0
  102. package/context/ChartProvider/ChartProvider.d.ts +4 -0
  103. package/context/ChartProvider/ChartProvider.js +19 -0
  104. package/context/ChartProvider/ChartProvider.types.d.ts +24 -0
  105. package/context/ChartProvider/ChartProvider.types.js +1 -0
  106. package/context/ChartProvider/index.d.ts +3 -0
  107. package/context/ChartProvider/index.js +3 -0
  108. package/context/ChartProvider/useChartContext.d.ts +3 -0
  109. package/context/ChartProvider/useChartContext.js +11 -0
  110. package/context/{DrawingProvider.d.ts → DrawingAreaProvider/DrawingArea.types.d.ts} +3 -14
  111. package/context/DrawingAreaProvider/DrawingArea.types.js +1 -0
  112. package/context/DrawingAreaProvider/DrawingAreaContext.d.ts +3 -0
  113. package/context/DrawingAreaProvider/DrawingAreaContext.js +15 -0
  114. package/context/DrawingAreaProvider/DrawingAreaProvider.d.ts +3 -0
  115. package/{modern/context/DrawingProvider.js → context/DrawingAreaProvider/DrawingAreaProvider.js} +11 -41
  116. package/context/DrawingAreaProvider/index.d.ts +3 -0
  117. package/context/DrawingAreaProvider/index.js +3 -0
  118. package/context/InteractionSelectors.d.ts +382 -0
  119. package/context/InteractionSelectors.js +12 -0
  120. package/context/SizeProvider/Size.types.d.ts +30 -0
  121. package/context/SizeProvider/Size.types.js +1 -0
  122. package/context/SizeProvider/SizeContext.d.ts +4 -0
  123. package/context/SizeProvider/SizeContext.js +15 -0
  124. package/context/SizeProvider/SizeProvider.d.ts +11 -0
  125. package/context/SizeProvider/SizeProvider.js +26 -0
  126. package/context/SizeProvider/index.d.ts +4 -0
  127. package/context/SizeProvider/index.js +4 -0
  128. package/context/SizeProvider/useChartContainerDimensions.d.ts +9 -0
  129. package/{modern/ChartContainer → context/SizeProvider}/useChartContainerDimensions.js +16 -6
  130. package/context/SizeProvider/useSize.d.ts +5 -0
  131. package/context/SizeProvider/useSize.js +13 -0
  132. package/context/index.d.ts +2 -0
  133. package/context/index.js +2 -1
  134. package/hooks/useAxisEvents.js +32 -19
  135. package/hooks/useChartId.js +5 -6
  136. package/hooks/useDrawingArea.d.ts +2 -2
  137. package/hooks/useDrawingArea.js +2 -2
  138. package/hooks/useInteractionItemProps.js +22 -13
  139. package/hooks/useSvgRef.d.ts +1 -1
  140. package/hooks/useSvgRef.js +4 -8
  141. package/index.js +1 -1
  142. package/internals/components/ChartsAxesGradients/ChartsAxesGradients.d.ts +1 -1
  143. package/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +9 -7
  144. package/internals/computeAxisValue.d.ts +2 -2
  145. package/internals/defaultizeColor.d.ts +1 -1
  146. package/internals/index.d.ts +3 -4
  147. package/internals/index.js +3 -4
  148. package/internals/plugins/allPlugins.d.ts +1 -0
  149. package/internals/plugins/allPlugins.js +3 -0
  150. package/internals/plugins/corePlugins/corePlugins.d.ts +10 -0
  151. package/internals/plugins/corePlugins/corePlugins.js +7 -0
  152. package/internals/plugins/corePlugins/index.d.ts +2 -0
  153. package/internals/plugins/corePlugins/index.js +1 -0
  154. package/internals/plugins/corePlugins/useChartId/index.d.ts +2 -0
  155. package/internals/plugins/corePlugins/useChartId/index.js +1 -0
  156. package/internals/plugins/corePlugins/useChartId/useChartId.d.ts +3 -0
  157. package/internals/plugins/corePlugins/useChartId/useChartId.js +32 -0
  158. package/internals/plugins/corePlugins/useChartId/useChartId.selectors.d.ts +36 -0
  159. package/internals/plugins/corePlugins/useChartId/useChartId.selectors.js +9 -0
  160. package/internals/plugins/corePlugins/useChartId/useChartId.types.d.ts +20 -0
  161. package/internals/plugins/corePlugins/useChartId/useChartId.types.js +1 -0
  162. package/internals/plugins/corePlugins/useChartId/useChartId.utils.d.ts +1 -0
  163. package/internals/plugins/corePlugins/useChartId/useChartId.utils.js +5 -0
  164. package/internals/plugins/featurePlugins/useChartInteraction/index.d.ts +3 -0
  165. package/internals/plugins/featurePlugins/useChartInteraction/index.js +2 -0
  166. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.d.ts +3 -0
  167. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +73 -0
  168. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +376 -0
  169. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.js +10 -0
  170. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.types.d.ts +57 -0
  171. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.types.js +1 -0
  172. package/internals/plugins/models/chart.d.ts +14 -0
  173. package/internals/plugins/models/chart.js +1 -0
  174. package/internals/plugins/models/helpers.d.ts +7 -0
  175. package/internals/plugins/models/helpers.js +1 -0
  176. package/internals/plugins/models/index.d.ts +3 -0
  177. package/internals/plugins/models/index.js +3 -0
  178. package/internals/plugins/models/plugin.d.ts +75 -0
  179. package/internals/plugins/models/plugin.js +1 -0
  180. package/internals/plugins/utils/ChartStore.d.ts +13 -0
  181. package/internals/plugins/utils/ChartStore.js +24 -0
  182. package/internals/plugins/utils/selectors.d.ts +9 -0
  183. package/internals/plugins/utils/selectors.js +37 -0
  184. package/internals/store/useCharts.d.ts +14 -0
  185. package/internals/store/useCharts.js +72 -0
  186. package/internals/store/useCharts.types.d.ts +5 -0
  187. package/internals/store/useCharts.types.js +1 -0
  188. package/internals/store/useSelector.d.ts +4 -0
  189. package/internals/store/useSelector.js +6 -0
  190. package/internals/store/useStore.d.ts +3 -0
  191. package/internals/store/useStore.js +17 -0
  192. package/models/axis.d.ts +1 -13
  193. package/modern/BarChart/AnimatedBarElement.js +21 -0
  194. package/modern/BarChart/BarChart.js +3 -35
  195. package/modern/BarChart/BarElement.js +10 -20
  196. package/modern/BarChart/BarPlot.js +12 -2
  197. package/modern/BarChart/useBarChartProps.js +2 -8
  198. package/modern/ChartContainer/ChartContainer.js +31 -25
  199. package/modern/ChartContainer/useChartContainerProps.js +12 -27
  200. package/modern/ChartsAxis/axisClasses.js +2 -1
  201. package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +10 -96
  202. package/modern/ChartsAxisHighlight/ChartsAxisHighlight.types.js +1 -0
  203. package/modern/ChartsAxisHighlight/ChartsAxisHighlightPath.js +34 -0
  204. package/modern/ChartsAxisHighlight/ChartsXAxisHighlight.js +53 -0
  205. package/modern/ChartsAxisHighlight/ChartsYAxisHighlight.js +53 -0
  206. package/modern/ChartsAxisHighlight/chartsAxisHighlightClasses.js +6 -0
  207. package/modern/ChartsAxisHighlight/index.js +4 -1
  208. package/modern/ChartsGrid/ChartsGrid.js +1 -1
  209. package/modern/ChartsGrid/ChartsHorizontalGrid.js +3 -3
  210. package/modern/ChartsGrid/ChartsVerticalGrid.js +3 -3
  211. package/modern/ChartsLegend/chartsLegendClasses.js +2 -1
  212. package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +9 -7
  213. package/modern/ChartsSurface/ChartsSurface.js +68 -35
  214. package/modern/ChartsTooltip/ChartTooltip.types.js +1 -0
  215. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +83 -72
  216. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +54 -44
  217. package/modern/ChartsTooltip/ChartsTooltip.js +143 -145
  218. package/modern/ChartsTooltip/ChartsTooltipContainer.js +280 -0
  219. package/modern/ChartsTooltip/ChartsTooltipTable.js +1 -1
  220. package/modern/ChartsTooltip/chartsTooltipClasses.js +18 -2
  221. package/modern/ChartsTooltip/index.js +2 -3
  222. package/modern/ChartsTooltip/useAxisTooltip.js +19 -19
  223. package/modern/ChartsTooltip/useItemTooltip.js +5 -4
  224. package/modern/ChartsTooltip/utils.js +0 -8
  225. package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +49 -36
  226. package/modern/ChartsXAxis/ChartsXAxis.js +3 -17
  227. package/modern/ChartsYAxis/ChartsYAxis.js +2 -17
  228. package/modern/Gauge/Gauge.js +0 -6
  229. package/modern/Gauge/GaugeContainer.js +42 -76
  230. package/modern/LineChart/AnimatedArea.js +9 -18
  231. package/modern/LineChart/AnimatedLine.js +9 -20
  232. package/modern/LineChart/AreaPlot.js +12 -2
  233. package/modern/LineChart/CircleMarkElement.js +6 -5
  234. package/modern/LineChart/LineChart.js +3 -36
  235. package/modern/LineChart/LineHighlightPlot.js +6 -5
  236. package/modern/LineChart/LinePlot.js +12 -2
  237. package/modern/LineChart/MarkElement.js +6 -5
  238. package/modern/LineChart/useLineChartProps.js +2 -8
  239. package/modern/PieChart/PieChart.js +5 -41
  240. package/modern/PieChart/PiePlot.js +2 -2
  241. package/modern/ScatterChart/Scatter.js +6 -5
  242. package/modern/ScatterChart/ScatterChart.js +5 -36
  243. package/modern/ScatterChart/useScatterChartProps.js +1 -9
  244. package/modern/SparkLineChart/SparkLineChart.js +4 -35
  245. package/modern/context/ChartDataProvider/ChartDataProvider.js +55 -48
  246. package/modern/context/ChartDataProvider/useChartDataProviderProps.js +22 -42
  247. package/modern/context/ChartProvider/ChartContext.js +8 -0
  248. package/modern/context/ChartProvider/ChartProvider.js +19 -0
  249. package/modern/context/ChartProvider/ChartProvider.types.js +1 -0
  250. package/modern/context/ChartProvider/index.js +3 -0
  251. package/modern/context/ChartProvider/useChartContext.js +11 -0
  252. package/modern/context/DrawingAreaProvider/DrawingArea.types.js +1 -0
  253. package/modern/context/DrawingAreaProvider/DrawingAreaContext.js +15 -0
  254. package/{context/DrawingProvider.js → modern/context/DrawingAreaProvider/DrawingAreaProvider.js} +11 -41
  255. package/modern/context/DrawingAreaProvider/index.js +3 -0
  256. package/modern/context/InteractionSelectors.js +12 -0
  257. package/modern/context/SizeProvider/Size.types.js +1 -0
  258. package/modern/context/SizeProvider/SizeContext.js +15 -0
  259. package/modern/context/SizeProvider/SizeProvider.js +26 -0
  260. package/modern/context/SizeProvider/index.js +4 -0
  261. package/{ChartContainer → modern/context/SizeProvider}/useChartContainerDimensions.js +16 -6
  262. package/modern/context/SizeProvider/useSize.js +13 -0
  263. package/modern/context/index.js +2 -1
  264. package/modern/hooks/useAxisEvents.js +32 -19
  265. package/modern/hooks/useChartId.js +5 -6
  266. package/modern/hooks/useDrawingArea.js +2 -2
  267. package/modern/hooks/useInteractionItemProps.js +22 -13
  268. package/modern/hooks/useSvgRef.js +4 -8
  269. package/modern/index.js +1 -1
  270. package/modern/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +9 -7
  271. package/modern/internals/index.js +3 -4
  272. package/modern/internals/plugins/allPlugins.js +3 -0
  273. package/modern/internals/plugins/corePlugins/corePlugins.js +7 -0
  274. package/modern/internals/plugins/corePlugins/index.js +1 -0
  275. package/modern/internals/plugins/corePlugins/useChartId/index.js +1 -0
  276. package/modern/internals/plugins/corePlugins/useChartId/useChartId.js +32 -0
  277. package/modern/internals/plugins/corePlugins/useChartId/useChartId.selectors.js +9 -0
  278. package/modern/internals/plugins/corePlugins/useChartId/useChartId.types.js +1 -0
  279. package/modern/internals/plugins/corePlugins/useChartId/useChartId.utils.js +5 -0
  280. package/modern/internals/plugins/featurePlugins/useChartInteraction/index.js +2 -0
  281. package/modern/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +73 -0
  282. package/modern/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.js +10 -0
  283. package/modern/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.types.js +1 -0
  284. package/modern/internals/plugins/models/chart.js +1 -0
  285. package/modern/internals/plugins/models/helpers.js +1 -0
  286. package/modern/internals/plugins/models/index.js +3 -0
  287. package/modern/internals/plugins/models/plugin.js +1 -0
  288. package/modern/internals/plugins/utils/ChartStore.js +24 -0
  289. package/modern/internals/plugins/utils/selectors.js +37 -0
  290. package/modern/internals/store/useCharts.js +72 -0
  291. package/modern/internals/store/useCharts.types.js +1 -0
  292. package/modern/internals/store/useSelector.js +6 -0
  293. package/modern/internals/store/useStore.js +17 -0
  294. package/node/BarChart/AnimatedBarElement.js +28 -0
  295. package/node/BarChart/BarChart.js +3 -35
  296. package/node/BarChart/BarElement.js +11 -21
  297. package/node/BarChart/BarPlot.js +11 -1
  298. package/node/BarChart/useBarChartProps.js +2 -8
  299. package/node/ChartContainer/ChartContainer.js +31 -25
  300. package/node/ChartContainer/useChartContainerProps.js +12 -27
  301. package/node/ChartsAxis/axisClasses.js +5 -3
  302. package/node/ChartsAxisHighlight/ChartsAxisHighlight.js +12 -100
  303. package/node/ChartsAxisHighlight/ChartsAxisHighlight.types.js +5 -0
  304. package/node/ChartsAxisHighlight/ChartsAxisHighlightPath.js +40 -0
  305. package/node/ChartsAxisHighlight/ChartsXAxisHighlight.js +57 -0
  306. package/node/ChartsAxisHighlight/ChartsYAxisHighlight.js +57 -0
  307. package/node/ChartsAxisHighlight/chartsAxisHighlightClasses.js +14 -0
  308. package/node/ChartsAxisHighlight/index.js +33 -0
  309. package/node/ChartsGrid/ChartsGrid.js +2 -2
  310. package/node/ChartsGrid/ChartsHorizontalGrid.js +4 -4
  311. package/node/ChartsGrid/ChartsVerticalGrid.js +4 -4
  312. package/node/ChartsLegend/chartsLegendClasses.js +5 -3
  313. package/node/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +9 -7
  314. package/node/ChartsSurface/ChartsSurface.js +68 -35
  315. package/node/ChartsTooltip/ChartTooltip.types.js +5 -0
  316. package/node/ChartsTooltip/ChartsAxisTooltipContent.js +83 -73
  317. package/node/ChartsTooltip/ChartsItemTooltipContent.js +54 -45
  318. package/node/ChartsTooltip/ChartsTooltip.js +142 -144
  319. package/node/ChartsTooltip/ChartsTooltipContainer.js +286 -0
  320. package/node/ChartsTooltip/ChartsTooltipTable.js +2 -2
  321. package/node/ChartsTooltip/chartsTooltipClasses.js +22 -3
  322. package/node/ChartsTooltip/index.js +19 -28
  323. package/node/ChartsTooltip/useAxisTooltip.js +19 -19
  324. package/node/ChartsTooltip/useItemTooltip.js +5 -4
  325. package/node/ChartsTooltip/utils.js +0 -9
  326. package/node/ChartsVoronoiHandler/ChartsVoronoiHandler.js +50 -37
  327. package/node/ChartsXAxis/ChartsXAxis.js +3 -17
  328. package/node/ChartsYAxis/ChartsYAxis.js +2 -17
  329. package/node/Gauge/Gauge.js +0 -6
  330. package/node/Gauge/GaugeContainer.js +42 -76
  331. package/node/LineChart/AnimatedArea.js +9 -19
  332. package/node/LineChart/AnimatedLine.js +9 -21
  333. package/node/LineChart/AreaPlot.js +11 -1
  334. package/node/LineChart/CircleMarkElement.js +6 -5
  335. package/node/LineChart/LineChart.js +3 -36
  336. package/node/LineChart/LineHighlightPlot.js +6 -5
  337. package/node/LineChart/LinePlot.js +11 -1
  338. package/node/LineChart/MarkElement.js +6 -5
  339. package/node/LineChart/useLineChartProps.js +2 -8
  340. package/node/PieChart/PieChart.js +5 -41
  341. package/node/PieChart/PiePlot.js +2 -2
  342. package/node/ScatterChart/Scatter.js +6 -5
  343. package/node/ScatterChart/ScatterChart.js +5 -36
  344. package/node/ScatterChart/useScatterChartProps.js +1 -9
  345. package/node/SparkLineChart/SparkLineChart.js +4 -35
  346. package/node/context/ChartDataProvider/ChartDataProvider.js +55 -48
  347. package/node/context/ChartDataProvider/useChartDataProviderProps.js +22 -44
  348. package/node/context/ChartProvider/ChartContext.js +15 -0
  349. package/node/context/ChartProvider/ChartProvider.js +24 -0
  350. package/node/context/ChartProvider/ChartProvider.types.js +5 -0
  351. package/node/context/ChartProvider/index.js +38 -0
  352. package/node/context/ChartProvider/useChartContext.js +18 -0
  353. package/node/context/DrawingAreaProvider/DrawingArea.types.js +5 -0
  354. package/node/context/DrawingAreaProvider/DrawingAreaContext.js +21 -0
  355. package/node/context/{DrawingProvider.js → DrawingAreaProvider/DrawingAreaProvider.js} +12 -44
  356. package/node/context/DrawingAreaProvider/index.js +38 -0
  357. package/node/context/InteractionSelectors.js +18 -0
  358. package/node/context/SizeProvider/Size.types.js +5 -0
  359. package/node/context/SizeProvider/SizeContext.js +22 -0
  360. package/node/context/SizeProvider/SizeProvider.js +29 -0
  361. package/node/context/SizeProvider/index.js +49 -0
  362. package/node/{ChartContainer → context/SizeProvider}/useChartContainerDimensions.js +16 -6
  363. package/node/context/SizeProvider/useSize.js +20 -0
  364. package/node/context/index.js +10 -2
  365. package/node/hooks/useAxisEvents.js +33 -19
  366. package/node/hooks/useChartId.js +5 -7
  367. package/node/hooks/useDrawingArea.js +2 -2
  368. package/node/hooks/useInteractionItemProps.js +23 -14
  369. package/node/hooks/useSvgRef.js +4 -9
  370. package/node/index.js +1 -1
  371. package/node/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +8 -6
  372. package/node/internals/index.js +28 -40
  373. package/node/internals/plugins/allPlugins.js +10 -0
  374. package/node/internals/plugins/corePlugins/corePlugins.js +12 -0
  375. package/node/internals/plugins/corePlugins/index.js +12 -0
  376. package/node/internals/plugins/corePlugins/useChartId/index.js +12 -0
  377. package/node/internals/plugins/corePlugins/useChartId/useChartId.js +41 -0
  378. package/node/internals/plugins/corePlugins/useChartId/useChartId.selectors.js +15 -0
  379. package/node/internals/plugins/corePlugins/useChartId/useChartId.types.js +5 -0
  380. package/node/internals/plugins/corePlugins/useChartId/useChartId.utils.js +12 -0
  381. package/node/internals/plugins/featurePlugins/useChartInteraction/index.js +27 -0
  382. package/node/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +81 -0
  383. package/node/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.js +16 -0
  384. package/node/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.types.js +5 -0
  385. package/node/internals/plugins/models/chart.js +5 -0
  386. package/node/internals/plugins/models/helpers.js +5 -0
  387. package/node/internals/plugins/models/index.js +38 -0
  388. package/node/internals/plugins/models/plugin.js +5 -0
  389. package/node/internals/plugins/utils/ChartStore.js +31 -0
  390. package/node/internals/plugins/utils/selectors.js +44 -0
  391. package/node/internals/store/useCharts.js +80 -0
  392. package/node/internals/store/useCharts.types.js +5 -0
  393. package/node/internals/store/useSelector.js +13 -0
  394. package/node/internals/store/useStore.js +23 -0
  395. package/package.json +7 -5
  396. package/themeAugmentation/props.d.ts +1 -2
  397. package/ChartContainer/ResizableContainer.d.ts +0 -9
  398. package/ChartContainer/ResizableContainer.js +0 -26
  399. package/ChartContainer/useChartContainerDimensions.d.ts +0 -6
  400. package/ChartsTooltip/DefaultChartsAxisTooltipContent.d.ts +0 -7
  401. package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +0 -123
  402. package/ChartsTooltip/DefaultChartsItemTooltipContent.d.ts +0 -8
  403. package/ChartsTooltip/DefaultChartsItemTooltipContent.js +0 -92
  404. package/context/InteractionProvider.d.ts +0 -50
  405. package/context/InteractionProvider.js +0 -78
  406. package/modern/ChartContainer/ResizableContainer.js +0 -26
  407. package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +0 -123
  408. package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +0 -92
  409. package/modern/context/InteractionProvider.js +0 -78
  410. package/node/ChartContainer/ResizableContainer.js +0 -32
  411. package/node/ChartsTooltip/DefaultChartsAxisTooltipContent.js +0 -129
  412. package/node/ChartsTooltip/DefaultChartsItemTooltipContent.js +0 -98
  413. package/node/context/InteractionProvider.js +0 -85
  414. /package/ChartsGrid/{styledCommonents.d.ts → styledComponents.d.ts} +0 -0
  415. /package/ChartsGrid/{styledCommonents.js → styledComponents.js} +0 -0
  416. /package/modern/ChartsGrid/{styledCommonents.js → styledComponents.js} +0 -0
  417. /package/node/ChartsGrid/{styledCommonents.js → styledComponents.js} +0 -0
@@ -1,41 +1,26 @@
1
1
  'use client';
2
2
 
3
- import _extends from "@babel/runtime/helpers/esm/extends";
4
- import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
5
- const _excluded = ["width", "height", "series", "margin", "xAxis", "yAxis", "zAxis", "colors", "dataset", "sx", "title", "desc", "disableAxisListener", "highlightedItem", "onHighlightChange", "plugins", "children", "skipAnimation"];
6
- import * as React from 'react';
7
- import useForkRef from '@mui/utils/useForkRef';
8
3
  import { useDefaultizeAxis } from "./useDefaultizeAxis.js";
9
- export const useChartDataProviderProps = (props, ref) => {
4
+ export const useChartDataProviderProps = props => {
10
5
  const {
11
- width,
12
- height,
13
- series,
14
- margin,
15
- xAxis,
16
- yAxis,
17
- zAxis,
18
- colors,
19
- dataset,
20
- sx,
21
- title,
22
- desc,
23
- disableAxisListener,
24
- highlightedItem,
25
- onHighlightChange,
26
- plugins,
27
- children,
28
- skipAnimation
29
- } = props,
30
- other = _objectWithoutPropertiesLoose(props, _excluded);
31
- const svgRef = React.useRef(null);
32
- const chartSurfaceRef = useForkRef(ref, svgRef);
33
- const [defaultizedXAxis, defaultizedYAxis] = useDefaultizeAxis(xAxis, yAxis, dataset);
34
- const drawingProviderProps = {
35
6
  width,
36
7
  height,
8
+ series,
37
9
  margin,
38
- svgRef
10
+ xAxis,
11
+ yAxis,
12
+ zAxis,
13
+ colors,
14
+ dataset,
15
+ highlightedItem,
16
+ onHighlightChange,
17
+ plugins,
18
+ children,
19
+ skipAnimation
20
+ } = props;
21
+ const [defaultizedXAxis, defaultizedYAxis] = useDefaultizeAxis(xAxis, yAxis, dataset);
22
+ const drawingAreaProviderProps = {
23
+ margin
39
24
  };
40
25
  const animationProviderProps = {
41
26
  skipAnimation
@@ -61,26 +46,21 @@ export const useChartDataProviderProps = (props, ref) => {
61
46
  highlightedItem,
62
47
  onHighlightChange
63
48
  };
64
- const chartsSurfaceProps = _extends({}, other, {
49
+ const sizeProviderProps = {
65
50
  width,
66
- height,
67
- ref: chartSurfaceRef,
68
- sx,
69
- title,
70
- desc,
71
- disableAxisListener
72
- });
51
+ height
52
+ };
73
53
  return {
74
54
  children,
75
- drawingProviderProps,
55
+ drawingAreaProviderProps,
76
56
  seriesProviderProps,
77
57
  cartesianProviderProps,
78
58
  zAxisContextProps,
79
59
  highlightedProviderProps,
80
- chartsSurfaceProps,
81
60
  pluginProviderProps,
82
61
  animationProviderProps,
83
62
  xAxis: defaultizedXAxis,
84
- yAxis: defaultizedYAxis
63
+ yAxis: defaultizedYAxis,
64
+ sizeProviderProps
85
65
  };
86
66
  };
@@ -0,0 +1,8 @@
1
+ import * as React from 'react';
2
+ /**
3
+ * @ignore - internal component.
4
+ */
5
+ export const ChartContext = /*#__PURE__*/React.createContext(null);
6
+ if (process.env.NODE_ENV !== 'production') {
7
+ ChartContext.displayName = 'ChartContext';
8
+ }
@@ -0,0 +1,19 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import { useCharts } from "../../internals/store/useCharts.js";
5
+ import { ChartContext } from "./ChartContext.js";
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ function ChartProvider(props) {
8
+ const {
9
+ children
10
+ } = props;
11
+ const {
12
+ contextValue
13
+ } = useCharts([], {});
14
+ return /*#__PURE__*/_jsx(ChartContext.Provider, {
15
+ value: contextValue,
16
+ children: children
17
+ });
18
+ }
19
+ export { ChartProvider };
@@ -0,0 +1,3 @@
1
+ export * from "./ChartProvider.js";
2
+ export * from "./ChartProvider.types.js";
3
+ export * from "./useChartContext.js";
@@ -0,0 +1,11 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import { ChartContext } from "./ChartContext.js";
5
+ export const useChartContext = () => {
6
+ const context = React.useContext(ChartContext);
7
+ if (context == null) {
8
+ throw new Error(['MUI X: Could not find the Chart context.', 'It looks like you rendered your component outside of a ChartDataProvider.', 'This can also happen if you are bundling multiple versions of the library.'].join('\n'));
9
+ }
10
+ return context;
11
+ };
@@ -0,0 +1,15 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ export const DrawingAreaContext = /*#__PURE__*/React.createContext({
5
+ top: 0,
6
+ left: 0,
7
+ bottom: 0,
8
+ right: 0,
9
+ height: 300,
10
+ width: 400,
11
+ isPointInside: () => false
12
+ });
13
+ if (process.env.NODE_ENV !== 'production') {
14
+ DrawingAreaContext.displayName = 'DrawingContext';
15
+ }
@@ -3,42 +3,19 @@
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import * as React from 'react';
5
5
  import useId from '@mui/utils/useId';
6
- import useChartDimensions from "../hooks/useChartDimensions.js";
7
-
8
- /**
9
- * Defines the area in which it is possible to draw the charts.
10
- */
6
+ import useChartDimensions from "../../hooks/useChartDimensions.js";
7
+ import { DrawingAreaContext } from "./DrawingAreaContext.js";
8
+ import { useSize } from "../SizeProvider/index.js";
11
9
  import { jsx as _jsx } from "react/jsx-runtime";
12
- export const DrawingContext = /*#__PURE__*/React.createContext({
13
- top: 0,
14
- left: 0,
15
- bottom: 0,
16
- right: 0,
17
- height: 300,
18
- width: 400,
19
- chartId: '',
20
- isPointInside: () => false
21
- });
22
- if (process.env.NODE_ENV !== 'production') {
23
- DrawingContext.displayName = 'DrawingContext';
24
- }
25
- export const SvgContext = /*#__PURE__*/React.createContext({
26
- isInitialized: false,
27
- data: {
28
- current: null
29
- }
30
- });
31
- if (process.env.NODE_ENV !== 'production') {
32
- SvgContext.displayName = 'SvgContext';
33
- }
34
- export function DrawingProvider(props) {
10
+ export function DrawingAreaProvider(props) {
35
11
  const {
36
- width,
37
- height,
38
12
  margin,
39
- svgRef,
40
13
  children
41
14
  } = props;
15
+ const {
16
+ width,
17
+ height
18
+ } = useSize();
42
19
  const drawingArea = useChartDimensions(width, height, margin);
43
20
  const chartId = useId();
44
21
  const isPointInside = React.useCallback(({
@@ -64,15 +41,8 @@ export function DrawingProvider(props) {
64
41
  }, drawingArea, {
65
42
  isPointInside
66
43
  }), [chartId, drawingArea, isPointInside]);
67
- const refValue = React.useMemo(() => ({
68
- isInitialized: true,
69
- data: svgRef
70
- }), [svgRef]);
71
- return /*#__PURE__*/_jsx(SvgContext.Provider, {
72
- value: refValue,
73
- children: /*#__PURE__*/_jsx(DrawingContext.Provider, {
74
- value: value,
75
- children: children
76
- })
44
+ return /*#__PURE__*/_jsx(DrawingAreaContext.Provider, {
45
+ value: value,
46
+ children: children
77
47
  });
78
48
  }
@@ -0,0 +1,3 @@
1
+ export * from "./DrawingArea.types.js";
2
+ export * from "./DrawingAreaProvider.js";
3
+ export * from "./DrawingAreaContext.js";
@@ -0,0 +1,12 @@
1
+ import { createSelector } from "../internals/plugins/utils/selectors.js";
2
+ function selectInteraction(state) {
3
+ return state.interaction;
4
+ }
5
+ export const selectorChartsInteractionItem = createSelector(selectInteraction, interaction => interaction.item);
6
+ export const selectorChartsInteractionAxis = createSelector(selectInteraction, interaction => interaction.axis);
7
+ export const selectorChartsInteractionXAxis = createSelector(selectInteraction, interaction => interaction.axis.x);
8
+ export const selectorChartsInteractionYAxis = createSelector(selectInteraction, interaction => interaction.axis.y);
9
+ export const selectorChartsInteractionItemIsDefined = createSelector(selectorChartsInteractionItem, item => item !== null);
10
+ export const selectorChartsInteractionXAxisIsDefined = createSelector(selectorChartsInteractionXAxis, x => x !== null);
11
+ export const selectorChartsInteractionYAxisIsDefined = createSelector(selectorChartsInteractionYAxis, y => y !== null);
12
+ export const selectorChartsInteractionIsVoronoiEnabled = createSelector(selectInteraction, interaction => interaction.isVoronoiEnabled);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,15 @@
1
+ import * as React from 'react';
2
+ export const SizeContext = /*#__PURE__*/React.createContext({
3
+ isInitialized: false,
4
+ data: {
5
+ hasIntrinsicSize: false,
6
+ svgRef: {
7
+ current: null
8
+ },
9
+ height: 0,
10
+ width: 0
11
+ }
12
+ });
13
+ if (process.env.NODE_ENV !== 'production') {
14
+ SizeContext.displayName = 'SizeContext';
15
+ }
@@ -0,0 +1,26 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import { SizeContext } from "./SizeContext.js";
5
+ import { useChartContainerDimensions } from "./useChartContainerDimensions.js";
6
+
7
+ /**
8
+ * The size provider.
9
+ *
10
+ * This differs from the DrawingProvider in that it provides the full size of the container.
11
+ *
12
+ * This provider is also responsible for resolving the size of the container before rendering and if the parent size changes.
13
+ */
14
+ import { jsx as _jsx } from "react/jsx-runtime";
15
+ function SizeProvider(props) {
16
+ const dimensions = useChartContainerDimensions(props.width, props.height);
17
+ const value = React.useMemo(() => ({
18
+ isInitialized: true,
19
+ data: dimensions
20
+ }), [dimensions]);
21
+ return /*#__PURE__*/_jsx(SizeContext.Provider, {
22
+ value: value,
23
+ children: props.children
24
+ });
25
+ }
26
+ export { SizeProvider };
@@ -0,0 +1,4 @@
1
+ export * from "./SizeProvider.js";
2
+ export * from "./SizeContext.js";
3
+ export * from "./useSize.js";
4
+ export * from "./Size.types.js";
@@ -4,7 +4,8 @@
4
4
  import * as React from 'react';
5
5
  import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
6
6
  import ownerWindow from '@mui/utils/ownerWindow';
7
- export const useChartContainerDimensions = (inWidth, inHeight, resolveSizeBeforeRender) => {
7
+ const MAX_COMPUTE_RUN = 10;
8
+ export const useChartContainerDimensions = (inWidth, inHeight) => {
8
9
  const hasInSize = inWidth !== undefined && inHeight !== undefined;
9
10
  const stateRef = React.useRef({
10
11
  displayError: false,
@@ -19,6 +20,10 @@ export const useChartContainerDimensions = (inWidth, inHeight, resolveSizeBefore
19
20
  const computeSize = React.useCallback(() => {
20
21
  const mainEl = rootRef?.current;
21
22
  if (!mainEl) {
23
+ if (process.env.NODE_ENV !== 'production') {
24
+ // This is mostly for internal use.
25
+ throw new Error([`MUI X: ChartContainer does not have a valid reference to the <svg /> element.`, 'This may be caused by a ref forwarding issue.', 'Make sure that the ref from SizedProvider is forwarded correctly.'].join('\n'));
26
+ }
22
27
  return {};
23
28
  }
24
29
  const win = ownerWindow(mainEl);
@@ -42,7 +47,7 @@ export const useChartContainerDimensions = (inWidth, inHeight, resolveSizeBefore
42
47
  // https://github.com/mui/mui-x/issues/13477#issuecomment-2336634785
43
48
  useEnhancedEffect(() => {
44
49
  // computeRun is used to avoid infinite loops.
45
- if (hasInSize || !resolveSizeBeforeRender || !stateRef.current.initialCompute || stateRef.current.computeRun > 20) {
50
+ if (hasInSize || !stateRef.current.initialCompute || stateRef.current.computeRun > MAX_COMPUTE_RUN) {
46
51
  return;
47
52
  }
48
53
  const computedSize = computeSize();
@@ -51,7 +56,7 @@ export const useChartContainerDimensions = (inWidth, inHeight, resolveSizeBefore
51
56
  } else if (stateRef.current.initialCompute) {
52
57
  stateRef.current.initialCompute = false;
53
58
  }
54
- }, [width, height, computeSize, resolveSizeBeforeRender, hasInSize]);
59
+ }, [width, height, computeSize, hasInSize]);
55
60
  useEnhancedEffect(() => {
56
61
  if (hasInSize) {
57
62
  return () => {};
@@ -90,9 +95,14 @@ export const useChartContainerDimensions = (inWidth, inHeight, resolveSizeBefore
90
95
  stateRef.current.displayError = false;
91
96
  }
92
97
  }
98
+ const finalWidth = inWidth ?? width;
99
+ const finalHeight = inHeight ?? height;
93
100
  return {
94
- containerRef: rootRef,
95
- width: inWidth ?? width,
96
- height: inHeight ?? height
101
+ svgRef: rootRef,
102
+ width: finalWidth,
103
+ height: finalHeight,
104
+ hasIntrinsicSize: finalWidth > 0 && finalHeight > 0,
105
+ inWidth,
106
+ inHeight
97
107
  };
98
108
  };
@@ -0,0 +1,13 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import { SizeContext } from "./SizeContext.js";
5
+ /**
6
+ * Returns the size of the chart. And the ref of the container element that the chart is rendered in.
7
+ */
8
+ export const useSize = () => {
9
+ const {
10
+ data
11
+ } = React.useContext(SizeContext);
12
+ return data;
13
+ };
@@ -1,2 +1,3 @@
1
1
  export * from "./HighlightedProvider/index.js";
2
- export { ZAxisContextProvider } from "./ZAxisContextProvider.js";
2
+ export { ZAxisContextProvider } from "./ZAxisContextProvider.js";
3
+ export { ChartDataProvider } from "./ChartDataProvider/index.js";
@@ -1,12 +1,13 @@
1
1
  'use client';
2
2
 
3
+ import _extends from "@babel/runtime/helpers/esm/extends";
3
4
  import * as React from 'react';
4
- import { InteractionContext } from "../context/InteractionProvider.js";
5
5
  import { useCartesianContext } from "../context/CartesianProvider/index.js";
6
6
  import { isBandScale } from "../internals/isBandScale.js";
7
7
  import { getSVGPoint } from "../internals/getSVGPoint.js";
8
8
  import { useSvgRef } from "./useSvgRef.js";
9
9
  import { useDrawingArea } from "./useDrawingArea.js";
10
+ import { useStore } from "../internals/store/useStore.js";
10
11
  function getAsANumber(value) {
11
12
  return value instanceof Date ? value.getTime() : value;
12
13
  }
@@ -19,9 +20,7 @@ export const useAxisEvents = disableAxisListener => {
19
20
  xAxisIds,
20
21
  yAxisIds
21
22
  } = useCartesianContext();
22
- const {
23
- dispatch
24
- } = React.useContext(InteractionContext);
23
+ const store = useStore(disableAxisListener);
25
24
  const usedXAxis = xAxisIds[0];
26
25
  const usedYAxis = yAxisIds[0];
27
26
 
@@ -33,7 +32,7 @@ export const useAxisEvents = disableAxisListener => {
33
32
  });
34
33
  React.useEffect(() => {
35
34
  const element = svgRef.current;
36
- if (element === null || disableAxisListener) {
35
+ if (element === null || disableAxisListener || !store) {
37
36
  return () => {};
38
37
  }
39
38
  function getNewAxisState(axisConfig, mouseValue) {
@@ -92,9 +91,15 @@ export const useAxisEvents = disableAxisListener => {
92
91
  x: -1,
93
92
  y: -1
94
93
  };
95
- dispatch({
96
- type: 'exitChart'
97
- });
94
+ store.update(prev => _extends({}, prev, {
95
+ interaction: {
96
+ item: null,
97
+ axis: {
98
+ x: null,
99
+ y: null
100
+ }
101
+ }
102
+ }));
98
103
  };
99
104
  const handleMove = event => {
100
105
  const target = 'targetTouches' in event ? event.targetTouches[0] : event;
@@ -105,9 +110,15 @@ export const useAxisEvents = disableAxisListener => {
105
110
  targetElement: event.target
106
111
  })) {
107
112
  if (mousePosition.current.isInChart) {
108
- dispatch({
109
- type: 'exitChart'
110
- });
113
+ store.update(prev => _extends({}, prev, {
114
+ interaction: {
115
+ item: null,
116
+ axis: {
117
+ x: null,
118
+ y: null
119
+ }
120
+ }
121
+ }));
111
122
  mousePosition.current.isInChart = false;
112
123
  }
113
124
  return;
@@ -115,13 +126,15 @@ export const useAxisEvents = disableAxisListener => {
115
126
  mousePosition.current.isInChart = true;
116
127
  const newStateX = getNewAxisState(xAxis[usedXAxis], svgPoint.x);
117
128
  const newStateY = getNewAxisState(yAxis[usedYAxis], svgPoint.y);
118
- dispatch({
119
- type: 'updateAxis',
120
- data: {
121
- x: newStateX,
122
- y: newStateY
123
- }
124
- });
129
+ store.update(prev => _extends({}, prev, {
130
+ interaction: _extends({}, prev.interaction, {
131
+ axis: _extends({}, prev.interaction.axis, prev.interaction.axis.x?.index !== newStateX?.index || prev.interaction.axis.x?.value !== newStateX?.value ? {
132
+ x: newStateX
133
+ } : {}, prev.interaction.axis.y?.index !== newStateY?.index || prev.interaction.axis.y?.value !== newStateY?.value ? {
134
+ y: newStateY
135
+ } : {})
136
+ })
137
+ }));
125
138
  };
126
139
  const handleDown = event => {
127
140
  const target = event.currentTarget;
@@ -144,5 +157,5 @@ export const useAxisEvents = disableAxisListener => {
144
157
  element.removeEventListener('pointercancel', handleOut);
145
158
  element.removeEventListener('pointerleave', handleOut);
146
159
  };
147
- }, [svgRef, dispatch, usedYAxis, yAxis, usedXAxis, xAxis, disableAxisListener, drawingArea]);
160
+ }, [svgRef, store, usedYAxis, yAxis, usedXAxis, xAxis, disableAxisListener, drawingArea]);
148
161
  };
@@ -1,10 +1,9 @@
1
1
  'use client';
2
2
 
3
- import * as React from 'react';
4
- import { DrawingContext } from "../context/DrawingProvider.js";
3
+ import { useStore } from "../internals/store/useStore.js";
4
+ import { useSelector } from "../internals/store/useSelector.js";
5
+ import { selectorChartId } from "../internals/plugins/corePlugins/useChartId/useChartId.selectors.js";
5
6
  export function useChartId() {
6
- const {
7
- chartId
8
- } = React.useContext(DrawingContext);
9
- return React.useMemo(() => chartId, [chartId]);
7
+ const store = useStore();
8
+ return useSelector(store, selectorChartId);
10
9
  }
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
 
3
3
  import * as React from 'react';
4
- import { DrawingContext } from "../context/DrawingProvider.js";
4
+ import { DrawingAreaContext } from "../context/DrawingAreaProvider/index.js";
5
5
  export function useDrawingArea() {
6
6
  const {
7
7
  left,
@@ -11,7 +11,7 @@ export function useDrawingArea() {
11
11
  bottom,
12
12
  right,
13
13
  isPointInside
14
- } = React.useContext(DrawingContext);
14
+ } = React.useContext(DrawingAreaContext);
15
15
  return React.useMemo(() => ({
16
16
  left,
17
17
  top,
@@ -1,12 +1,10 @@
1
1
  'use client';
2
2
 
3
- import * as React from 'react';
4
- import { InteractionContext } from "../context/InteractionProvider.js";
3
+ import _extends from "@babel/runtime/helpers/esm/extends";
5
4
  import { useHighlighted } from "../context/index.js";
5
+ import { useStore } from "../internals/store/useStore.js";
6
6
  export const useInteractionItemProps = skip => {
7
- const {
8
- dispatch: dispatchInteraction
9
- } = React.useContext(InteractionContext);
7
+ const store = useStore();
10
8
  const {
11
9
  setHighlighted,
12
10
  clearHighlighted
@@ -21,20 +19,31 @@ export const useInteractionItemProps = skip => {
21
19
  }
22
20
  };
23
21
  const onPointerEnter = () => {
24
- dispatchInteraction({
25
- type: 'enterItem',
26
- data
27
- });
22
+ store.update(prev => _extends({}, prev, {
23
+ interaction: _extends({}, prev.interaction, {
24
+ item: data
25
+ })
26
+ }));
28
27
  setHighlighted({
29
28
  seriesId: data.seriesId,
30
29
  dataIndex: data.dataIndex
31
30
  });
32
31
  };
33
32
  const onPointerLeave = event => {
34
- event.currentTarget.releasePointerCapture(event.pointerId);
35
- dispatchInteraction({
36
- type: 'leaveItem',
37
- data
33
+ if (event.currentTarget.hasPointerCapture(event.pointerId)) {
34
+ event.currentTarget.releasePointerCapture(event.pointerId);
35
+ }
36
+ store.update(prev => {
37
+ const prevItem = prev.interaction.item;
38
+ if (prevItem === null || Object.keys(data).some(key => data[key] !== prevItem[key])) {
39
+ // The item is already something else, no need to clean it.
40
+ return prev;
41
+ }
42
+ return _extends({}, prev, {
43
+ interaction: _extends({}, prev.interaction, {
44
+ item: null
45
+ })
46
+ });
38
47
  });
39
48
  clearHighlighted();
40
49
  };
@@ -1,14 +1,10 @@
1
1
  'use client';
2
2
 
3
- import * as React from 'react';
4
- import { SvgContext } from "../context/DrawingProvider.js";
3
+ import { useChartContext } from "../context/ChartProvider/index.js";
5
4
  export function useSvgRef() {
6
- const {
7
- isInitialized,
8
- data
9
- } = React.useContext(SvgContext);
10
- if (!isInitialized) {
5
+ const context = useChartContext();
6
+ if (!context) {
11
7
  throw new Error(['MUI X: Could not find the svg ref context.', 'It looks like you rendered your component outside of a ChartsContainer parent component.'].join('\n'));
12
8
  }
13
- return data;
9
+ return context.svgRef;
14
10
  }
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v8.0.0-alpha.0
2
+ * @mui/x-charts v8.0.0-alpha.2
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -1,14 +1,11 @@
1
1
  import * as React from 'react';
2
2
  import { useCartesianContext } from "../../../context/CartesianProvider/index.js";
3
- import { DrawingContext } from "../../../context/DrawingProvider.js";
4
- import { useDrawingArea } from "../../../hooks/index.js";
3
+ import { useChartId, useDrawingArea } from "../../../hooks/index.js";
5
4
  import ChartsPiecewiseGradient from "./ChartsPiecewiseGradient.js";
6
5
  import ChartsContinuousGradient from "./ChartsContinuousGradient.js";
7
6
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
8
7
  export function useChartGradient() {
9
- const {
10
- chartId
11
- } = React.useContext(DrawingContext);
8
+ const chartId = useChartId();
12
9
  return React.useCallback((axisId, direction) => `${chartId}-gradient-${direction}-${axisId}`, [chartId]);
13
10
  }
14
11
  export function ChartsAxesGradients() {
@@ -29,8 +26,13 @@ export function ChartsAxesGradients() {
29
26
  yAxisIds,
30
27
  yAxis
31
28
  } = useCartesianContext();
29
+ const filteredYAxisIds = yAxisIds.filter(axisId => yAxis[axisId].colorMap !== undefined);
30
+ const filteredXAxisIds = xAxisIds.filter(axisId => xAxis[axisId].colorMap !== undefined);
31
+ if (filteredYAxisIds.length === 0 && filteredXAxisIds.length === 0) {
32
+ return null;
33
+ }
32
34
  return /*#__PURE__*/_jsxs("defs", {
33
- children: [yAxisIds.filter(axisId => yAxis[axisId].colorMap !== undefined).map(axisId => {
35
+ children: [filteredYAxisIds.map(axisId => {
34
36
  const gradientId = getGradientId(axisId, 'y');
35
37
  const {
36
38
  colorMap,
@@ -60,7 +62,7 @@ export function ChartsAxesGradients() {
60
62
  }, gradientId);
61
63
  }
62
64
  return null;
63
- }), xAxisIds.filter(axisId => xAxis[axisId].colorMap !== undefined).map(axisId => {
65
+ }), filteredXAxisIds.map(axisId => {
64
66
  const gradientId = getGradientId(axisId, 'x');
65
67
  const {
66
68
  colorMap,