@mui/x-charts 7.22.3 → 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 (415) hide show
  1. package/BarChart/AnimatedBarElement.d.ts +15 -0
  2. package/BarChart/AnimatedBarElement.js +21 -0
  3. package/BarChart/BarChart.d.ts +11 -16
  4. package/BarChart/BarChart.js +9 -59
  5. package/BarChart/BarElement.d.ts +6 -1343
  6. package/BarChart/BarElement.js +10 -20
  7. package/BarChart/BarLabel/BarLabelItem.d.ts +1 -1
  8. package/BarChart/BarPlot.js +24 -6
  9. package/BarChart/extremums.js +3 -3
  10. package/BarChart/useBarChartProps.d.ts +2 -4
  11. package/BarChart/useBarChartProps.js +4 -11
  12. package/CHANGELOG.md +348 -12
  13. package/ChartContainer/ChartContainer.d.ts +4 -38
  14. package/ChartContainer/ChartContainer.js +15 -44
  15. package/ChartContainer/ResizableContainer.d.ts +22 -0
  16. package/ChartContainer/ResizableContainer.js +60 -0
  17. package/ChartContainer/useChartContainerProps.d.ts +8 -92
  18. package/ChartContainer/useChartContainerProps.js +29 -59
  19. package/ChartsAxisHighlight/ChartsAxisHighlight.d.ts +1 -17
  20. package/ChartsAxisHighlight/ChartsAxisHighlight.js +10 -96
  21. package/ChartsAxisHighlight/ChartsAxisHighlight.types.d.ts +5 -0
  22. package/ChartsAxisHighlight/ChartsAxisHighlightPath.d.ts +6 -0
  23. package/ChartsAxisHighlight/ChartsAxisHighlightPath.js +34 -0
  24. package/ChartsAxisHighlight/ChartsXAxisHighlight.d.ts +10 -0
  25. package/ChartsAxisHighlight/ChartsXAxisHighlight.js +53 -0
  26. package/ChartsAxisHighlight/ChartsYAxisHighlight.d.ts +10 -0
  27. package/ChartsAxisHighlight/ChartsYAxisHighlight.js +53 -0
  28. package/ChartsAxisHighlight/chartsAxisHighlightClasses.d.ts +7 -0
  29. package/ChartsAxisHighlight/chartsAxisHighlightClasses.js +6 -0
  30. package/ChartsAxisHighlight/index.d.ts +3 -0
  31. package/ChartsAxisHighlight/index.js +4 -1
  32. package/ChartsGrid/ChartsGrid.js +1 -1
  33. package/ChartsGrid/ChartsHorizontalGrid.d.ts +2 -2
  34. package/ChartsGrid/ChartsHorizontalGrid.js +3 -3
  35. package/ChartsGrid/ChartsVerticalGrid.d.ts +2 -2
  36. package/ChartsGrid/ChartsVerticalGrid.js +3 -3
  37. package/ChartsLegend/ChartsLegend.js +0 -3
  38. package/ChartsLegend/DefaultChartsLegend.d.ts +0 -5
  39. package/ChartsLegend/DefaultChartsLegend.js +1 -12
  40. package/ChartsLegend/LegendPerItem.d.ts +3 -3
  41. package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +11 -9
  42. package/ChartsOverlay/ChartsOverlay.d.ts +1 -1
  43. package/ChartsSurface/ChartsSurface.d.ts +0 -15
  44. package/ChartsSurface/ChartsSurface.js +35 -34
  45. package/ChartsTooltip/ChartTooltip.types.d.ts +15 -0
  46. package/ChartsTooltip/ChartsAxisTooltipContent.d.ts +7 -39
  47. package/ChartsTooltip/ChartsAxisTooltipContent.js +83 -72
  48. package/ChartsTooltip/ChartsItemTooltipContent.d.ts +5 -28
  49. package/ChartsTooltip/ChartsItemTooltipContent.js +54 -44
  50. package/ChartsTooltip/ChartsTooltip.d.ts +3 -69
  51. package/ChartsTooltip/ChartsTooltip.js +162 -107
  52. package/ChartsTooltip/ChartsTooltipContainer.d.ts +33 -0
  53. package/ChartsTooltip/ChartsTooltipContainer.js +298 -0
  54. package/ChartsTooltip/chartsTooltipClasses.d.ts +1 -0
  55. package/ChartsTooltip/chartsTooltipClasses.js +18 -2
  56. package/ChartsTooltip/index.d.ts +3 -3
  57. package/ChartsTooltip/index.js +2 -3
  58. package/ChartsTooltip/useAxisTooltip.d.ts +2 -2
  59. package/ChartsTooltip/useAxisTooltip.js +21 -21
  60. package/ChartsTooltip/useItemTooltip.d.ts +1 -1
  61. package/ChartsTooltip/useItemTooltip.js +8 -7
  62. package/ChartsTooltip/utils.d.ts +5 -16
  63. package/ChartsTooltip/utils.js +45 -50
  64. package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +50 -39
  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 +60 -61
  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/AreaElement.d.ts +1 -1
  74. package/LineChart/AreaPlot.js +14 -8
  75. package/LineChart/CircleMarkElement.js +6 -5
  76. package/LineChart/LineChart.d.ts +11 -17
  77. package/LineChart/LineChart.js +9 -60
  78. package/LineChart/LineElement.d.ts +1 -1
  79. package/LineChart/LineHighlightPlot.d.ts +1 -1
  80. package/LineChart/LineHighlightPlot.js +8 -11
  81. package/LineChart/LinePlot.js +14 -8
  82. package/LineChart/MarkElement.js +6 -5
  83. package/LineChart/MarkPlot.js +2 -6
  84. package/LineChart/extremums.js +10 -6
  85. package/LineChart/useLineChartProps.d.ts +2 -4
  86. package/LineChart/useLineChartProps.js +4 -11
  87. package/PieChart/PieArc.d.ts +0 -5
  88. package/PieChart/PieArc.js +1 -10
  89. package/PieChart/PieArcPlot.js +0 -5
  90. package/PieChart/PieChart.d.ts +10 -39
  91. package/PieChart/PieChart.js +20 -137
  92. package/PieChart/PiePlot.js +2 -2
  93. package/PieChart/getPieCoordinates.d.ts +2 -2
  94. package/README.md +4 -4
  95. package/ScatterChart/Scatter.js +6 -5
  96. package/ScatterChart/ScatterChart.d.ts +11 -17
  97. package/ScatterChart/ScatterChart.js +11 -60
  98. package/ScatterChart/ScatterPlot.js +3 -6
  99. package/ScatterChart/extremums.js +6 -6
  100. package/ScatterChart/useScatterChartProps.d.ts +2 -4
  101. package/ScatterChart/useScatterChartProps.js +3 -12
  102. package/SparkLineChart/SparkLineChart.d.ts +7 -8
  103. package/SparkLineChart/SparkLineChart.js +6 -33
  104. package/context/CartesianProvider/defaultizeAxis.d.ts +1 -1
  105. package/context/ChartDataProvider/ChartDataProvider.d.ts +31 -0
  106. package/{ResponsiveChartContainer/ResponsiveChartContainer.js → context/ChartDataProvider/ChartDataProvider.js} +45 -39
  107. package/context/ChartDataProvider/index.d.ts +1 -0
  108. package/context/ChartDataProvider/index.js +1 -0
  109. package/context/ChartDataProvider/useChartDataProviderProps.d.ts +94 -0
  110. package/context/ChartDataProvider/useChartDataProviderProps.js +66 -0
  111. package/{ChartContainer → context/ChartDataProvider}/useDefaultizeAxis.d.ts +12 -12
  112. package/{modern/ChartContainer → context/ChartDataProvider}/useDefaultizeAxis.js +1 -1
  113. package/context/{DrawingProvider.d.ts → DrawingAreaProvider/DrawingArea.types.d.ts} +3 -14
  114. package/context/DrawingAreaProvider/DrawingAreaContext.d.ts +8 -0
  115. package/context/DrawingAreaProvider/DrawingAreaContext.js +16 -0
  116. package/context/DrawingAreaProvider/DrawingAreaProvider.d.ts +3 -0
  117. package/{modern/context/DrawingProvider.js → context/DrawingAreaProvider/DrawingAreaProvider.js} +11 -41
  118. package/context/DrawingAreaProvider/index.d.ts +3 -0
  119. package/context/DrawingAreaProvider/index.js +3 -0
  120. package/context/HighlightedProvider/HighlightedContext.d.ts +0 -8
  121. package/context/HighlightedProvider/HighlightedProvider.js +1 -16
  122. package/context/InteractionProvider.d.ts +5 -48
  123. package/context/InteractionProvider.js +8 -64
  124. package/context/InteractionSelectors.d.ts +359 -0
  125. package/context/InteractionSelectors.js +12 -0
  126. package/context/PluginProvider/ExtremumGetter.types.d.ts +2 -2
  127. package/context/SizeProvider/Size.types.d.ts +30 -0
  128. package/context/SizeProvider/SizeContext.d.ts +4 -0
  129. package/context/SizeProvider/SizeContext.js +13 -0
  130. package/context/SizeProvider/SizeProvider.d.ts +11 -0
  131. package/context/SizeProvider/SizeProvider.js +26 -0
  132. package/context/SizeProvider/index.d.ts +4 -0
  133. package/context/SizeProvider/index.js +4 -0
  134. package/context/SizeProvider/useChartContainerDimensions.d.ts +9 -0
  135. package/{modern/ResponsiveChartContainer → context/SizeProvider}/useChartContainerDimensions.js +15 -7
  136. package/context/SizeProvider/useSize.d.ts +5 -0
  137. package/context/SizeProvider/useSize.js +13 -0
  138. package/context/SvgRefProvider/SvgRef.types.d.ts +8 -0
  139. package/context/SvgRefProvider/SvgRef.types.js +1 -0
  140. package/context/SvgRefProvider/SvgRefContext.d.ts +4 -0
  141. package/context/SvgRefProvider/SvgRefContext.js +17 -0
  142. package/context/SvgRefProvider/SvgRefProvider.d.ts +3 -0
  143. package/context/SvgRefProvider/SvgRefProvider.js +24 -0
  144. package/context/SvgRefProvider/index.d.ts +4 -0
  145. package/context/SvgRefProvider/index.js +4 -0
  146. package/context/SvgRefProvider/useSurfaceRef.d.ts +2 -0
  147. package/context/SvgRefProvider/useSurfaceRef.js +14 -0
  148. package/context/ZAxisContextProvider.d.ts +1 -1
  149. package/context/index.d.ts +2 -0
  150. package/context/index.js +2 -1
  151. package/hooks/useAxisEvents.js +32 -19
  152. package/hooks/useChartId.js +2 -2
  153. package/hooks/useDrawingArea.d.ts +2 -2
  154. package/hooks/useDrawingArea.js +2 -2
  155. package/hooks/useInteractionItemProps.js +19 -12
  156. package/hooks/useSvgRef.js +3 -3
  157. package/index.d.ts +1 -2
  158. package/index.js +2 -3
  159. package/internals/components/ChartsAxesGradients/ChartsAxesGradients.d.ts +1 -1
  160. package/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +9 -4
  161. package/internals/computeAxisValue.d.ts +2 -2
  162. package/internals/defaultizeColor.d.ts +1 -8
  163. package/internals/getSymbol.js +19 -3
  164. package/internals/index.d.ts +7 -6
  165. package/internals/index.js +7 -6
  166. package/internals/plugins/models/index.d.ts +35 -0
  167. package/internals/plugins/models/index.js +1 -0
  168. package/internals/plugins/utils/ChartStore.d.ts +12 -0
  169. package/internals/plugins/utils/ChartStore.js +26 -0
  170. package/internals/plugins/utils/ChartsStore.d.ts +12 -0
  171. package/internals/plugins/utils/ChartsStore.js +26 -0
  172. package/internals/plugins/utils/selectors.d.ts +9 -0
  173. package/internals/plugins/utils/selectors.js +37 -0
  174. package/internals/useCharts.d.ts +6 -0
  175. package/internals/useCharts.js +29 -0
  176. package/internals/useSelector.d.ts +4 -0
  177. package/internals/useSelector.js +6 -0
  178. package/internals/useStore.d.ts +2 -0
  179. package/internals/useStore.js +17 -0
  180. package/internals/useStringInterpolator.js +1 -0
  181. package/models/seriesType/bar.d.ts +1 -1
  182. package/models/seriesType/common.d.ts +0 -10
  183. package/models/seriesType/config.d.ts +1 -1
  184. package/models/seriesType/line.d.ts +1 -1
  185. package/models/seriesType/pie.d.ts +1 -1
  186. package/models/seriesType/scatter.d.ts +1 -6
  187. package/modern/BarChart/AnimatedBarElement.js +21 -0
  188. package/modern/BarChart/BarChart.js +9 -59
  189. package/modern/BarChart/BarElement.js +10 -20
  190. package/modern/BarChart/BarPlot.js +24 -6
  191. package/modern/BarChart/extremums.js +3 -3
  192. package/modern/BarChart/useBarChartProps.js +4 -11
  193. package/modern/ChartContainer/ChartContainer.js +15 -44
  194. package/modern/ChartContainer/ResizableContainer.js +60 -0
  195. package/modern/ChartContainer/useChartContainerProps.js +29 -59
  196. package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +10 -96
  197. package/modern/ChartsAxisHighlight/ChartsAxisHighlight.types.js +1 -0
  198. package/modern/ChartsAxisHighlight/ChartsAxisHighlightPath.js +34 -0
  199. package/modern/ChartsAxisHighlight/ChartsXAxisHighlight.js +53 -0
  200. package/modern/ChartsAxisHighlight/ChartsYAxisHighlight.js +53 -0
  201. package/modern/ChartsAxisHighlight/chartsAxisHighlightClasses.js +6 -0
  202. package/modern/ChartsAxisHighlight/index.js +4 -1
  203. package/modern/ChartsGrid/ChartsGrid.js +1 -1
  204. package/modern/ChartsGrid/ChartsHorizontalGrid.js +3 -3
  205. package/modern/ChartsGrid/ChartsVerticalGrid.js +3 -3
  206. package/modern/ChartsLegend/ChartsLegend.js +0 -3
  207. package/modern/ChartsLegend/DefaultChartsLegend.js +1 -12
  208. package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +11 -9
  209. package/modern/ChartsSurface/ChartsSurface.js +35 -34
  210. package/modern/ChartsTooltip/ChartTooltip.types.js +1 -0
  211. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +83 -72
  212. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +54 -44
  213. package/modern/ChartsTooltip/ChartsTooltip.js +162 -107
  214. package/modern/ChartsTooltip/ChartsTooltipContainer.js +298 -0
  215. package/modern/ChartsTooltip/chartsTooltipClasses.js +18 -2
  216. package/modern/ChartsTooltip/index.js +2 -3
  217. package/modern/ChartsTooltip/useAxisTooltip.js +21 -21
  218. package/modern/ChartsTooltip/useItemTooltip.js +8 -7
  219. package/modern/ChartsTooltip/utils.js +45 -50
  220. package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +50 -39
  221. package/modern/Gauge/Gauge.js +0 -6
  222. package/modern/Gauge/GaugeContainer.js +60 -61
  223. package/modern/LineChart/AnimatedArea.js +9 -18
  224. package/modern/LineChart/AnimatedLine.js +9 -20
  225. package/modern/LineChart/AreaPlot.js +14 -8
  226. package/modern/LineChart/CircleMarkElement.js +6 -5
  227. package/modern/LineChart/LineChart.js +9 -60
  228. package/modern/LineChart/LineHighlightPlot.js +8 -11
  229. package/modern/LineChart/LinePlot.js +14 -8
  230. package/modern/LineChart/MarkElement.js +6 -5
  231. package/modern/LineChart/MarkPlot.js +2 -6
  232. package/modern/LineChart/extremums.js +10 -6
  233. package/modern/LineChart/useLineChartProps.js +4 -11
  234. package/modern/PieChart/PieArc.js +1 -10
  235. package/modern/PieChart/PieArcPlot.js +0 -5
  236. package/modern/PieChart/PieChart.js +20 -137
  237. package/modern/PieChart/PiePlot.js +2 -2
  238. package/modern/ScatterChart/Scatter.js +6 -5
  239. package/modern/ScatterChart/ScatterChart.js +11 -60
  240. package/modern/ScatterChart/ScatterPlot.js +3 -6
  241. package/modern/ScatterChart/extremums.js +6 -6
  242. package/modern/ScatterChart/useScatterChartProps.js +3 -12
  243. package/modern/SparkLineChart/SparkLineChart.js +6 -33
  244. package/modern/{ResponsiveChartContainer/ResponsiveChartContainer.js → context/ChartDataProvider/ChartDataProvider.js} +45 -39
  245. package/modern/context/ChartDataProvider/index.js +1 -0
  246. package/modern/context/ChartDataProvider/useChartDataProviderProps.js +66 -0
  247. package/{ChartContainer → modern/context/ChartDataProvider}/useDefaultizeAxis.js +1 -1
  248. package/modern/context/DrawingAreaProvider/DrawingArea.types.js +1 -0
  249. package/modern/context/DrawingAreaProvider/DrawingAreaContext.js +16 -0
  250. package/{context/DrawingProvider.js → modern/context/DrawingAreaProvider/DrawingAreaProvider.js} +11 -41
  251. package/modern/context/DrawingAreaProvider/index.js +3 -0
  252. package/modern/context/HighlightedProvider/HighlightedProvider.js +1 -16
  253. package/modern/context/InteractionProvider.js +8 -64
  254. package/modern/context/InteractionSelectors.js +12 -0
  255. package/modern/context/SizeProvider/Size.types.js +1 -0
  256. package/modern/context/SizeProvider/SizeContext.js +13 -0
  257. package/modern/context/SizeProvider/SizeProvider.js +26 -0
  258. package/modern/context/SizeProvider/index.js +4 -0
  259. package/{ResponsiveChartContainer → modern/context/SizeProvider}/useChartContainerDimensions.js +15 -7
  260. package/modern/context/SizeProvider/useSize.js +13 -0
  261. package/modern/context/SvgRefProvider/SvgRef.types.js +1 -0
  262. package/modern/context/SvgRefProvider/SvgRefContext.js +17 -0
  263. package/modern/context/SvgRefProvider/SvgRefProvider.js +24 -0
  264. package/modern/context/SvgRefProvider/index.js +4 -0
  265. package/modern/context/SvgRefProvider/useSurfaceRef.js +14 -0
  266. package/modern/context/index.js +2 -1
  267. package/modern/hooks/useAxisEvents.js +32 -19
  268. package/modern/hooks/useChartId.js +2 -2
  269. package/modern/hooks/useDrawingArea.js +2 -2
  270. package/modern/hooks/useInteractionItemProps.js +19 -12
  271. package/modern/hooks/useSvgRef.js +3 -3
  272. package/modern/index.js +2 -3
  273. package/modern/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +9 -4
  274. package/modern/internals/getSymbol.js +19 -3
  275. package/modern/internals/index.js +7 -6
  276. package/modern/internals/plugins/models/index.js +1 -0
  277. package/modern/internals/plugins/utils/ChartStore.js +26 -0
  278. package/modern/internals/plugins/utils/ChartsStore.js +26 -0
  279. package/modern/internals/plugins/utils/selectors.js +37 -0
  280. package/modern/internals/useCharts.js +29 -0
  281. package/modern/internals/useSelector.js +6 -0
  282. package/modern/internals/useStore.js +17 -0
  283. package/modern/internals/useStringInterpolator.js +1 -0
  284. package/node/BarChart/AnimatedBarElement.js +28 -0
  285. package/node/BarChart/BarChart.js +9 -59
  286. package/node/BarChart/BarElement.js +11 -21
  287. package/node/BarChart/BarPlot.js +22 -4
  288. package/node/BarChart/extremums.js +3 -3
  289. package/node/BarChart/useBarChartProps.js +4 -11
  290. package/node/ChartContainer/ChartContainer.js +14 -43
  291. package/node/ChartContainer/ResizableContainer.js +68 -0
  292. package/node/ChartContainer/useChartContainerProps.js +29 -60
  293. package/node/ChartsAxisHighlight/ChartsAxisHighlight.js +12 -100
  294. package/node/ChartsAxisHighlight/ChartsAxisHighlightPath.js +40 -0
  295. package/node/ChartsAxisHighlight/ChartsXAxisHighlight.js +57 -0
  296. package/node/ChartsAxisHighlight/ChartsYAxisHighlight.js +57 -0
  297. package/node/ChartsAxisHighlight/chartsAxisHighlightClasses.js +14 -0
  298. package/node/ChartsAxisHighlight/index.js +33 -0
  299. package/node/ChartsGrid/ChartsGrid.js +2 -2
  300. package/node/ChartsGrid/ChartsHorizontalGrid.js +4 -4
  301. package/node/ChartsGrid/ChartsVerticalGrid.js +4 -4
  302. package/node/ChartsLegend/ChartsLegend.js +0 -3
  303. package/node/ChartsLegend/DefaultChartsLegend.js +1 -12
  304. package/node/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +11 -9
  305. package/node/ChartsSurface/ChartsSurface.js +35 -34
  306. package/node/ChartsTooltip/ChartsAxisTooltipContent.js +83 -73
  307. package/node/ChartsTooltip/ChartsItemTooltipContent.js +54 -45
  308. package/node/ChartsTooltip/ChartsTooltip.js +161 -106
  309. package/node/ChartsTooltip/ChartsTooltipContainer.js +304 -0
  310. package/node/ChartsTooltip/chartsTooltipClasses.js +22 -3
  311. package/node/ChartsTooltip/index.js +19 -28
  312. package/node/ChartsTooltip/useAxisTooltip.js +21 -21
  313. package/node/ChartsTooltip/useItemTooltip.js +8 -7
  314. package/node/ChartsTooltip/utils.js +46 -53
  315. package/node/ChartsVoronoiHandler/ChartsVoronoiHandler.js +51 -40
  316. package/node/Gauge/Gauge.js +0 -6
  317. package/node/Gauge/GaugeContainer.js +60 -61
  318. package/node/LineChart/AnimatedArea.js +9 -19
  319. package/node/LineChart/AnimatedLine.js +9 -21
  320. package/node/LineChart/AreaPlot.js +13 -7
  321. package/node/LineChart/CircleMarkElement.js +6 -5
  322. package/node/LineChart/LineChart.js +9 -60
  323. package/node/LineChart/LineHighlightPlot.js +8 -11
  324. package/node/LineChart/LinePlot.js +13 -7
  325. package/node/LineChart/MarkElement.js +6 -5
  326. package/node/LineChart/MarkPlot.js +2 -6
  327. package/node/LineChart/extremums.js +10 -6
  328. package/node/LineChart/useLineChartProps.js +4 -11
  329. package/node/PieChart/PieArc.js +1 -10
  330. package/node/PieChart/PieArcPlot.js +0 -5
  331. package/node/PieChart/PieChart.js +20 -137
  332. package/node/PieChart/PiePlot.js +2 -2
  333. package/node/ScatterChart/Scatter.js +6 -5
  334. package/node/ScatterChart/ScatterChart.js +11 -60
  335. package/node/ScatterChart/ScatterPlot.js +3 -6
  336. package/node/ScatterChart/extremums.js +6 -6
  337. package/node/ScatterChart/useScatterChartProps.js +3 -12
  338. package/node/SparkLineChart/SparkLineChart.js +6 -33
  339. package/node/{ResponsiveChartContainer/ResponsiveChartContainer.js → context/ChartDataProvider/ChartDataProvider.js} +45 -39
  340. package/node/context/ChartDataProvider/index.js +16 -0
  341. package/node/context/ChartDataProvider/useChartDataProviderProps.js +72 -0
  342. package/node/{ChartContainer → context/ChartDataProvider}/useDefaultizeAxis.js +1 -1
  343. package/node/context/DrawingAreaProvider/DrawingArea.types.js +5 -0
  344. package/node/context/DrawingAreaProvider/DrawingAreaContext.js +22 -0
  345. package/node/context/{DrawingProvider.js → DrawingAreaProvider/DrawingAreaProvider.js} +12 -44
  346. package/node/context/DrawingAreaProvider/index.js +38 -0
  347. package/node/context/HighlightedProvider/HighlightedProvider.js +1 -16
  348. package/node/context/InteractionProvider.js +9 -66
  349. package/node/context/InteractionSelectors.js +18 -0
  350. package/node/context/SizeProvider/Size.types.js +5 -0
  351. package/node/context/SizeProvider/SizeContext.js +20 -0
  352. package/node/context/SizeProvider/SizeProvider.js +29 -0
  353. package/node/context/SizeProvider/index.js +49 -0
  354. package/node/{ResponsiveChartContainer → context/SizeProvider}/useChartContainerDimensions.js +15 -7
  355. package/node/context/SizeProvider/useSize.js +20 -0
  356. package/node/context/SvgRefProvider/SvgRef.types.js +5 -0
  357. package/node/context/SvgRefProvider/SvgRefContext.js +23 -0
  358. package/node/context/SvgRefProvider/SvgRefProvider.js +31 -0
  359. package/node/context/SvgRefProvider/index.js +49 -0
  360. package/node/context/SvgRefProvider/useSurfaceRef.js +20 -0
  361. package/node/context/index.js +10 -2
  362. package/node/hooks/useAxisEvents.js +33 -19
  363. package/node/hooks/useChartId.js +2 -2
  364. package/node/hooks/useDrawingArea.js +2 -2
  365. package/node/hooks/useInteractionItemProps.js +20 -13
  366. package/node/hooks/useSvgRef.js +3 -3
  367. package/node/index.js +5 -16
  368. package/node/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +9 -4
  369. package/node/internals/getSymbol.js +19 -3
  370. package/node/internals/index.js +64 -44
  371. package/node/internals/plugins/models/index.js +5 -0
  372. package/node/internals/plugins/utils/ChartStore.js +33 -0
  373. package/node/internals/plugins/utils/ChartsStore.js +33 -0
  374. package/node/internals/plugins/utils/selectors.js +44 -0
  375. package/node/internals/useCharts.js +36 -0
  376. package/node/internals/useSelector.js +13 -0
  377. package/node/internals/useStore.js +24 -0
  378. package/node/internals/useStringInterpolator.js +2 -0
  379. package/package.json +8 -6
  380. package/themeAugmentation/props.d.ts +1 -2
  381. package/ChartsTooltip/DefaultChartsAxisTooltipContent.d.ts +0 -7
  382. package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +0 -123
  383. package/ChartsTooltip/DefaultChartsItemTooltipContent.d.ts +0 -8
  384. package/ChartsTooltip/DefaultChartsItemTooltipContent.js +0 -92
  385. package/ResponsiveChartContainer/ResizableContainer.d.ts +0 -9
  386. package/ResponsiveChartContainer/ResizableContainer.js +0 -26
  387. package/ResponsiveChartContainer/ResponsiveChartContainer.d.ts +0 -24
  388. package/ResponsiveChartContainer/index.d.ts +0 -1
  389. package/ResponsiveChartContainer/index.js +0 -1
  390. package/ResponsiveChartContainer/package.json +0 -6
  391. package/ResponsiveChartContainer/useChartContainerDimensions.d.ts +0 -6
  392. package/ResponsiveChartContainer/useResponsiveChartContainerProps.d.ts +0 -19
  393. package/ResponsiveChartContainer/useResponsiveChartContainerProps.js +0 -70
  394. package/internals/SlotComponentPropsFromProps.d.ts +0 -1
  395. package/models/helpers.d.ts +0 -3
  396. package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +0 -123
  397. package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +0 -92
  398. package/modern/ResponsiveChartContainer/ResizableContainer.js +0 -26
  399. package/modern/ResponsiveChartContainer/index.js +0 -1
  400. package/modern/ResponsiveChartContainer/useResponsiveChartContainerProps.js +0 -70
  401. package/node/ChartsTooltip/DefaultChartsAxisTooltipContent.js +0 -129
  402. package/node/ChartsTooltip/DefaultChartsItemTooltipContent.js +0 -98
  403. package/node/ResponsiveChartContainer/ResizableContainer.js +0 -32
  404. package/node/ResponsiveChartContainer/index.js +0 -16
  405. package/node/ResponsiveChartContainer/useResponsiveChartContainerProps.js +0 -77
  406. /package/{internals/SlotComponentPropsFromProps.js → ChartsAxisHighlight/ChartsAxisHighlight.types.js} +0 -0
  407. /package/ChartsGrid/{styledCommonents.d.ts → styledComponents.d.ts} +0 -0
  408. /package/ChartsGrid/{styledCommonents.js → styledComponents.js} +0 -0
  409. /package/{models/helpers.js → ChartsTooltip/ChartTooltip.types.js} +0 -0
  410. /package/{modern/internals/SlotComponentPropsFromProps.js → context/DrawingAreaProvider/DrawingArea.types.js} +0 -0
  411. /package/{modern/models/helpers.js → context/SizeProvider/Size.types.js} +0 -0
  412. /package/modern/ChartsGrid/{styledCommonents.js → styledComponents.js} +0 -0
  413. /package/node/{internals/SlotComponentPropsFromProps.js → ChartsAxisHighlight/ChartsAxisHighlight.types.js} +0 -0
  414. /package/node/ChartsGrid/{styledCommonents.js → styledComponents.js} +0 -0
  415. /package/node/{models/helpers.js → ChartsTooltip/ChartTooltip.types.js} +0 -0
