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

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 (335) 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 -31
  5. package/BarChart/BarElement.d.ts +5 -1342
  6. package/BarChart/BarElement.js +10 -20
  7. package/BarChart/BarPlot.js +12 -2
  8. package/BarChart/useBarChartProps.d.ts +0 -2
  9. package/BarChart/useBarChartProps.js +2 -8
  10. package/CHANGELOG.md +429 -5
  11. package/ChartContainer/ChartContainer.d.ts +2 -19
  12. package/ChartContainer/ChartContainer.js +10 -20
  13. package/ChartContainer/ResizableContainer.d.ts +17 -4
  14. package/ChartContainer/ResizableContainer.js +36 -2
  15. package/ChartContainer/useChartContainerProps.d.ts +6 -7
  16. package/ChartContainer/useChartContainerProps.js +14 -28
  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/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +9 -7
  38. package/ChartsSurface/ChartsSurface.d.ts +0 -15
  39. package/ChartsSurface/ChartsSurface.js +35 -34
  40. package/ChartsTooltip/ChartTooltip.types.d.ts +15 -0
  41. package/ChartsTooltip/ChartTooltip.types.js +1 -0
  42. package/ChartsTooltip/ChartsAxisTooltipContent.d.ts +7 -39
  43. package/ChartsTooltip/ChartsAxisTooltipContent.js +83 -72
  44. package/ChartsTooltip/ChartsItemTooltipContent.d.ts +5 -28
  45. package/ChartsTooltip/ChartsItemTooltipContent.js +54 -44
  46. package/ChartsTooltip/ChartsTooltip.d.ts +3 -69
  47. package/ChartsTooltip/ChartsTooltip.js +161 -145
  48. package/ChartsTooltip/ChartsTooltipContainer.d.ts +33 -0
  49. package/ChartsTooltip/ChartsTooltipContainer.js +298 -0
  50. package/ChartsTooltip/chartsTooltipClasses.d.ts +1 -0
  51. package/ChartsTooltip/chartsTooltipClasses.js +18 -2
  52. package/ChartsTooltip/index.d.ts +3 -3
  53. package/ChartsTooltip/index.js +2 -3
  54. package/ChartsTooltip/useAxisTooltip.d.ts +2 -2
  55. package/ChartsTooltip/useAxisTooltip.js +19 -19
  56. package/ChartsTooltip/useItemTooltip.d.ts +1 -1
  57. package/ChartsTooltip/useItemTooltip.js +5 -4
  58. package/ChartsTooltip/utils.d.ts +0 -3
  59. package/ChartsTooltip/utils.js +0 -8
  60. package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +47 -34
  61. package/Gauge/Gauge.d.ts +1 -1
  62. package/Gauge/Gauge.js +0 -6
  63. package/Gauge/GaugeContainer.d.ts +3 -3
  64. package/Gauge/GaugeContainer.js +60 -61
  65. package/LineChart/AnimatedArea.d.ts +0 -1333
  66. package/LineChart/AnimatedArea.js +9 -18
  67. package/LineChart/AnimatedLine.d.ts +0 -1333
  68. package/LineChart/AnimatedLine.js +9 -20
  69. package/LineChart/AreaPlot.js +12 -2
  70. package/LineChart/CircleMarkElement.js +6 -5
  71. package/LineChart/LineChart.d.ts +4 -10
  72. package/LineChart/LineChart.js +3 -32
  73. package/LineChart/LineHighlightPlot.js +6 -5
  74. package/LineChart/LinePlot.js +12 -2
  75. package/LineChart/MarkElement.js +6 -5
  76. package/LineChart/useLineChartProps.d.ts +0 -2
  77. package/LineChart/useLineChartProps.js +2 -8
  78. package/PieChart/PieChart.d.ts +3 -9
  79. package/PieChart/PieChart.js +5 -37
  80. package/PieChart/PiePlot.js +2 -2
  81. package/PieChart/getPieCoordinates.d.ts +2 -2
  82. package/README.md +2 -2
  83. package/ScatterChart/Scatter.js +6 -5
  84. package/ScatterChart/ScatterChart.d.ts +4 -10
  85. package/ScatterChart/ScatterChart.js +5 -32
  86. package/ScatterChart/useScatterChartProps.d.ts +0 -2
  87. package/ScatterChart/useScatterChartProps.js +1 -9
  88. package/SparkLineChart/SparkLineChart.d.ts +3 -4
  89. package/SparkLineChart/SparkLineChart.js +4 -31
  90. package/context/ChartDataProvider/ChartDataProvider.d.ts +9 -19
  91. package/context/ChartDataProvider/ChartDataProvider.js +30 -43
  92. package/context/ChartDataProvider/useChartDataProviderProps.d.ts +7 -10
  93. package/context/ChartDataProvider/useChartDataProviderProps.js +22 -42
  94. package/context/{DrawingProvider.d.ts → DrawingAreaProvider/DrawingArea.types.d.ts} +3 -14
  95. package/context/DrawingAreaProvider/DrawingArea.types.js +1 -0
  96. package/context/DrawingAreaProvider/DrawingAreaContext.d.ts +8 -0
  97. package/context/DrawingAreaProvider/DrawingAreaContext.js +16 -0
  98. package/context/DrawingAreaProvider/DrawingAreaProvider.d.ts +3 -0
  99. package/context/{DrawingProvider.js → DrawingAreaProvider/DrawingAreaProvider.js} +11 -41
  100. package/context/DrawingAreaProvider/index.d.ts +3 -0
  101. package/context/DrawingAreaProvider/index.js +3 -0
  102. package/context/InteractionProvider.d.ts +5 -48
  103. package/context/InteractionProvider.js +8 -64
  104. package/context/InteractionSelectors.d.ts +359 -0
  105. package/context/InteractionSelectors.js +12 -0
  106. package/context/SizeProvider/Size.types.d.ts +30 -0
  107. package/context/SizeProvider/Size.types.js +1 -0
  108. package/context/SizeProvider/SizeContext.d.ts +4 -0
  109. package/context/SizeProvider/SizeContext.js +13 -0
  110. package/context/SizeProvider/SizeProvider.d.ts +11 -0
  111. package/context/SizeProvider/SizeProvider.js +26 -0
  112. package/context/SizeProvider/index.d.ts +4 -0
  113. package/context/SizeProvider/index.js +4 -0
  114. package/{ChartContainer → context/SizeProvider}/useChartContainerDimensions.d.ts +4 -1
  115. package/{modern/ChartContainer → context/SizeProvider}/useChartContainerDimensions.js +11 -5
  116. package/context/SizeProvider/useSize.d.ts +5 -0
  117. package/context/SizeProvider/useSize.js +13 -0
  118. package/context/SvgRefProvider/SvgRef.types.d.ts +8 -0
  119. package/context/SvgRefProvider/SvgRef.types.js +1 -0
  120. package/context/SvgRefProvider/SvgRefContext.d.ts +4 -0
  121. package/context/SvgRefProvider/SvgRefContext.js +17 -0
  122. package/context/SvgRefProvider/SvgRefProvider.d.ts +3 -0
  123. package/context/SvgRefProvider/SvgRefProvider.js +24 -0
  124. package/context/SvgRefProvider/index.d.ts +4 -0
  125. package/context/SvgRefProvider/index.js +4 -0
  126. package/context/SvgRefProvider/useSurfaceRef.d.ts +2 -0
  127. package/context/SvgRefProvider/useSurfaceRef.js +14 -0
  128. package/context/index.d.ts +2 -0
  129. package/context/index.js +2 -1
  130. package/hooks/useAxisEvents.js +32 -19
  131. package/hooks/useChartId.js +2 -2
  132. package/hooks/useDrawingArea.d.ts +2 -2
  133. package/hooks/useDrawingArea.js +2 -2
  134. package/hooks/useInteractionItemProps.js +19 -12
  135. package/hooks/useSvgRef.js +3 -3
  136. package/index.js +1 -1
  137. package/internals/components/ChartsAxesGradients/ChartsAxesGradients.d.ts +1 -1
  138. package/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +9 -4
  139. package/internals/computeAxisValue.d.ts +2 -2
  140. package/internals/index.d.ts +3 -2
  141. package/internals/index.js +3 -2
  142. package/internals/plugins/models/index.d.ts +35 -0
  143. package/internals/plugins/models/index.js +1 -0
  144. package/internals/plugins/utils/ChartStore.d.ts +12 -0
  145. package/internals/plugins/utils/ChartStore.js +26 -0
  146. package/internals/plugins/utils/ChartsStore.d.ts +12 -0
  147. package/internals/plugins/utils/ChartsStore.js +26 -0
  148. package/internals/plugins/utils/selectors.d.ts +9 -0
  149. package/internals/plugins/utils/selectors.js +37 -0
  150. package/internals/useCharts.d.ts +6 -0
  151. package/internals/useCharts.js +29 -0
  152. package/internals/useSelector.d.ts +4 -0
  153. package/internals/useSelector.js +6 -0
  154. package/internals/useStore.d.ts +2 -0
  155. package/internals/useStore.js +17 -0
  156. package/modern/BarChart/AnimatedBarElement.js +21 -0
  157. package/modern/BarChart/BarChart.js +3 -31
  158. package/modern/BarChart/BarElement.js +10 -20
  159. package/modern/BarChart/BarPlot.js +12 -2
  160. package/modern/BarChart/useBarChartProps.js +2 -8
  161. package/modern/ChartContainer/ChartContainer.js +10 -20
  162. package/modern/ChartContainer/ResizableContainer.js +36 -2
  163. package/modern/ChartContainer/useChartContainerProps.js +14 -28
  164. package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +10 -96
  165. package/modern/ChartsAxisHighlight/ChartsAxisHighlight.types.js +1 -0
  166. package/modern/ChartsAxisHighlight/ChartsAxisHighlightPath.js +34 -0
  167. package/modern/ChartsAxisHighlight/ChartsXAxisHighlight.js +53 -0
  168. package/modern/ChartsAxisHighlight/ChartsYAxisHighlight.js +53 -0
  169. package/modern/ChartsAxisHighlight/chartsAxisHighlightClasses.js +6 -0
  170. package/modern/ChartsAxisHighlight/index.js +4 -1
  171. package/modern/ChartsGrid/ChartsGrid.js +1 -1
  172. package/modern/ChartsGrid/ChartsHorizontalGrid.js +3 -3
  173. package/modern/ChartsGrid/ChartsVerticalGrid.js +3 -3
  174. package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +9 -7
  175. package/modern/ChartsSurface/ChartsSurface.js +35 -34
  176. package/modern/ChartsTooltip/ChartTooltip.types.js +1 -0
  177. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +83 -72
  178. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +54 -44
  179. package/modern/ChartsTooltip/ChartsTooltip.js +161 -145
  180. package/modern/ChartsTooltip/ChartsTooltipContainer.js +298 -0
  181. package/modern/ChartsTooltip/chartsTooltipClasses.js +18 -2
  182. package/modern/ChartsTooltip/index.js +2 -3
  183. package/modern/ChartsTooltip/useAxisTooltip.js +19 -19
  184. package/modern/ChartsTooltip/useItemTooltip.js +5 -4
  185. package/modern/ChartsTooltip/utils.js +0 -8
  186. package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +47 -34
  187. package/modern/Gauge/Gauge.js +0 -6
  188. package/modern/Gauge/GaugeContainer.js +60 -61
  189. package/modern/LineChart/AnimatedArea.js +9 -18
  190. package/modern/LineChart/AnimatedLine.js +9 -20
  191. package/modern/LineChart/AreaPlot.js +12 -2
  192. package/modern/LineChart/CircleMarkElement.js +6 -5
  193. package/modern/LineChart/LineChart.js +3 -32
  194. package/modern/LineChart/LineHighlightPlot.js +6 -5
  195. package/modern/LineChart/LinePlot.js +12 -2
  196. package/modern/LineChart/MarkElement.js +6 -5
  197. package/modern/LineChart/useLineChartProps.js +2 -8
  198. package/modern/PieChart/PieChart.js +5 -37
  199. package/modern/PieChart/PiePlot.js +2 -2
  200. package/modern/ScatterChart/Scatter.js +6 -5
  201. package/modern/ScatterChart/ScatterChart.js +5 -32
  202. package/modern/ScatterChart/useScatterChartProps.js +1 -9
  203. package/modern/SparkLineChart/SparkLineChart.js +4 -31
  204. package/modern/context/ChartDataProvider/ChartDataProvider.js +30 -43
  205. package/modern/context/ChartDataProvider/useChartDataProviderProps.js +22 -42
  206. package/modern/context/DrawingAreaProvider/DrawingArea.types.js +1 -0
  207. package/modern/context/DrawingAreaProvider/DrawingAreaContext.js +16 -0
  208. package/modern/context/{DrawingProvider.js → DrawingAreaProvider/DrawingAreaProvider.js} +11 -41
  209. package/modern/context/DrawingAreaProvider/index.js +3 -0
  210. package/modern/context/InteractionProvider.js +8 -64
  211. package/modern/context/InteractionSelectors.js +12 -0
  212. package/modern/context/SizeProvider/Size.types.js +1 -0
  213. package/modern/context/SizeProvider/SizeContext.js +13 -0
  214. package/modern/context/SizeProvider/SizeProvider.js +26 -0
  215. package/modern/context/SizeProvider/index.js +4 -0
  216. package/{ChartContainer → modern/context/SizeProvider}/useChartContainerDimensions.js +11 -5
  217. package/modern/context/SizeProvider/useSize.js +13 -0
  218. package/modern/context/SvgRefProvider/SvgRef.types.js +1 -0
  219. package/modern/context/SvgRefProvider/SvgRefContext.js +17 -0
  220. package/modern/context/SvgRefProvider/SvgRefProvider.js +24 -0
  221. package/modern/context/SvgRefProvider/index.js +4 -0
  222. package/modern/context/SvgRefProvider/useSurfaceRef.js +14 -0
  223. package/modern/context/index.js +2 -1
  224. package/modern/hooks/useAxisEvents.js +32 -19
  225. package/modern/hooks/useChartId.js +2 -2
  226. package/modern/hooks/useDrawingArea.js +2 -2
  227. package/modern/hooks/useInteractionItemProps.js +19 -12
  228. package/modern/hooks/useSvgRef.js +3 -3
  229. package/modern/index.js +1 -1
  230. package/modern/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +9 -4
  231. package/modern/internals/index.js +3 -2
  232. package/modern/internals/plugins/models/index.js +1 -0
  233. package/modern/internals/plugins/utils/ChartStore.js +26 -0
  234. package/modern/internals/plugins/utils/ChartsStore.js +26 -0
  235. package/modern/internals/plugins/utils/selectors.js +37 -0
  236. package/modern/internals/useCharts.js +29 -0
  237. package/modern/internals/useSelector.js +6 -0
  238. package/modern/internals/useStore.js +17 -0
  239. package/node/BarChart/AnimatedBarElement.js +28 -0
  240. package/node/BarChart/BarChart.js +3 -31
  241. package/node/BarChart/BarElement.js +11 -21
  242. package/node/BarChart/BarPlot.js +11 -1
  243. package/node/BarChart/useBarChartProps.js +2 -8
  244. package/node/ChartContainer/ChartContainer.js +10 -20
  245. package/node/ChartContainer/ResizableContainer.js +39 -3
  246. package/node/ChartContainer/useChartContainerProps.js +14 -28
  247. package/node/ChartsAxisHighlight/ChartsAxisHighlight.js +12 -100
  248. package/node/ChartsAxisHighlight/ChartsAxisHighlight.types.js +5 -0
  249. package/node/ChartsAxisHighlight/ChartsAxisHighlightPath.js +40 -0
  250. package/node/ChartsAxisHighlight/ChartsXAxisHighlight.js +57 -0
  251. package/node/ChartsAxisHighlight/ChartsYAxisHighlight.js +57 -0
  252. package/node/ChartsAxisHighlight/chartsAxisHighlightClasses.js +14 -0
  253. package/node/ChartsAxisHighlight/index.js +33 -0
  254. package/node/ChartsGrid/ChartsGrid.js +2 -2
  255. package/node/ChartsGrid/ChartsHorizontalGrid.js +4 -4
  256. package/node/ChartsGrid/ChartsVerticalGrid.js +4 -4
  257. package/node/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +9 -7
  258. package/node/ChartsSurface/ChartsSurface.js +35 -34
  259. package/node/ChartsTooltip/ChartTooltip.types.js +5 -0
  260. package/node/ChartsTooltip/ChartsAxisTooltipContent.js +83 -73
  261. package/node/ChartsTooltip/ChartsItemTooltipContent.js +54 -45
  262. package/node/ChartsTooltip/ChartsTooltip.js +160 -144
  263. package/node/ChartsTooltip/ChartsTooltipContainer.js +304 -0
  264. package/node/ChartsTooltip/chartsTooltipClasses.js +22 -3
  265. package/node/ChartsTooltip/index.js +19 -28
  266. package/node/ChartsTooltip/useAxisTooltip.js +19 -19
  267. package/node/ChartsTooltip/useItemTooltip.js +5 -4
  268. package/node/ChartsTooltip/utils.js +0 -9
  269. package/node/ChartsVoronoiHandler/ChartsVoronoiHandler.js +48 -35
  270. package/node/Gauge/Gauge.js +0 -6
  271. package/node/Gauge/GaugeContainer.js +60 -61
  272. package/node/LineChart/AnimatedArea.js +9 -19
  273. package/node/LineChart/AnimatedLine.js +9 -21
  274. package/node/LineChart/AreaPlot.js +11 -1
  275. package/node/LineChart/CircleMarkElement.js +6 -5
  276. package/node/LineChart/LineChart.js +3 -32
  277. package/node/LineChart/LineHighlightPlot.js +6 -5
  278. package/node/LineChart/LinePlot.js +11 -1
  279. package/node/LineChart/MarkElement.js +6 -5
  280. package/node/LineChart/useLineChartProps.js +2 -8
  281. package/node/PieChart/PieChart.js +5 -37
  282. package/node/PieChart/PiePlot.js +2 -2
  283. package/node/ScatterChart/Scatter.js +6 -5
  284. package/node/ScatterChart/ScatterChart.js +5 -32
  285. package/node/ScatterChart/useScatterChartProps.js +1 -9
  286. package/node/SparkLineChart/SparkLineChart.js +4 -31
  287. package/node/context/ChartDataProvider/ChartDataProvider.js +30 -43
  288. package/node/context/ChartDataProvider/useChartDataProviderProps.js +22 -44
  289. package/node/context/DrawingAreaProvider/DrawingArea.types.js +5 -0
  290. package/node/context/DrawingAreaProvider/DrawingAreaContext.js +22 -0
  291. package/node/context/{DrawingProvider.js → DrawingAreaProvider/DrawingAreaProvider.js} +12 -44
  292. package/node/context/DrawingAreaProvider/index.js +38 -0
  293. package/node/context/InteractionProvider.js +9 -66
  294. package/node/context/InteractionSelectors.js +18 -0
  295. package/node/context/SizeProvider/Size.types.js +5 -0
  296. package/node/context/SizeProvider/SizeContext.js +20 -0
  297. package/node/context/SizeProvider/SizeProvider.js +29 -0
  298. package/node/context/SizeProvider/index.js +49 -0
  299. package/node/{ChartContainer → context/SizeProvider}/useChartContainerDimensions.js +11 -5
  300. package/node/context/SizeProvider/useSize.js +20 -0
  301. package/node/context/SvgRefProvider/SvgRef.types.js +5 -0
  302. package/node/context/SvgRefProvider/SvgRefContext.js +23 -0
  303. package/node/context/SvgRefProvider/SvgRefProvider.js +31 -0
  304. package/node/context/SvgRefProvider/index.js +49 -0
  305. package/node/context/SvgRefProvider/useSurfaceRef.js +20 -0
  306. package/node/context/index.js +10 -2
  307. package/node/hooks/useAxisEvents.js +33 -19
  308. package/node/hooks/useChartId.js +2 -2
  309. package/node/hooks/useDrawingArea.js +2 -2
  310. package/node/hooks/useInteractionItemProps.js +20 -13
  311. package/node/hooks/useSvgRef.js +3 -3
  312. package/node/index.js +1 -1
  313. package/node/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +9 -4
  314. package/node/internals/index.js +28 -16
  315. package/node/internals/plugins/models/index.js +5 -0
  316. package/node/internals/plugins/utils/ChartStore.js +33 -0
  317. package/node/internals/plugins/utils/ChartsStore.js +33 -0
  318. package/node/internals/plugins/utils/selectors.js +44 -0
  319. package/node/internals/useCharts.js +36 -0
  320. package/node/internals/useSelector.js +13 -0
  321. package/node/internals/useStore.js +24 -0
  322. package/package.json +7 -5
  323. package/themeAugmentation/props.d.ts +1 -2
  324. package/ChartsTooltip/DefaultChartsAxisTooltipContent.d.ts +0 -7
  325. package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +0 -123
  326. package/ChartsTooltip/DefaultChartsItemTooltipContent.d.ts +0 -8
  327. package/ChartsTooltip/DefaultChartsItemTooltipContent.js +0 -92
  328. package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +0 -123
  329. package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +0 -92
  330. package/node/ChartsTooltip/DefaultChartsAxisTooltipContent.js +0 -129
  331. package/node/ChartsTooltip/DefaultChartsItemTooltipContent.js +0 -98
  332. /package/ChartsGrid/{styledCommonents.d.ts → styledComponents.d.ts} +0 -0
  333. /package/ChartsGrid/{styledCommonents.js → styledComponents.js} +0 -0
  334. /package/modern/ChartsGrid/{styledCommonents.js → styledComponents.js} +0 -0
  335. /package/node/ChartsGrid/{styledCommonents.js → styledComponents.js} +0 -0
