@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
@@ -0,0 +1,280 @@
1
+ 'use client';
2
+
3
+ import _extends from "@babel/runtime/helpers/esm/extends";
4
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
5
+ const _excluded = ["trigger", "classes", "children"];
6
+ import * as React from 'react';
7
+ import PropTypes from 'prop-types';
8
+ import HTMLElementType from '@mui/utils/HTMLElementType';
9
+ import useLazyRef from '@mui/utils/useLazyRef';
10
+ import { styled, useThemeProps } from '@mui/material/styles';
11
+ import Popper from '@mui/material/Popper';
12
+ import NoSsr from '@mui/material/NoSsr';
13
+ import { useSvgRef } from "../hooks/useSvgRef.js";
14
+ import { usePointerType } from "./utils.js";
15
+ import { useSelector } from "../internals/store/useSelector.js";
16
+ import { useStore } from "../internals/store/useStore.js";
17
+ import { useXAxis } from "../hooks/index.js";
18
+ import { selectorChartsInteractionItemIsDefined, selectorChartsInteractionXAxisIsDefined, selectorChartsInteractionYAxisIsDefined } from "../internals/plugins/featurePlugins/useChartInteraction/index.js";
19
+ import { jsx as _jsx } from "react/jsx-runtime";
20
+ const ChartsTooltipRoot = styled(Popper, {
21
+ name: 'MuiChartsTooltip',
22
+ slot: 'Root',
23
+ overridesResolver: (_, styles) => styles.root
24
+ })(({
25
+ theme
26
+ }) => ({
27
+ pointerEvents: 'none',
28
+ zIndex: theme.zIndex.modal
29
+ }));
30
+
31
+ /**
32
+ * Demos:
33
+ *
34
+ * - [ChartsTooltip](https://mui.com/x/react-charts/tooltip/)
35
+ *
36
+ * API:
37
+ *
38
+ * - [ChartsTooltip API](https://mui.com/x/api/charts/charts-tool-tip/)
39
+ */
40
+ function ChartsTooltipContainer(inProps) {
41
+ const props = useThemeProps({
42
+ props: inProps,
43
+ name: 'MuiChartsTooltipContainer'
44
+ });
45
+ const {
46
+ trigger = 'axis',
47
+ classes,
48
+ children
49
+ } = props,
50
+ other = _objectWithoutPropertiesLoose(props, _excluded);
51
+ const svgRef = useSvgRef();
52
+ const pointerType = usePointerType();
53
+ const xAxis = useXAxis();
54
+ const xAxisHasData = xAxis.data !== undefined && xAxis.data.length !== 0;
55
+ const popperRef = React.useRef(null);
56
+ const positionRef = useLazyRef(() => ({
57
+ x: 0,
58
+ y: 0
59
+ }));
60
+ const store = useStore();
61
+ const isOpen = useSelector(store,
62
+ // eslint-disable-next-line no-nested-ternary
63
+ trigger === 'axis' ? xAxisHasData ? selectorChartsInteractionXAxisIsDefined : selectorChartsInteractionYAxisIsDefined : selectorChartsInteractionItemIsDefined);
64
+ const popperOpen = pointerType !== null && isOpen; // tooltipHasData;
65
+
66
+ React.useEffect(() => {
67
+ const element = svgRef.current;
68
+ if (element === null) {
69
+ return () => {};
70
+ }
71
+ const handleMove = event => {
72
+ // eslint-disable-next-line react-compiler/react-compiler
73
+ positionRef.current = {
74
+ x: event.clientX,
75
+ y: event.clientY
76
+ };
77
+ popperRef.current?.update();
78
+ };
79
+ element.addEventListener('pointermove', handleMove);
80
+ return () => {
81
+ element.removeEventListener('pointermove', handleMove);
82
+ };
83
+ }, [svgRef, positionRef]);
84
+ if (trigger === 'none') {
85
+ return null;
86
+ }
87
+ return /*#__PURE__*/_jsx(NoSsr, {
88
+ children: popperOpen && /*#__PURE__*/_jsx(ChartsTooltipRoot, _extends({
89
+ className: classes?.root,
90
+ open: popperOpen,
91
+ placement: pointerType?.pointerType === 'mouse' ? 'right-start' : 'top',
92
+ popperRef: popperRef,
93
+ anchorEl: {
94
+ getBoundingClientRect: () => ({
95
+ x: positionRef.current.x,
96
+ y: positionRef.current.y,
97
+ top: positionRef.current.y,
98
+ left: positionRef.current.x,
99
+ right: positionRef.current.x,
100
+ bottom: positionRef.current.y,
101
+ width: 0,
102
+ height: 0,
103
+ toJSON: () => ''
104
+ })
105
+ },
106
+ modifiers: [{
107
+ name: 'offset',
108
+ options: {
109
+ offset: [0, pointerType?.pointerType === 'touch' ? 40 - pointerType.height : 0]
110
+ }
111
+ }]
112
+ }, other, {
113
+ children: children
114
+ }))
115
+ });
116
+ }
117
+ process.env.NODE_ENV !== "production" ? ChartsTooltipContainer.propTypes = {
118
+ // ----------------------------- Warning --------------------------------
119
+ // | These PropTypes are generated from the TypeScript type definitions |
120
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
121
+ // ----------------------------------------------------------------------
122
+ /**
123
+ * An HTML element, [virtualElement](https://popper.js.org/docs/v2/virtual-elements/),
124
+ * or a function that returns either.
125
+ * It's used to set the position of the popper.
126
+ * The return value will passed as the reference object of the Popper instance.
127
+ */
128
+ anchorEl: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([HTMLElementType, PropTypes.object, PropTypes.func]),
129
+ /**
130
+ * Popper render function or node.
131
+ */
132
+ children: PropTypes.node,
133
+ /**
134
+ * Override or extend the styles applied to the component.
135
+ */
136
+ classes: PropTypes.object,
137
+ /**
138
+ * The component used for the root node.
139
+ * Either a string to use a HTML element or a component.
140
+ */
141
+ component: PropTypes.elementType,
142
+ /**
143
+ * The components used for each slot inside the Popper.
144
+ * Either a string to use a HTML element or a component.
145
+ * @default {}
146
+ */
147
+ components: PropTypes.shape({
148
+ Root: PropTypes.elementType
149
+ }),
150
+ /**
151
+ * The props used for each slot inside the Popper.
152
+ * @default {}
153
+ */
154
+ componentsProps: PropTypes.shape({
155
+ root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
156
+ }),
157
+ /**
158
+ * An HTML element or function that returns one.
159
+ * The `container` will have the portal children appended to it.
160
+ *
161
+ * You can also provide a callback, which is called in a React layout effect.
162
+ * This lets you set the container from a ref, and also makes server-side rendering possible.
163
+ *
164
+ * By default, it uses the body of the top-level document object,
165
+ * so it's simply `document.body` most of the time.
166
+ */
167
+ container: PropTypes.oneOfType([(props, propName) => {
168
+ if (props[propName] == null) {
169
+ return new Error(`Prop '${propName}' is required but wasn't specified`);
170
+ }
171
+ if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
172
+ return new Error(`Expected prop '${propName}' to be of type Element`);
173
+ }
174
+ return null;
175
+ }, PropTypes.func]),
176
+ /**
177
+ * The `children` will be under the DOM hierarchy of the parent component.
178
+ * @default false
179
+ */
180
+ disablePortal: PropTypes.bool,
181
+ /**
182
+ * Always keep the children in the DOM.
183
+ * This prop can be useful in SEO situation or
184
+ * when you want to maximize the responsiveness of the Popper.
185
+ * @default false
186
+ */
187
+ keepMounted: PropTypes.bool,
188
+ /**
189
+ * Popper.js is based on a "plugin-like" architecture,
190
+ * most of its features are fully encapsulated "modifiers".
191
+ *
192
+ * A modifier is a function that is called each time Popper.js needs to
193
+ * compute the position of the popper.
194
+ * For this reason, modifiers should be very performant to avoid bottlenecks.
195
+ * To learn how to create a modifier, [read the modifiers documentation](https://popper.js.org/docs/v2/modifiers/).
196
+ */
197
+ modifiers: PropTypes.arrayOf(PropTypes.shape({
198
+ data: PropTypes.object,
199
+ effect: PropTypes.func,
200
+ enabled: PropTypes.bool,
201
+ fn: PropTypes.func,
202
+ name: PropTypes.any,
203
+ options: PropTypes.object,
204
+ phase: PropTypes.oneOf(['afterMain', 'afterRead', 'afterWrite', 'beforeMain', 'beforeRead', 'beforeWrite', 'main', 'read', 'write']),
205
+ requires: PropTypes.arrayOf(PropTypes.string),
206
+ requiresIfExists: PropTypes.arrayOf(PropTypes.string)
207
+ })),
208
+ /**
209
+ * If `true`, the component is shown.
210
+ */
211
+ open: PropTypes.bool,
212
+ /**
213
+ * Popper placement.
214
+ * @default 'bottom'
215
+ */
216
+ placement: PropTypes.oneOf(['auto-end', 'auto-start', 'auto', 'bottom-end', 'bottom-start', 'bottom', 'left-end', 'left-start', 'left', 'right-end', 'right-start', 'right', 'top-end', 'top-start', 'top']),
217
+ /**
218
+ * Options provided to the [`Popper.js`](https://popper.js.org/docs/v2/constructors/#options) instance.
219
+ * @default {}
220
+ */
221
+ popperOptions: PropTypes.shape({
222
+ modifiers: PropTypes.array,
223
+ onFirstUpdate: PropTypes.func,
224
+ placement: PropTypes.oneOf(['auto-end', 'auto-start', 'auto', 'bottom-end', 'bottom-start', 'bottom', 'left-end', 'left-start', 'left', 'right-end', 'right-start', 'right', 'top-end', 'top-start', 'top']),
225
+ strategy: PropTypes.oneOf(['absolute', 'fixed'])
226
+ }),
227
+ /**
228
+ * A ref that points to the used popper instance.
229
+ */
230
+ popperRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
231
+ current: PropTypes.shape({
232
+ destroy: PropTypes.func.isRequired,
233
+ forceUpdate: PropTypes.func.isRequired,
234
+ setOptions: PropTypes.func.isRequired,
235
+ state: PropTypes.shape({
236
+ attributes: PropTypes.object.isRequired,
237
+ elements: PropTypes.object.isRequired,
238
+ modifiersData: PropTypes.object.isRequired,
239
+ options: PropTypes.object.isRequired,
240
+ orderedModifiers: PropTypes.arrayOf(PropTypes.object).isRequired,
241
+ placement: PropTypes.oneOf(['auto-end', 'auto-start', 'auto', 'bottom-end', 'bottom-start', 'bottom', 'left-end', 'left-start', 'left', 'right-end', 'right-start', 'right', 'top-end', 'top-start', 'top']).isRequired,
242
+ rects: PropTypes.object.isRequired,
243
+ reset: PropTypes.bool.isRequired,
244
+ scrollParents: PropTypes.object.isRequired,
245
+ strategy: PropTypes.oneOf(['absolute', 'fixed']).isRequired,
246
+ styles: PropTypes.object.isRequired
247
+ }).isRequired,
248
+ update: PropTypes.func.isRequired
249
+ })
250
+ })]),
251
+ /**
252
+ * The props used for each slot inside the Popper.
253
+ * @default {}
254
+ */
255
+ slotProps: PropTypes.object,
256
+ /**
257
+ * The components used for each slot inside the Popper.
258
+ * Either a string to use a HTML element or a component.
259
+ * @default {}
260
+ */
261
+ slots: PropTypes.object,
262
+ /**
263
+ * The system prop that allows defining system overrides as well as additional CSS styles.
264
+ */
265
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
266
+ /**
267
+ * Help supporting a react-transition-group/Transition component.
268
+ * @default false
269
+ */
270
+ transition: PropTypes.bool,
271
+ /**
272
+ * Select the kind of tooltip to display
273
+ * - 'item': Shows data about the item below the mouse.
274
+ * - 'axis': Shows values associated with the hovered x value
275
+ * - 'none': Does not display tooltip
276
+ * @default 'axis'
277
+ */
278
+ trigger: PropTypes.oneOf(['axis', 'item', 'none'])
279
+ } : void 0;
280
+ export { ChartsTooltipContainer };
@@ -1,5 +1,5 @@
1
1
  import { styled } from '@mui/material/styles';