@@ -3,27 +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 { ChartContainer } from "../ChartContainer/index.js";
7
- import { ResizableContainer } from "./ResizableContainer.js";
8
- import { useResponsiveChartContainerProps } from "./useResponsiveChartContainerProps.js";
6
+ import { DrawingAreaProvider } from "../DrawingAreaProvider/index.js";
7
+ import { SeriesProvider } from "../SeriesProvider/index.js";
8
+ import { InteractionProvider } from "../InteractionProvider.js";
9
+ import { CartesianProvider } from "../CartesianProvider/index.js";
10
+ import { PluginProvider } from "../PluginProvider/index.js";
11
+ import { useChartDataProviderProps } from "./useChartDataProviderProps.js";
12
+ import { AnimationProvider } from "../AnimationProvider/index.js";
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";
9
17
  import { jsx as _jsx } from "react/jsx-runtime";
10
- const ResponsiveChartContainer = /*#__PURE__*/React.forwardRef(function ResponsiveChartContainer(props, ref) {
18
+ function ChartDataProvider(props) {
11
19
  const {
12
- hasIntrinsicSize,
13
- chartContainerProps,
14
- resizableChartContainerProps
15
- } = useResponsiveChartContainerProps(props, ref);
16
- return /*#__PURE__*/_jsx(ResizableContainer, _extends({}, resizableChartContainerProps, {
17
- children: hasIntrinsicSize ? /*#__PURE__*/_jsx(ChartContainer, _extends({}, chartContainerProps)) : null
20
+ children,
21
+ drawingAreaProviderProps,
22
+ seriesProviderProps,
23
+ cartesianProviderProps,
24
+ zAxisContextProps,
25
+ highlightedProviderProps,
26
+ pluginProviderProps,
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
+ })
42
+ }))
43
+ }))
44
+ })
45
+ }))
46
+ }))
47
+ }))
48
+ }))
49
+ }))
18
50
  }));