@@ -5,9 +5,11 @@ import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import { getValueToPositionMapper } from "../hooks/useScale.js";
7
7
  import { useInteractionItemProps } from "../hooks/useInteractionItemProps.js";
8
- import { InteractionContext } from "../context/InteractionProvider.js";
8
+ import { useStore } from "../internals/useStore.js";
9
+ import { useSelector } from "../internals/useSelector.js";
9
10
  import { useHighlighted } from "../context/index.js";
10
11
  import { useDrawingArea } from "../hooks/useDrawingArea.js";
12
+ import { selectorChartsInteractionIsVoronoiEnabled } from "../context/InteractionSelectors.js";
11
13
  import { jsx as _jsx } from "react/jsx-runtime";
12
14
  /**
13
15
  * Demos:
@@ -30,10 +32,9 @@ function Scatter(props) {
30
32
  onItemClick
31
33
  } = props;
32
34
  const drawingArea = useDrawingArea();
33
- const {
34
- useVoronoiInteraction
35
- } = React.useContext(InteractionContext);
36
- const skipInteractionHandlers = useVoronoiInteraction || series.disableHover;
35
+ const store = useStore();
36
+ const isVoronoiEnabled = useSelector(store, selectorChartsInteractionIsVoronoiEnabled);
37
+ const skipInteractionHandlers = isVoronoiEnabled || series.disableHover;
37
38
  const getInteractionItemProps = useInteractionItemProps(skipInteractionHandlers);
38
39
  const {
39
40
  isFaded,
@@ -41,9 +41,9 @@ const ScatterChart = /*#__PURE__*/React.forwardRef(function ScatterChart(inProps
41
41
  overlayProps,
42
42
  legendProps,
43
43
  axisHighlightProps,
44
- tooltipProps,
45
44
  children
46
45
  } = useScatterChartProps(props);
46
+ const Tooltip = props.slots?.tooltip ?? ChartsTooltip;
47
47
  return /*#__PURE__*/_jsx(ChartContainer, _extends({
48
48
  ref: ref
49
49
  }, chartContainerProps, {
@@ -51,7 +51,9 @@ const ScatterChart = /*#__PURE__*/React.forwardRef(function ScatterChart(inProps
51
51
  children: [!props.disableVoronoi && /*#__PURE__*/_jsx(ChartsVoronoiHandler, _extends({}, voronoiHandlerProps)), /*#__PURE__*/_jsx(ChartsAxis, _extends({}, chartsAxisProps)), /*#__PURE__*/_jsx(ChartsGrid, _extends({}, gridProps)), /*#__PURE__*/_jsx("g", {
52
52
  "data-drawing-container": true,
53
53
  children: /*#__PURE__*/_jsx(ScatterPlot, _extends({}, scatterPlotProps))
54
- }), /*#__PURE__*/_jsx(ChartsOverlay, _extends({}, overlayProps)), !props.hideLegend && /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legendProps)), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlightProps)), !props.loading && /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltipProps)), children]
54
+ }), /*#__PURE__*/_jsx(ChartsOverlay, _extends({}, overlayProps)), !props.hideLegend && /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legendProps)), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlightProps)), !props.loading && /*#__PURE__*/_jsx(Tooltip, _extends({
55
+ trigger: "item"
56
+ }, props.slotProps?.tooltip)), children]
55
57
  }))