2
- import { shouldForwardProp } from '@mui/system';
2
+ import { shouldForwardProp } from '@mui/system/createStyled';
3
3
  import { chartsTooltipClasses } from "./chartsTooltipClasses.js";
4
4
 
5
5
  /**
@@ -21,3 +21,4 @@ export interface ChartsTooltipClasses {
21
21
  export type ChartsTooltipClassKey = keyof Omit<ChartsTooltipClasses, 'markCell' | 'labelCell' | 'valueCell'>;
22
22
  export declare function getChartsTooltipUtilityClass(slot: string): string;
23
23
  export declare const chartsTooltipClasses: ChartsTooltipClasses;
24
+ export declare const useUtilityClasses: (classes?: Partial<ChartsTooltipClasses>) => Record<"cell" | "table" | "row" | "mark" | "root" | "paper" | "markCell" | "labelCell" | "valueCell", string>;
@@ -1,5 +1,21 @@
1
- import { unstable_generateUtilityClass as generateUtilityClass, unstable_generateUtilityClasses as generateUtilityClasses } from '@mui/utils';
1
+ import generateUtilityClass from '@mui/utils/generateUtilityClass';
2
+ import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
3
+ import composeClasses from '@mui/utils/composeClasses';
2
4
  export function getChartsTooltipUtilityClass(slot) {
3
5
  return generateUtilityClass('MuiChartsTooltip', slot);
4
6
  }
5
- export const chartsTooltipClasses = generateUtilityClasses('MuiChartsTooltip', ['root', 'paper', 'table', 'row', 'cell', 'mark', 'markCell', 'labelCell', 'valueCell']);
7
+ export const chartsTooltipClasses = generateUtilityClasses('MuiChartsTooltip', ['root', 'paper', 'table', 'row', 'cell', 'mark', 'markCell', 'labelCell', 'valueCell']);
8
+ export const useUtilityClasses = classes => {
9
+ const slots = {
10
+ root: ['root'],
11
+ paper: ['paper'],
12
+ table: ['table'],
13
+ row: ['row'],
14
+ cell: ['cell'],
15
+ mark: ['mark'],
16
+ markCell: ['markCell'],
17
+ labelCell: ['labelCell'],
18
+ valueCell: ['valueCell']
19
+ };
20
+ return composeClasses(slots, getChartsTooltipUtilityClass, classes);
21
+ };
@@ -1,9 +1,9 @@
1
1
  export * from './ChartsTooltip';
2
- export * from './chartsTooltipClasses';
2
+ export * from './ChartsTooltipContainer';
3
+ export type { ChartsTooltipClasses, ChartsTooltipClassKey } from './chartsTooltipClasses';
4
+ export { getChartsTooltipUtilityClass, chartsTooltipClasses } from './chartsTooltipClasses';
3
5
  export * from './ChartsAxisTooltipContent';
4
6
  export * from './ChartsItemTooltipContent';
5
- export * from './DefaultChartsAxisTooltipContent';
6
- export * from './DefaultChartsItemTooltipContent';
7
7
  export * from './ChartsTooltipTable';
8
8
  export * from './useItemTooltip';
9
9
  export * from './useAxisTooltip';
@@ -1,9 +1,8 @@
1
1
  export * from "./ChartsTooltip.js";
2
- export * from "./chartsTooltipClasses.js";
2
+ export * from "./ChartsTooltipContainer.js";
3
+ export { getChartsTooltipUtilityClass, chartsTooltipClasses } from "./chartsTooltipClasses.js";
3
4
  export * from "./ChartsAxisTooltipContent.js";
4
5
  export * from "./ChartsItemTooltipContent.js";
5
- export * from "./DefaultChartsAxisTooltipContent.js";
6
- export * from "./DefaultChartsItemTooltipContent.js";
7
6
  export * from "./ChartsTooltipTable.js";
8
7
  export * from "./useItemTooltip.js";
9
8
  export * from "./useAxisTooltip.js";
@@ -1,8 +1,8 @@
1
- import { AxisInteractionData } from '../context/InteractionProvider';
2
1
  import { SeriesId } from '../models/seriesType/common';
3
2
  import { CartesianChartSeriesType, ChartsSeriesConfig } from '../models/seriesType/config';
4
3
  export interface UseAxisTooltipReturnValue<SeriesT extends CartesianChartSeriesType = CartesianChartSeriesType, AxisValueT extends string | number | Date = string | number | Date> {
5
- identifier: AxisInteractionData;
4
+ axisDirection: 'x' | 'y';
5
+ dataIndex: number;
6
6
  seriesItems: SeriesItem<SeriesT>[];
7
7
  axisValue: AxisValueT;
8
8
  axisFormattedValue: string;
@@ -1,34 +1,33 @@
1
1
  'use client';
2
2
 
3
3
  import * as React from 'react';
4
- import { InteractionContext } from "../context/InteractionProvider.js";
5
4
  import { useSeries } from "../hooks/useSeries.js";
6
5
  import { useCartesianContext } from "../context/CartesianProvider/index.js";
7
6
  import { ZAxisContext } from "../context/ZAxisContextProvider.js";
8
7
  import { useColorProcessor } from "../context/PluginProvider/useColorProcessor.js";
8
+ import { useStore } from "../internals/store/useStore.js";
9
+ import { useSelector } from "../internals/store/useSelector.js";
9
10
  import { getLabel } from "../internals/getLabel.js";
10
11
  import { isCartesianSeriesType } from "../internals/isCartesian.js";
11
12
  import { utcFormatter } from "./utils.js";
13
+ import { useXAxis, useYAxis } from "../hooks/useAxis.js";
14
+ import { selectorChartsInteractionXAxis, selectorChartsInteractionYAxis } from "../internals/plugins/featurePlugins/useChartInteraction/index.js";
12
15
  export function useAxisTooltip() {
13
- const {
14
- axis
15
- } = React.useContext(InteractionContext);
16
+ const defaultXAxis = useXAxis();
17
+ const defaultYAxis = useYAxis();
18
+ const xAxisHasData = defaultXAxis.data !== undefined && defaultXAxis.data.length !== 0;
19
+ const store = useStore();
20
+ const axisData = useSelector(store, xAxisHasData ? selectorChartsInteractionXAxis : selectorChartsInteractionYAxis);
16
21
  const series = useSeries();
17
22
  const {
18
23
  xAxis,
19
- yAxis,
20
- xAxisIds,
21
- yAxisIds
24
+ yAxis
22
25
  } = useCartesianContext();
23
26
  const {
24
27
  zAxis,
25
28
  zAxisIds
26
29
  } = React.useContext(ZAxisContext);
27
30
  const colorProcessors = useColorProcessor();
28
-
29
- // By default use the x-axis
30
- const isXaxis = axis.x !== null && axis.x.index !== -1;
31
- const axisData = isXaxis ? axis.x && axis.x : axis.y && axis.y;
32
31
  if (axisData === null) {
33
32
  return null;
34
33
  }
@@ -36,8 +35,8 @@ export function useAxisTooltip() {
36
35
  index: dataIndex,
37
36
  value: axisValue
38
37
  } = axisData;
39
- const USED_AXIS_ID = isXaxis ? xAxisIds[0] : yAxisIds[0];
40
- const usedAxis = isXaxis ? xAxis[USED_AXIS_ID] : yAxis[USED_AXIS_ID];
38
+ const USED_AXIS_ID = xAxisHasData ? defaultXAxis.id : defaultYAxis.id;
39
+ const usedAxis = xAxisHasData ? defaultXAxis : defaultYAxis;
41
40
  const relevantSeries = Object.keys(series).filter(isCartesianSeriesType).flatMap(seriesType => {
42
41
  const seriesOfType = series[seriesType];
43
42
  if (!seriesOfType) {
@@ -47,14 +46,14 @@ export function useAxisTooltip() {
47
46
  const seriesToAdd = seriesOfType.series[seriesId];
48
47
  const providedXAxisId = seriesToAdd.xAxisId;
49
48
  const providedYAxisId = seriesToAdd.yAxisId;
50
- const axisKey = isXaxis ? providedXAxisId : providedYAxisId;
49
+ const axisKey = xAxisHasData ? providedXAxisId : providedYAxisId;
51
50
 
52
51
  // Test if the series uses the default axis
53
52
  if (axisKey === undefined || axisKey === USED_AXIS_ID) {
54
- const xAxisId = providedXAxisId ?? xAxisIds[0];
55
- const yAxisId = providedYAxisId ?? yAxisIds[0];
56
- const zAxisId = seriesToAdd.zAxisId ?? zAxisIds[0];
57
- const color = colorProcessors[seriesType]?.(seriesToAdd, xAxis[xAxisId], yAxis[yAxisId], zAxisId && zAxis[zAxisId])(dataIndex) ?? '';
53
+ const xAxisId = providedXAxisId ?? defaultXAxis.id;
54
+ const yAxisId = providedYAxisId ?? defaultYAxis.id;
55
+ const zAxisId = 'zAxisId' in seriesToAdd ? seriesToAdd.zAxisId : zAxisIds[0];
56
+ const color = colorProcessors[seriesType]?.(seriesToAdd, xAxis[xAxisId], yAxis[yAxisId], zAxisId ? zAxis[zAxisId] : undefined)(dataIndex) ?? '';
58
57
  const value = seriesToAdd.data[dataIndex] ?? null;
59
58
  const formattedValue = seriesToAdd.valueFormatter(value, {
60
59
  dataIndex
@@ -76,7 +75,8 @@ export function useAxisTooltip() {
76
75
  location: 'tooltip'
77
76
  });
78
77
  return {
79
- identifier: axis,
78
+ axisDirection: xAxisHasData ? 'x' : 'y',
79
+ dataIndex,
80
80
  seriesItems: relevantSeries,
81
81
  axisValue,
82
82
  axisFormattedValue
@@ -1,7 +1,6 @@
1
- import { ItemInteractionData } from '../context/InteractionProvider';
2
- import { ChartSeriesType, ChartsSeriesConfig } from '../models/seriesType/config';
1
+ import { ChartItemIdentifier, ChartSeriesType, ChartsSeriesConfig } from '../models/seriesType/config';
3
2
  export interface UseItemTooltipReturnValue<T extends ChartSeriesType> {
4
- identifier: ItemInteractionData<T>;
3
+ identifier: ChartItemIdentifier<T>;
5
4
  color: string;
6
5
  label: string | undefined;
7
6
  value: ChartsSeriesConfig[T]['valueType'];
@@ -2,16 +2,17 @@
2
2
 
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import * as React from 'react';
5
- import { InteractionContext } from "../context/InteractionProvider.js";
6
5
  import { useSeries } from "../hooks/useSeries.js";
7
6
  import { useCartesianContext } from "../context/CartesianProvider/index.js";
8
7
  import { ZAxisContext } from "../context/ZAxisContextProvider.js";
9
8
  import { useColorProcessor } from "../context/PluginProvider/useColorProcessor.js";
10
9
  import { getLabel } from "../internals/getLabel.js";
10
+ import { selectorChartsInteractionItem } from "../internals/plugins/featurePlugins/useChartInteraction/index.js";
11
+ import { useSelector } from "../internals/store/useSelector.js";
12
+ import { useStore } from "../internals/store/useStore.js";
11
13
  export function useItemTooltip() {
12
- const {
13
- item
14
- } = React.useContext(InteractionContext);
14
+ const store = useStore();
15
+ const item = useSelector(store, selectorChartsInteractionItem);
15
16
  const series = useSeries();
16
17
  const {
17
18
  xAxis,
@@ -1,5 +1,3 @@
1
- import { AxisInteractionData, ItemInteractionData } from '../context/InteractionProvider';
2
- import { ChartSeriesType } from '../models/seriesType/config';
3
1
  type MousePosition = {
4
2
  x: number;
5
3
  y: number;
@@ -14,6 +12,5 @@ export declare function useMouseTracker(): UseMouseTrackerReturnValue;
14
12
  type PointerType = Pick<MousePosition, 'height' | 'pointerType'>;
15
13
  export declare function usePointerType(): null | PointerType;
16
14
  export type TriggerOptions = 'item' | 'axis' | 'none';
17
- export declare function getTooltipHasData(trigger: TriggerOptions, displayedData: null | AxisInteractionData | ItemInteractionData<ChartSeriesType>): boolean;
18
15
  export declare function utcFormatter(v: string | number | Date): string;
19
16
  export {};
@@ -74,14 +74,6 @@ export function usePointerType() {
74
74
  }, [svgRef]);
75
75
  return pointerType;
76
76
  }
77
- export function getTooltipHasData(trigger, displayedData) {
78
- if (trigger === 'item') {
79
- return displayedData !== null;
80
- }
81
- const hasAxisXData = displayedData.x !== null;
82
- const hasAxisYData = displayedData.y !== null;
83
- return hasAxisXData || hasAxisYData;
84
- }
85
77
  export function utcFormatter(v) {
86
78
  if (v instanceof Date) {
87
79
  return v.toUTCString();
@@ -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
5
  import PropTypes from 'prop-types';
5
6
  import { Delaunay } from '@mui/x-charts-vendor/d3-delaunay';
6
7
  import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
7
- import { InteractionContext } from "../context/InteractionProvider.js";
8
8
  import { useCartesianContext } from "../context/CartesianProvider/index.js";
9
9
  import { getValueToPositionMapper } from "../hooks/useScale.js";
10
+ import { useStore } from "../internals/store/useStore.js";
10
11
  import { getSVGPoint } from "../internals/getSVGPoint.js";
11
12
  import { useDrawingArea, useSvgRef } from "../hooks/index.js";
12
13
  import { useHighlighted } from "../context/index.js";
@@ -25,9 +26,7 @@ function ChartsVoronoiHandler(props) {
25
26
  xAxisIds,
26
27
  yAxisIds
27
28
  } = useCartesianContext();
28
- const {
29
- dispatch
30
- } = React.useContext(InteractionContext);
29
+ const store = useStore();
31
30
  const {
32
31
  series,
33
32
  seriesOrder
@@ -42,17 +41,19 @@ function ChartsVoronoiHandler(props) {
42
41
  const defaultXAxisId = xAxisIds[0];
43
42
  const defaultYAxisId = yAxisIds[0];
44
43
  useEnhancedEffect(() => {
45
- dispatch({
46
- type: 'updateVoronoiUsage',
47
- useVoronoiInteraction: true
48
- });
44
+ store.update(prev => _extends({}, prev, {
45
+ interaction: _extends({}, prev.interaction, {
46
+ useVoronoiInteraction: true
47
+ })
48
+ }));
49
49
  return () => {
50
- dispatch({
51
- type: 'updateVoronoiUsage',
52
- useVoronoiInteraction: false
53
- });
50
+ store.update(prev => _extends({}, prev, {
51
+ interaction: _extends({}, prev.interaction, {
52
+ useVoronoiInteraction: false
53
+ })
54
+ }));
54
55
  };
55
- }, [dispatch]);
56
+ }, [store]);
56
57
  useEnhancedEffect(() => {
57
58
  // This effect generate and store the Delaunay object that's used to map coordinate to closest point.
58
59
 
@@ -100,10 +101,10 @@ function ChartsVoronoiHandler(props) {
100
101
  lastFind.current = undefined;
101
102
  }, [defaultXAxisId, defaultYAxisId, series, seriesOrder, xAxis, yAxis, drawingArea]);
102
103
  React.useEffect(() => {
103
- const element = svgRef.current;
104
- if (element === null) {
104
+ if (svgRef.current === null) {
105
105
  return undefined;
106
106
  }
107
+ const element = svgRef.current;
107
108
  function getClosestPoint(event) {
108
109
  // Get mouse coordinate in global SVG space
109
110
  const svgPoint = getSVGPoint(element, event);
@@ -141,27 +142,38 @@ function ChartsVoronoiHandler(props) {
141
142
  };
142
143
  }
143
144
  const handleMouseLeave = () => {
144
- dispatch({
145
- type: 'exitChart'
146
- });
145
+ store.update(prev => _extends({}, prev, {
146
+ interaction: _extends({}, prev.interaction, {
147
+ axis: {
148
+ x: null,
149
+ y: null
150
+ },
151
+ item: null
152
+ })
153
+ }));
147
154
  clearHighlighted();
148
155
  };
149
156
  const handleMouseMove = event => {
150
157
  const closestPoint = getClosestPoint(event);
151
158
  if (closestPoint === 'outside-chart') {
152
- dispatch({
153
- type: 'exitChart'
154
- });
159
+ store.update(prev => _extends({}, prev, {
160
+ interaction: _extends({}, prev.interaction, {
161
+ axis: {
162
+ x: null,
163
+ y: null
164
+ },
165
+ item: null
166
+ })
167
+ }));
155
168
  clearHighlighted();
156
169
  return;
157
170
  }
158
171
  if (closestPoint === 'outside-voronoi-max-radius' || closestPoint === 'no-point-found') {
159
- dispatch({
160
- type: 'leaveItem',
161
- data: {
162
- type: 'scatter'
163
- }
164
- });
172
+ store.update(prev => _extends({}, prev, {
173
+ interaction: _extends({}, prev.interaction, {
174
+ item: null
175
+ })
176
+ }));
165
177
  clearHighlighted();
166
178
  return;
167
179
  }
@@ -169,14 +181,15 @@ function ChartsVoronoiHandler(props) {
169
181
  seriesId,
170
182
  dataIndex
171
183
  } = closestPoint;
172
- dispatch({
173
- type: 'enterItem',
174
- data: {
175
- type: 'scatter',
176
- seriesId,
177
- dataIndex
178
- }
179
- });
184
+ store.update(prev => _extends({}, prev, {
185
+ interaction: _extends({}, prev.interaction, {
186
+ item: {
187
+ type: 'scatter',
188
+ seriesId,
189
+ dataIndex
190
+ }
191
+ })
192
+ }));
180
193
  setHighlighted({
181
194
  seriesId,
182
195
  dataIndex
@@ -209,7 +222,7 @@ function ChartsVoronoiHandler(props) {
209
222
  element.removeEventListener('pointermove', handleMouseMove);
210
223
  element.removeEventListener('click', handleMouseClick);
211
224
  };
212
- }, [svgRef, dispatch, yAxis, xAxis, voronoiMaxRadius, onItemClick, setHighlighted, clearHighlighted, drawingArea]);
225
+ }, [svgRef, yAxis, xAxis, voronoiMaxRadius, onItemClick, setHighlighted, clearHighlighted, drawingArea, store]);
213
226
 
214
227
  // eslint-disable-next-line react/jsx-no-useless-fragment
215
228
  return /*#__PURE__*/_jsx(React.Fragment, {});