19
- });
20
- process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
51
+ }
52
+ process.env.NODE_ENV !== "production" ? ChartDataProvider.propTypes = {
21
53
  // ----------------------------- Warning --------------------------------
22
54
  // | These PropTypes are generated from the TypeScript type definitions |
23
55
  // | To update them edit the TypeScript types and run "pnpm proptypes" |
24
56
  // ----------------------------------------------------------------------
25
57
  children: PropTypes.node,
26
- className: PropTypes.string,
27
58
  /**
28
59
  * Color palette used to colorize multiple series.
29
60
  * @default blueberryTwilightPalette
@@ -33,13 +64,6 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
33
64
  * An array of objects that can be used to populate series and axes data using their `dataKey` property.
34
65
  */
35
66
  dataset: PropTypes.arrayOf(PropTypes.object),
36
- desc: PropTypes.string,
37
- /**
38
- * If `true`, the charts will not listen to the mouse move event.
39
- * It might break interactive features, but will improve performance.
40
- * @default false
41
- */
42
- disableAxisListener: PropTypes.bool,
43
67
  /**
44
68
  * The height of the chart in px. If not defined, it takes the height of the parent element.
45
69
  */
@@ -74,16 +98,6 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
74
98
  * If not provided, the container supports line, bar, scatter and pie charts.
75
99
  */
76
100
  plugins: PropTypes.arrayOf(PropTypes.object),
77
- /**
78
- * The chart will try to wait for the parent container to resolve its size
79
- * before it renders for the first time.
80
- *
81
- * This can be useful in some scenarios where the chart appear to grow after
82
- * the first render, like when used inside a grid.
83
- *
84
- * @default false
85
- */
86
- resolveSizeBeforeRender: PropTypes.bool,
87
101
  /**
88
102
  * The array of series to display.
89
103
  * Each type of series has its own specificity.
@@ -95,14 +109,6 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
95
109
  * If unset or `false`, the animations respects the user's `prefers-reduced-motion` setting.
96
110
  */
97
111
  skipAnimation: PropTypes.bool,
98
- sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
99
- title: PropTypes.string,
100
- viewBox: PropTypes.shape({
101
- height: PropTypes.number,
102
- width: PropTypes.number,
103
- x: PropTypes.number,
104
- y: PropTypes.number
105
- }),
106
112
  /**
107
113
  * The width of the chart in px. If not defined, it takes the width of the parent element.
108
114
  */
@@ -241,4 +247,4 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
241
247
  min: PropTypes.number
242
248
  }))