56
58
  }));
57
59
  });
@@ -62,7 +64,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
62
64
  // ----------------------------------------------------------------------
63
65
  /**
64
66
  * The configuration of axes highlight.
65
- * @see See {@link https://mui.com/x/react-charts/highlighting highlighting docs} for more details.
67
+ * @see See {@link https://mui.com/x/react-charts/highlighting/ highlighting docs} for more details.
66
68
  * @default { x: 'none', y: 'none' }
67
69
  */
68
70
  axisHighlight: PropTypes.shape({
@@ -155,16 +157,6 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
155
157
  * @param {ScatterItemIdentifier} scatterItemIdentifier The scatter item identifier.
156
158
  */
157
159
  onItemClick: PropTypes.func,
158
- /**
159
- * The chart will try to wait for the parent container to resolve its size
160
- * before it renders for the first time.
161
- *
162
- * This can be useful in some scenarios where the chart appear to grow after
163
- * the first render, like when used inside a grid.
164
- *
165
- * @default false
166
- */
167
- resolveSizeBeforeRender: PropTypes.bool,
168
160
  /**
169
161
  * Indicate which axis to display the right of the charts.
170
162
  * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
@@ -193,31 +185,12 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
193
185
  slots: PropTypes.object,
194
186
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
195
187
  title: PropTypes.string,
196
- /**
197
- * The configuration of the tooltip.
198
- * @see See {@link https://mui.com/x/react-charts/tooltip/ tooltip docs} for more details.
199
- * @default { trigger: 'item' }
200
- */
201
- tooltip: PropTypes.shape({
202
- axisContent: PropTypes.elementType,
203
- classes: PropTypes.object,
204
- itemContent: PropTypes.elementType,
205
- slotProps: PropTypes.object,
206
- slots: PropTypes.object,
207
- trigger: PropTypes.oneOf(['axis', 'item', 'none'])
208
- }),
209
188
  /**
210
189
  * Indicate which axis to display the top of the charts.
211
190
  * Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
212
191
  * @default null
213
192
  */
214
193
  topAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
215
- viewBox: PropTypes.shape({
216
- height: PropTypes.number,
217
- width: PropTypes.number,
218
- x: PropTypes.number,
219
- y: PropTypes.number
220
- }),
221
194
  /**
222
195
  * Defines the maximal distance between a scatter point and the pointer that triggers the interaction.
223
196
  * If `undefined`, the radius is assumed to be infinite.
@@ -2,7 +2,7 @@
2
2
 
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
5
- const _excluded = ["xAxis", "yAxis", "zAxis", "series", "tooltip", "axisHighlight", "voronoiMaxRadius", "disableVoronoi", "hideLegend", "width", "height", "margin", "colors", "sx", "grid", "topAxis", "leftAxis", "rightAxis", "bottomAxis", "onItemClick", "children", "slots", "slotProps", "loading", "highlightedItem", "onHighlightChange", "className"];
5
+ const _excluded = ["xAxis", "yAxis", "zAxis", "series", "axisHighlight", "voronoiMaxRadius", "disableVoronoi", "hideLegend", "width", "height", "margin", "colors", "sx", "grid", "topAxis", "leftAxis", "rightAxis", "bottomAxis", "onItemClick", "children", "slots", "slotProps", "loading", "highlightedItem", "onHighlightChange", "className"];
6
6
  /**
7
7
  * A helper function that extracts ScatterChartProps from the input props
8
8
  * and returns an object with props for the children components of ScatterChart.
@@ -16,7 +16,6 @@ export const useScatterChartProps = props => {
16
16
  yAxis,
17
17
  zAxis,
18
18
  series,
19
- tooltip,
20
19
  axisHighlight,
21
20
  voronoiMaxRadius,
22
21
  disableVoronoi,
@@ -92,12 +91,6 @@ export const useScatterChartProps = props => {
92
91
  y: 'none',
93
92
  x: 'none'
94
93
  }, axisHighlight);
95
- const tooltipProps = _extends({
96
- trigger: 'item'
97
- }, tooltip, {
98
- slots,
99
- slotProps
100
- });
101
94
  return {
102
95
  chartContainerProps,
103
96
  zAxisProps,
@@ -108,7 +101,6 @@ export const useScatterChartProps = props => {
108
101
  overlayProps,
109
102
  legendProps,
110
103
  axisHighlightProps,
111
- tooltipProps,
112
104
  children
113
105
  };
114
106
  };
@@ -2,7 +2,7 @@
2
2
 
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
5
- const _excluded = ["xAxis", "yAxis", "width", "height", "margin", "colors", "sx", "showTooltip", "tooltip", "showHighlight", "axisHighlight", "children", "slots", "slotProps", "data", "plotType", "valueFormatter", "area", "curve", "className"];
5
+ const _excluded = ["xAxis", "yAxis", "width", "height", "margin", "colors", "sx", "showTooltip", "showHighlight", "axisHighlight", "children", "slots", "slotProps", "data", "plotType", "valueFormatter", "area", "curve", "className"];
6
6
  import * as React from 'react';
7
7
  import PropTypes from 'prop-types';
8
8
  import { BarPlot } from "../BarChart/index.js";
@@ -38,7 +38,6 @@ const SparkLineChart = /*#__PURE__*/React.forwardRef(function SparkLineChart(pro
38
38
  colors,
39
39
  sx,
40
40
  showTooltip,
41
- tooltip,
42
41
  showHighlight,
43
42
  axisHighlight: inAxisHighlight,
44
43
  children,
@@ -58,6 +57,7 @@ const SparkLineChart = /*#__PURE__*/React.forwardRef(function SparkLineChart(pro
58
57
  x: 'none'
59
58
  };
60
59
  const axisHighlight = _extends({}, defaultXHighlight, inAxisHighlight);
60
+ const Tooltip = props.slots?.tooltip ?? ChartsTooltip;
61
61
  return /*#__PURE__*/_jsxs(ChartContainer, _extends({}, other, {
62
62
  ref: ref,
63
63
  series: [_extends({
@@ -86,7 +86,7 @@ const SparkLineChart = /*#__PURE__*/React.forwardRef(function SparkLineChart(pro
86
86
  }, yAxis)],
87
87
  colors: colors,
88
88
  sx: sx,
89
- disableAxisListener: (!showTooltip || tooltip?.trigger !== 'axis') && axisHighlight?.x === 'none' && axisHighlight?.y === 'none',
89
+ disableAxisListener: (!showTooltip || slotProps?.tooltip?.trigger !== 'axis') && axisHighlight?.x === 'none' && axisHighlight?.y === 'none',
90
90
  children: [plotType === 'bar' && /*#__PURE__*/_jsx(BarPlot, {
91
91
  skipAnimation: true,
92
92
  slots: slots,
@@ -107,10 +107,7 @@ const SparkLineChart = /*#__PURE__*/React.forwardRef(function SparkLineChart(pro
107
107
  slots: slots,
108
108
  slotProps: slotProps
109
109
  })]
110
- }), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlight)), showTooltip && /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip, {
111
- slotProps: slotProps,
112
- slots: slots
113
- })), children]
110
+ }), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlight)), showTooltip && /*#__PURE__*/_jsx(Tooltip, _extends({}, props.slotProps?.tooltip)), children]
114
111
  }));