243
249
  } : void 0;
244
- export { ResponsiveChartContainer };
250
+ export { ChartDataProvider };
@@ -0,0 +1 @@
1
+ export * from "./ChartDataProvider.js";
@@ -0,0 +1,66 @@
1
+ 'use client';
2
+
3
+ import { useDefaultizeAxis } from "./useDefaultizeAxis.js";
4
+ export const useChartDataProviderProps = props => {
5
+ const {
6
+ width,
7
+ height,
8
+ series,
9
+ margin,
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
24
+ };
25
+ const animationProviderProps = {
26
+ skipAnimation
27
+ };
28
+ const pluginProviderProps = {
29
+ plugins
30
+ };
31
+ const seriesProviderProps = {
32
+ series,
33
+ colors,
34
+ dataset
35
+ };
36
+ const cartesianProviderProps = {
37
+ xAxis: defaultizedXAxis,
38
+ yAxis: defaultizedYAxis,
39
+ dataset
40
+ };
41
+ const zAxisContextProps = {
42
+ zAxis,
43
+ dataset
44
+ };
45
+ const highlightedProviderProps = {
46
+ highlightedItem,
47
+ onHighlightChange
48
+ };
49
+ const sizeProviderProps = {
50
+ width,
51
+ height
52
+ };
53
+ return {
54
+ children,
55
+ drawingAreaProviderProps,
56
+ seriesProviderProps,
57
+ cartesianProviderProps,
58
+ zAxisContextProps,
59
+ highlightedProviderProps,
60
+ pluginProviderProps,
61
+ animationProviderProps,
62
+ xAxis: defaultizedXAxis,
63
+ yAxis: defaultizedYAxis,
64
+ sizeProviderProps
65
+ };
66
+ };
@@ -2,7 +2,7 @@
2
2
 
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import * as React from 'react';
5
- import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from "../constants/index.js";
5
+ import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from "../../constants/index.js";
6
6
  const defaultizeAxis = (inAxis, dataset, axisName) => {
7
7
  const DEFAULT_AXIS_KEY = axisName === 'x' ? DEFAULT_X_AXIS_KEY : DEFAULT_Y_AXIS_KEY;
8
8
  return [...(inAxis?.map((axis, index) => _extends({
@@ -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,8 +1,5 @@
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 = ["highlighted", "faded"];
6
3
  import * as React from 'react';
7
4
  import PropTypes from 'prop-types';
8
5
  import useControlled from '@mui/utils/useControlled';
@@ -11,18 +8,6 @@ import { createIsFaded } from "./createIsFaded.js";
11
8
  import { createIsHighlighted } from "./createIsHighlighted.js";
12
9
  import { useSeries } from "../../hooks/useSeries.js";
13
10
  import { jsx as _jsx } from "react/jsx-runtime";
14
- const mergeDeprecatedOptions = options => {
15
- const _ref = options ?? {},
16
- {
17
- highlighted,
18
- faded
19
- } = _ref,
20
- other = _objectWithoutPropertiesLoose(_ref, _excluded);
21
- return _extends({
22
- highlight: highlighted,
23
- fade: faded
24
- }, other);
25
- };
26
11
  function HighlightedProvider({
27
12
  children,
28
13
  highlightedItem: highlightedItemProps,
@@ -41,7 +26,7 @@ function HighlightedProvider({
41
26
  const seriesData = series[seriesType];
42
27
  Object.keys(seriesData?.series ?? {}).forEach(seriesId => {
43
28
  const seriesItem = seriesData?.series[seriesId];
44
- map.set(seriesId, mergeDeprecatedOptions(seriesItem?.highlightScope));
29
+ map.set(seriesId, seriesItem?.highlightScope);
45
30
  });
46
31
  });
47
32
  return map;
@@ -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
+ }
@@ -0,0 +1,26 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import { SizeContext } from "./SizeContext.js";
5
+ import { useChartContainerDimensions } from "./useChartContainerDimensions.js";
6
+
7
+ /**
8
+ * The size provider.
9
+ *
10
+ * This differs from the DrawingProvider in that it provides the full size of the container.
11
+ *
12
+ * This provider is also responsible for resolving the size of the container before rendering and if the parent size changes.
13
+ */
14
+ import { jsx as _jsx } from "react/jsx-runtime";
15
+ function SizeProvider(props) {
16
+ const dimensions = useChartContainerDimensions(props.width, props.height);
17
+ const value = React.useMemo(() => ({
18
+ isInitialized: true,
19
+ data: dimensions
20
+ }), [dimensions]);
21
+ return /*#__PURE__*/_jsx(SizeContext.Provider, {
22
+ value: value,
23
+ children: props.children
24
+ });
25
+ }
26
+ export { SizeProvider };
@@ -0,0 +1,4 @@
1
+ export * from "./SizeProvider.js";
2
+ export * from "./SizeContext.js";
3
+ export * from "./useSize.js";
4
+ export * from "./Size.types.js";
@@ -1,9 +1,12 @@
1
1
  'use client';
2
2
 
3
+ /* eslint-disable react-compiler/react-compiler */
3
4
  import * as React from 'react';
4
5
  import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
5
6
  import ownerWindow from '@mui/utils/ownerWindow';
6
- export const useChartContainerDimensions = (inWidth, inHeight, resolveSizeBeforeRender) => {
7
+ const MAX_COMPUTE_RUN = 10;
8
+ export const useChartContainerDimensions = (inWidth, inHeight) => {
9
+ const hasInSize = inWidth !== undefined && inHeight !== undefined;
7
10
  const stateRef = React.useRef({
8
11
  displayError: false,
9
12
  initialCompute: true,
@@ -40,7 +43,7 @@ export const useChartContainerDimensions = (inWidth, inHeight, resolveSizeBefore
40
43
  // https://github.com/mui/mui-x/issues/13477#issuecomment-2336634785
41
44
  useEnhancedEffect(() => {
42
45
  // computeRun is used to avoid infinite loops.
43
- if (!resolveSizeBeforeRender || !stateRef.current.initialCompute || stateRef.current.computeRun > 20) {
46
+ if (hasInSize || !stateRef.current.initialCompute || stateRef.current.computeRun > MAX_COMPUTE_RUN) {
44
47
  return;
45
48
  }
46
49
  const computedSize = computeSize();
@@ -49,9 +52,9 @@ export const useChartContainerDimensions = (inWidth, inHeight, resolveSizeBefore
49
52
  } else if (stateRef.current.initialCompute) {
50
53
  stateRef.current.initialCompute = false;
51
54
  }
52
- }, [width, height, computeSize, resolveSizeBeforeRender]);
55
+ }, [width, height, computeSize, hasInSize]);
53
56
  useEnhancedEffect(() => {
54
- if (inWidth !== undefined && inHeight !== undefined) {
57
+ if (hasInSize) {
55
58
  return () => {};
56
59
  }
57
60
  computeSize();
@@ -77,7 +80,7 @@ export const useChartContainerDimensions = (inWidth, inHeight, resolveSizeBefore
77
80
  observer.unobserve(elementToObserve);
78
81
  }
79
82
  };
80
- }, [computeSize, inHeight, inWidth]);
83
+ }, [computeSize, hasInSize]);
81
84
  if (process.env.NODE_ENV !== 'production') {
82
85
  if (stateRef.current.displayError && inWidth === undefined && width === 0) {
83
86
  console.error(`MUI X: ChartContainer does not have \`width\` prop, and its container has no \`width\` defined.`);
@@ -88,9 +91,14 @@ export const useChartContainerDimensions = (inWidth, inHeight, resolveSizeBefore
88
91
  stateRef.current.displayError = false;
89
92
  }
90
93
  }
94
+ const finalWidth = inWidth ?? width;
95
+ const finalHeight = inHeight ?? height;
91
96
  return {
92
97
  containerRef: rootRef,
93
- width: inWidth ?? width,
94
- height: inHeight ?? height
98
+ width: finalWidth,
99
+ height: finalHeight,
100
+ hasIntrinsicSize: finalWidth > 0 && finalHeight > 0,
101
+ inWidth,
102
+ inHeight
95
103
  };
96
104
  };
@@ -0,0 +1,13 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import { SizeContext } from "./SizeContext.js";
5
+ /**
6
+ * Returns the size of the chart. And the ref of the container element that the chart is rendered in.
7
+ */
8
+ export const useSize = () => {
9
+ const {
10
+ data
11
+ } = React.useContext(SizeContext);
12
+ return data;
13
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ export const SvgRefContext = /*#__PURE__*/React.createContext({
5
+ isInitialized: false,
6
+ data: {
7
+ svgRef: {
8
+ current: null
9
+ },
10
+ surfaceRef: {
11
+ current: null
12
+ }
13
+ }
14
+ });
15
+ if (process.env.NODE_ENV !== 'production') {
16
+ SvgRefContext.displayName = 'SvgRefContext';
17
+ }
@@ -0,0 +1,24 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import useForkRef from '@mui/utils/useForkRef';
5
+ import { SvgRefContext } from "./SvgRefContext.js";
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ export function SvgRefProvider(props) {
8
+ const {
9
+ children
10
+ } = props;
11
+ const svgRef = React.useRef(null);
12
+ const surfaceRef = useForkRef(svgRef);
13
+ const refValue = React.useMemo(() => ({
14
+ isInitialized: true,
15
+ data: {
16
+ svgRef,
17
+ surfaceRef
18
+ }
19
+ }), [svgRef, surfaceRef]);
20
+ return /*#__PURE__*/_jsx(SvgRefContext.Provider, {
21
+ value: refValue,
22
+ children: children
23
+ });
24
+ }
@@ -0,0 +1,4 @@
1
+ export * from "./SvgRef.types.js";
2
+ export * from "./SvgRefProvider.js";
3
+ export * from "./SvgRefContext.js";
4
+ export * from "./useSurfaceRef.js";
@@ -0,0 +1,14 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import { SvgRefContext } from "./SvgRefContext.js";
5
+ export function useSurfaceRef() {
6
+ const {
7
+ isInitialized,
8
+ data
9
+ } = React.useContext(SvgRefContext);
10
+ if (!isInitialized) {
11
+ throw new Error(['MUI X: Could not find the svg ref context.', 'It looks like you rendered your component outside of a ChartsContainer parent component.'].join('\n'));
12
+ }
13
+ return data.surfaceRef;
14
+ }
@@ -1,2 +1,3 @@
1
1
  export * from "./HighlightedProvider/index.js";
2
- export { ZAxisContextProvider } from "./ZAxisContextProvider.js";
2
+ export { ZAxisContextProvider } from "./ZAxisContextProvider.js";
3
+ export { ChartDataProvider } from "./ChartDataProvider/index.js";