115
112
  });
116
113
  process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
@@ -193,16 +190,6 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
193
190
  * @default 'line'
194
191
  */
195
192
  plotType: PropTypes.oneOf(['bar', 'line']),
196
- /**
197
- * The chart will try to wait for the parent container to resolve its size
198
- * before it renders for the first time.
199
- *
200
- * This can be useful in some scenarios where the chart appear to grow after
201
- * the first render, like when used inside a grid.
202
- *
203
- * @default false
204
- */
205
- resolveSizeBeforeRender: PropTypes.bool,
206
193
  /**
207
194
  * Set to `true` to highlight the value.
208
195
  * With line, it shows a point.
@@ -232,14 +219,6 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
232
219
  slots: PropTypes.object,
233
220
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
234
221
  title: PropTypes.string,
235
- tooltip: PropTypes.shape({
236
- axisContent: PropTypes.elementType,
237
- classes: PropTypes.object,
238
- itemContent: PropTypes.elementType,
239
- slotProps: PropTypes.object,
240
- slots: PropTypes.object,
241
- trigger: PropTypes.oneOf(['axis', 'item', 'none'])
242
- }),
243
222
  /**
244
223
  * Formatter used by the tooltip.
245
224
  * @param {number} value The value to format.
@@ -247,12 +226,6 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
247
226
  * @default (value: number | null) => (value === null ? '' : value.toString())
248
227
  */
249
228
  valueFormatter: PropTypes.func,
250
- viewBox: PropTypes.shape({
251
- height: PropTypes.number,
252
- width: PropTypes.number,
253
- x: PropTypes.number,
254
- y: PropTypes.number
255
- }),
256
229
  /**
257
230
  * The width of the chart in px. If not defined, it takes the width of the parent element.
258
231
  */
@@ -3,56 +3,58 @@
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
- import { DrawingProvider } from "../DrawingProvider.js";
6
+ import { DrawingAreaProvider } from "../DrawingAreaProvider/index.js";
7
7
  import { SeriesProvider } from "../SeriesProvider/index.js";
8
8
  import { InteractionProvider } from "../InteractionProvider.js";
9
- import { ChartsSurface } from "../../ChartsSurface/index.js";
10
9
  import { CartesianProvider } from "../CartesianProvider/index.js";
11
- import { ChartsAxesGradients } from "../../internals/components/ChartsAxesGradients/index.js";
12
- import { HighlightedProvider, ZAxisContextProvider } from "../index.js";
13
10
  import { PluginProvider } from "../PluginProvider/index.js";
14
11
  import { useChartDataProviderProps } from "./useChartDataProviderProps.js";
15
12
  import { AnimationProvider } from "../AnimationProvider/index.js";
16
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
17
- const ChartDataProvider = /*#__PURE__*/React.forwardRef(function ChartDataProvider(props, ref) {
13
+ import { ZAxisContextProvider } from "../ZAxisContextProvider.js";
14
+ import { HighlightedProvider } from "../HighlightedProvider/index.js";
15
+ import { SizeProvider } from "../SizeProvider/index.js";
16
+ import { SvgRefProvider } from "../SvgRefProvider/index.js";
17
+ import { jsx as _jsx } from "react/jsx-runtime";
18
+ function ChartDataProvider(props) {
18
19
  const {
19
20
  children,
20
- drawingProviderProps,
21
+ drawingAreaProviderProps,
21
22
  seriesProviderProps,
22
23
  cartesianProviderProps,
23
24
  zAxisContextProps,
24
25
  highlightedProviderProps,
25
- chartsSurfaceProps,
26
26
  pluginProviderProps,
27
- animationProviderProps
28
- } = useChartDataProviderProps(props, ref);
29
- return /*#__PURE__*/_jsx(DrawingProvider, _extends({}, drawingProviderProps, {
30
- children: /*#__PURE__*/_jsx(PluginProvider, _extends({}, pluginProviderProps, {
31
- children: /*#__PURE__*/_jsx(SeriesProvider, _extends({}, seriesProviderProps, {
32
- children: /*#__PURE__*/_jsx(CartesianProvider, _extends({}, cartesianProviderProps, {
33
- children: /*#__PURE__*/_jsx(ZAxisContextProvider, _extends({}, zAxisContextProps, {
34
- children: /*#__PURE__*/_jsx(InteractionProvider, {
35
- children: /*#__PURE__*/_jsx(HighlightedProvider, _extends({}, highlightedProviderProps, {
36
- children: /*#__PURE__*/_jsx(AnimationProvider, _extends({}, animationProviderProps, {
37
- children: /*#__PURE__*/_jsxs(ChartsSurface, _extends({}, chartsSurfaceProps, {
38
- children: [/*#__PURE__*/_jsx(ChartsAxesGradients, {}), children]
27
+ animationProviderProps,
28
+ sizeProviderProps
29
+ } = useChartDataProviderProps(props);
30
+ return /*#__PURE__*/_jsx(SizeProvider, _extends({}, sizeProviderProps, {
31
+ children: /*#__PURE__*/_jsx(DrawingAreaProvider, _extends({}, drawingAreaProviderProps, {
32
+ children: /*#__PURE__*/_jsx(PluginProvider, _extends({}, pluginProviderProps, {
33
+ children: /*#__PURE__*/_jsx(SeriesProvider, _extends({}, seriesProviderProps, {
34
+ children: /*#__PURE__*/_jsx(CartesianProvider, _extends({}, cartesianProviderProps, {
35
+ children: /*#__PURE__*/_jsx(ZAxisContextProvider, _extends({}, zAxisContextProps, {
36
+ children: /*#__PURE__*/_jsx(InteractionProvider, {
37
+ children: /*#__PURE__*/_jsx(HighlightedProvider, _extends({}, highlightedProviderProps, {
38
+ children: /*#__PURE__*/_jsx(AnimationProvider, _extends({}, animationProviderProps, {
39
+ children: /*#__PURE__*/_jsx(SvgRefProvider, {
40
+ children: children
41
+ })
39
42
  }))
40
43
  }))
41
- }))
42
- })
44
+ })
45
+ }))
43
46
  }))
44
47
  }))
45
48
  }))
46
49
  }))
47
50
  }));
48
- });
51
+ }
49
52
  process.env.NODE_ENV !== "production" ? ChartDataProvider.propTypes = {
50
53
  // ----------------------------- Warning --------------------------------
51
54
  // | These PropTypes are generated from the TypeScript type definitions |
52
55
  // | To update them edit the TypeScript types and run "pnpm proptypes" |
53
56
  // ----------------------------------------------------------------------
54
57
  children: PropTypes.node,
55
- className: PropTypes.string,
56
58
  /**
57
59
  * Color palette used to colorize multiple series.
58
60
  * @default blueberryTwilightPalette
@@ -62,17 +64,10 @@ process.env.NODE_ENV !== "production" ? ChartDataProvider.propTypes = {
62
64
  * An array of objects that can be used to populate series and axes data using their `dataKey` property.
63
65
  */
64
66
  dataset: PropTypes.arrayOf(PropTypes.object),
65
- desc: PropTypes.string,
66
67
  /**
67
- * If `true`, the charts will not listen to the mouse move event.
68
- * It might break interactive features, but will improve performance.
69
- * @default false
68
+ * The height of the chart in px. If not defined, it takes the height of the parent element.
70
69
  */
71
- disableAxisListener: PropTypes.bool,
72
- /**
73
- * The height of the chart in px.
74
- */
75
- height: PropTypes.number.isRequired,
70
+ height: PropTypes.number,
76
71
  /**
77
72
  * The item currently highlighted. Turns highlighting into a controlled prop.
78
73
  */
@@ -114,18 +109,10 @@ process.env.NODE_ENV !== "production" ? ChartDataProvider.propTypes = {
114
109
  * If unset or `false`, the animations respects the user's `prefers-reduced-motion` setting.
115
110
  */
116
111
  skipAnimation: PropTypes.bool,
117
- sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
118
- title: PropTypes.string,
119
- viewBox: PropTypes.shape({
120
- height: PropTypes.number,
121
- width: PropTypes.number,
122
- x: PropTypes.number,
123
- y: PropTypes.number
124
- }),
125
112
  /**
126
- * The width of the chart in px.
113
+ * The width of the chart in px. If not defined, it takes the width of the parent element.
127
114
  */
128
- width: PropTypes.number.isRequired,
115
+ width: PropTypes.number,
129
116
  /**
130
117
  * The configuration of the x-axes.
131
118
  * If not provided, a default axis config is used.
@@ -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,16 @@
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
+ chartId: '',
12
+ isPointInside: () => false
13
+ });
14
+ if (process.env.NODE_ENV !== 'production') {
15
+ DrawingAreaContext.displayName = 'DrawingContext';
16
+ }
@@ -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";
@@ -1,77 +1,21 @@
1
1
  'use client';
2
2
 
3
- import _extends from "@babel/runtime/helpers/esm/extends";
4
3
  import * as React from 'react';
4
+ import { useCharts } from "../internals/useCharts.js";
5
5
  import { jsx as _jsx } from "react/jsx-runtime";
6
- export const InteractionContext = /*#__PURE__*/React.createContext({
7
- item: null,
8
- axis: {
9
- x: null,
10
- y: null
11
- },
12
- useVoronoiInteraction: false,
13
- dispatch: () => null
14
- });
6
+ export const ChartsContext = /*#__PURE__*/React.createContext(null);
15
7
  if (process.env.NODE_ENV !== 'production') {
16
- InteractionContext.displayName = 'InteractionContext';
8
+ ChartsContext.displayName = 'ChartsContext';
17
9
  }
18
- const dataReducer = (prevState, action) => {
19
- switch (action.type) {
20
- case 'enterItem':
21
- return _extends({}, prevState, {
22
- item: action.data
23
- });
24
- case 'exitChart':
25
- if (prevState.item === null && prevState.axis.x === null && prevState.axis.y === null) {
26
- return prevState;
27
- }
28
- return _extends({}, prevState, {
29
- axis: {
30
- x: null,
31
- y: null
32
- },
33
- item: null
34
- });
35
- case 'updateVoronoiUsage':
36
- return _extends({}, prevState, {
37
- useVoronoiInteraction: action.useVoronoiInteraction
38
- });
39
- case 'leaveItem':
40
- if (prevState.item === null || Object.keys(action.data).some(key => action.data[key] !== prevState.item[key])) {
41
- // The item is already something else
42
- return prevState;
43
- }
44
- return _extends({}, prevState, {
45
- item: null
46
- });
47
- case 'updateAxis':
48
- if (action.data.x === prevState.axis.x && action.data.y === prevState.axis.y) {
49
- return prevState;
50
- }
51
- return _extends({}, prevState, {
52
- axis: action.data
53
- });
54
- default:
55
- return prevState;
56
- }
57
- };
58
10
  function InteractionProvider(props) {
59
11
  const {
60
12
  children
61
13
  } = props;
62
- const [data, dispatch] = React.useReducer(dataReducer, {
63
- item: null,
64
- axis: {
65
- x: null,
66
- y: null
67
- },
68
- useVoronoiInteraction: false
69
- });
70
- const value = React.useMemo(() => _extends({}, data, {
71
- dispatch
72
- }), [data]);
73
- return /*#__PURE__*/_jsx(InteractionContext.Provider, {
74
- value: value,
14
+ const {
15
+ contextValue
16
+ } = useCharts();
17
+ return /*#__PURE__*/_jsx(ChartsContext.Provider, {
18
+ value: contextValue,
75
19
  children: children
76
20
  });
77
21
  }
@@ -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,13 @@
1
+ import * as React from 'react';
2
+ export const SizeContext = /*#__PURE__*/React.createContext({
3
+ isInitialized: false,
4
+ data: {
5
+ hasIntrinsicSize: false,
6
+ containerRef: null,
7
+ height: 0,
8
+ width: 0
9
+ }
10
+ });
11
+ if (process.env.NODE_ENV !== 'production') {
12
+ SizeContext.displayName = 'SizeContext';
13
+ }