@mui/x-charts 7.16.0 → 7.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (398) hide show
  1. package/BarChart/BarChart.js +13 -0
  2. package/BarChart/BarElement.js +2 -0
  3. package/BarChart/BarLabel/BarLabel.js +2 -0
  4. package/BarChart/BarPlot.js +2 -0
  5. package/BarChart/legend.js +3 -2
  6. package/BarChart/useBarChartProps.js +2 -0
  7. package/CHANGELOG.md +184 -4
  8. package/ChartContainer/ChartContainer.js +2 -0
  9. package/ChartContainer/useChartContainerProps.js +2 -0
  10. package/ChartContainer/useDefaultizeAxis.js +2 -0
  11. package/ChartsAxis/ChartsAxis.js +2 -0
  12. package/ChartsAxisHighlight/ChartsAxisHighlight.js +2 -0
  13. package/ChartsClipPath/ChartsClipPath.js +2 -0
  14. package/ChartsGrid/ChartsGrid.js +2 -0
  15. package/ChartsLegend/ChartsLegend.d.ts +2 -2
  16. package/ChartsLegend/ChartsLegend.js +11 -1
  17. package/ChartsLegend/ChartsLegendItem.d.ts +26 -0
  18. package/ChartsLegend/ChartsLegendItem.js +65 -0
  19. package/ChartsLegend/ContinuousColorLegend.js +2 -0
  20. package/ChartsLegend/DefaultChartsLegend.d.ts +9 -1
  21. package/ChartsLegend/DefaultChartsLegend.js +26 -4
  22. package/ChartsLegend/LegendPerItem.d.ts +1 -0
  23. package/ChartsLegend/LegendPerItem.js +19 -28
  24. package/ChartsLegend/PiecewiseColorLegend.d.ts +9 -1
  25. package/ChartsLegend/PiecewiseColorLegend.js +28 -7
  26. package/ChartsLegend/chartsLegend.types.d.ts +39 -1
  27. package/ChartsLegend/chartsLegendClasses.d.ts +2 -0
  28. package/ChartsLegend/chartsLegendClasses.js +1 -1
  29. package/ChartsLegend/useAxis.js +2 -0
  30. package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +3 -1
  31. package/ChartsOverlay/ChartsLoadingOverlay.js +2 -0
  32. package/ChartsOverlay/ChartsNoDataOverlay.js +2 -0
  33. package/ChartsOverlay/ChartsOverlay.js +2 -0
  34. package/ChartsReferenceLine/ChartsReferenceLine.js +2 -0
  35. package/ChartsReferenceLine/ChartsXReferenceLine.js +3 -1
  36. package/ChartsReferenceLine/ChartsYReferenceLine.js +3 -1
  37. package/ChartsSurface/ChartsSurface.js +2 -0
  38. package/ChartsText/ChartsText.js +2 -0
  39. package/ChartsTooltip/ChartsTooltip.js +2 -0
  40. package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -0
  41. package/ChartsTooltip/DefaultChartsItemTooltipContent.js +2 -0
  42. package/ChartsTooltip/index.d.ts +3 -0
  43. package/ChartsTooltip/index.js +4 -1
  44. package/ChartsTooltip/useAxisTooltip.d.ts +18 -0
  45. package/ChartsTooltip/useAxisTooltip.js +84 -0
  46. package/ChartsTooltip/useItemTooltip.d.ts +10 -0
  47. package/ChartsTooltip/useItemTooltip.js +64 -0
  48. package/ChartsTooltip/utils.d.ts +2 -1
  49. package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -0
  50. package/ChartsXAxis/ChartsXAxis.js +2 -0
  51. package/ChartsYAxis/ChartsYAxis.js +2 -0
  52. package/Gauge/Gauge.js +2 -0
  53. package/Gauge/GaugeContainer.js +2 -0
  54. package/Gauge/GaugeReferenceArc.js +2 -0
  55. package/Gauge/GaugeValueArc.js +2 -0
  56. package/Gauge/GaugeValueText.js +2 -0
  57. package/LineChart/AnimatedArea.js +2 -0
  58. package/LineChart/AnimatedLine.js +14 -22
  59. package/LineChart/AreaElement.js +2 -0
  60. package/LineChart/AreaPlot.js +2 -0
  61. package/LineChart/CircleMarkElement.d.ts +34 -0
  62. package/LineChart/CircleMarkElement.js +107 -0
  63. package/LineChart/LineChart.d.ts +4 -0
  64. package/LineChart/LineChart.js +17 -0
  65. package/LineChart/LineElement.js +2 -0
  66. package/LineChart/LineHighlightElement.js +2 -0
  67. package/LineChart/LineHighlightPlot.js +2 -0
  68. package/LineChart/LinePlot.js +2 -0
  69. package/LineChart/MarkElement.d.ts +1 -19
  70. package/LineChart/MarkElement.js +3 -19
  71. package/LineChart/MarkPlot.d.ts +6 -0
  72. package/LineChart/MarkPlot.js +13 -3
  73. package/LineChart/index.d.ts +2 -0
  74. package/LineChart/index.js +2 -1
  75. package/LineChart/legend.js +3 -2
  76. package/LineChart/markElementClasses.d.ts +20 -0
  77. package/LineChart/markElementClasses.js +19 -0
  78. package/LineChart/useLineChartProps.js +7 -3
  79. package/PieChart/PieArc.js +2 -0
  80. package/PieChart/PieArcLabel.js +2 -0
  81. package/PieChart/PieArcLabelPlot.js +2 -0
  82. package/PieChart/PieArcPlot.js +2 -0
  83. package/PieChart/PieChart.js +13 -0
  84. package/PieChart/PiePlot.js +2 -0
  85. package/PieChart/dataTransform/useTransformData.js +2 -0
  86. package/PieChart/legend.js +3 -1
  87. package/ResponsiveChartContainer/ResponsiveChartContainer.d.ts +10 -0
  88. package/ResponsiveChartContainer/ResponsiveChartContainer.js +12 -0
  89. package/ResponsiveChartContainer/useChartContainerDimensions.d.ts +1 -1
  90. package/ResponsiveChartContainer/useChartContainerDimensions.js +35 -9
  91. package/ResponsiveChartContainer/useResponsiveChartContainerProps.js +5 -2
  92. package/ScatterChart/Scatter.js +2 -0
  93. package/ScatterChart/ScatterChart.js +13 -0
  94. package/ScatterChart/ScatterPlot.js +2 -0
  95. package/ScatterChart/legend.js +3 -2
  96. package/ScatterChart/useScatterChartProps.js +2 -0
  97. package/SparkLineChart/SparkLineChart.js +12 -0
  98. package/context/CartesianProvider/CartesianProvider.js +5 -3
  99. package/context/CartesianProvider/getAxisExtremum.d.ts +1 -1
  100. package/context/CartesianProvider/getAxisExtremum.js +5 -4
  101. package/context/CartesianProvider/index.d.ts +0 -5
  102. package/context/CartesianProvider/index.js +1 -6
  103. package/context/CartesianProvider/useCartesianContext.js +2 -0
  104. package/context/DrawingProvider.js +2 -0
  105. package/context/HighlightedProvider/HighlightedProvider.js +2 -0
  106. package/context/HighlightedProvider/useHighlighted.js +2 -0
  107. package/context/HighlightedProvider/useItemHighlighted.js +2 -0
  108. package/context/InteractionProvider.js +2 -0
  109. package/context/PluginProvider/ExtremumGetter.types.d.ts +1 -0
  110. package/context/PluginProvider/Plugin.types.d.ts +4 -0
  111. package/context/PluginProvider/PluginContext.js +3 -1
  112. package/context/PluginProvider/PluginProvider.js +2 -0
  113. package/context/PluginProvider/index.d.ts +2 -0
  114. package/context/PluginProvider/index.js +3 -1
  115. package/context/PluginProvider/mergePlugins.d.ts +10 -0
  116. package/context/PluginProvider/mergePlugins.js +11 -1
  117. package/context/PluginProvider/useColorProcessor.js +2 -0
  118. package/context/PluginProvider/useRadiusExtremumGetter.d.ts +4 -0
  119. package/context/PluginProvider/useRadiusExtremumGetter.js +17 -0
  120. package/context/PluginProvider/useRotationExtremumGetter.d.ts +4 -0
  121. package/context/PluginProvider/useRotationExtremumGetter.js +17 -0
  122. package/context/PluginProvider/useSeriesFormatter.js +2 -0
  123. package/context/PolarProvider/Polar.types.d.ts +42 -0
  124. package/context/PolarProvider/Polar.types.js +1 -0
  125. package/context/PolarProvider/PolarContext.d.ts +4 -0
  126. package/context/PolarProvider/PolarContext.js +13 -0
  127. package/context/PolarProvider/PolarProvider.d.ts +4 -0
  128. package/context/PolarProvider/PolarProvider.js +49 -0
  129. package/context/PolarProvider/getAxisExtremum.d.ts +4 -0
  130. package/context/PolarProvider/getAxisExtremum.js +20 -0
  131. package/context/PolarProvider/index.d.ts +0 -0
  132. package/context/PolarProvider/index.js +0 -0
  133. package/context/PolarProvider/usePolarContext.d.ts +2 -0
  134. package/context/PolarProvider/usePolarContext.js +10 -0
  135. package/context/SeriesProvider/SeriesProvider.js +2 -0
  136. package/context/ZAxisContextProvider.js +2 -0
  137. package/hooks/useAxis.js +2 -0
  138. package/hooks/useAxisEvents.js +2 -0
  139. package/hooks/useChartDimensions.js +2 -0
  140. package/hooks/useChartId.js +2 -0
  141. package/hooks/useColorScale.js +2 -0
  142. package/hooks/useDrawingArea.js +2 -0
  143. package/hooks/useInteractionItemProps.js +2 -0
  144. package/hooks/useMounted.js +2 -0
  145. package/hooks/useReducedMotion.js +2 -0
  146. package/hooks/useScale.js +2 -0
  147. package/hooks/useSeries.js +2 -0
  148. package/hooks/useSvgRef.js +2 -0
  149. package/hooks/useTicks.js +2 -0
  150. package/index.js +1 -1
  151. package/internals/computeAxisValue.d.ts +38 -0
  152. package/{modern/context/CartesianProvider/computeValue.js → internals/computeAxisValue.js} +28 -15
  153. package/internals/index.d.ts +1 -0
  154. package/internals/index.js +1 -0
  155. package/models/axis.d.ts +20 -0
  156. package/models/seriesType/config.d.ts +6 -2
  157. package/modern/BarChart/BarChart.js +13 -0
  158. package/modern/BarChart/BarElement.js +2 -0
  159. package/modern/BarChart/BarLabel/BarLabel.js +2 -0
  160. package/modern/BarChart/BarPlot.js +2 -0
  161. package/modern/BarChart/legend.js +3 -2
  162. package/modern/BarChart/useBarChartProps.js +2 -0
  163. package/modern/ChartContainer/ChartContainer.js +2 -0
  164. package/modern/ChartContainer/useChartContainerProps.js +2 -0
  165. package/modern/ChartContainer/useDefaultizeAxis.js +2 -0
  166. package/modern/ChartsAxis/ChartsAxis.js +2 -0
  167. package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +2 -0
  168. package/modern/ChartsClipPath/ChartsClipPath.js +2 -0
  169. package/modern/ChartsGrid/ChartsGrid.js +2 -0
  170. package/modern/ChartsLegend/ChartsLegend.js +11 -1
  171. package/modern/ChartsLegend/ChartsLegendItem.js +65 -0
  172. package/modern/ChartsLegend/ContinuousColorLegend.js +2 -0
  173. package/modern/ChartsLegend/DefaultChartsLegend.js +26 -4
  174. package/modern/ChartsLegend/LegendPerItem.js +19 -28
  175. package/modern/ChartsLegend/PiecewiseColorLegend.js +28 -7
  176. package/modern/ChartsLegend/chartsLegendClasses.js +1 -1
  177. package/modern/ChartsLegend/useAxis.js +2 -0
  178. package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +3 -1
  179. package/modern/ChartsOverlay/ChartsLoadingOverlay.js +2 -0
  180. package/modern/ChartsOverlay/ChartsNoDataOverlay.js +2 -0
  181. package/modern/ChartsOverlay/ChartsOverlay.js +2 -0
  182. package/modern/ChartsReferenceLine/ChartsReferenceLine.js +2 -0
  183. package/modern/ChartsReferenceLine/ChartsXReferenceLine.js +3 -1
  184. package/modern/ChartsReferenceLine/ChartsYReferenceLine.js +3 -1
  185. package/modern/ChartsSurface/ChartsSurface.js +2 -0
  186. package/modern/ChartsText/ChartsText.js +2 -0
  187. package/modern/ChartsTooltip/ChartsTooltip.js +2 -0
  188. package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -0
  189. package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +2 -0
  190. package/modern/ChartsTooltip/index.js +4 -1
  191. package/modern/ChartsTooltip/useAxisTooltip.js +84 -0
  192. package/modern/ChartsTooltip/useItemTooltip.js +64 -0
  193. package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -0
  194. package/modern/ChartsXAxis/ChartsXAxis.js +2 -0
  195. package/modern/ChartsYAxis/ChartsYAxis.js +2 -0
  196. package/modern/Gauge/Gauge.js +2 -0
  197. package/modern/Gauge/GaugeContainer.js +2 -0
  198. package/modern/Gauge/GaugeReferenceArc.js +2 -0
  199. package/modern/Gauge/GaugeValueArc.js +2 -0
  200. package/modern/Gauge/GaugeValueText.js +2 -0
  201. package/modern/LineChart/AnimatedArea.js +2 -0
  202. package/modern/LineChart/AnimatedLine.js +14 -22
  203. package/modern/LineChart/AreaElement.js +2 -0
  204. package/modern/LineChart/AreaPlot.js +2 -0
  205. package/modern/LineChart/CircleMarkElement.js +107 -0
  206. package/modern/LineChart/LineChart.js +17 -0
  207. package/modern/LineChart/LineElement.js +2 -0
  208. package/modern/LineChart/LineHighlightElement.js +2 -0
  209. package/modern/LineChart/LineHighlightPlot.js +2 -0
  210. package/modern/LineChart/LinePlot.js +2 -0
  211. package/modern/LineChart/MarkElement.js +3 -19
  212. package/modern/LineChart/MarkPlot.js +13 -3
  213. package/modern/LineChart/index.js +2 -1
  214. package/modern/LineChart/legend.js +3 -2
  215. package/modern/LineChart/markElementClasses.js +19 -0
  216. package/modern/LineChart/useLineChartProps.js +7 -3
  217. package/modern/PieChart/PieArc.js +2 -0
  218. package/modern/PieChart/PieArcLabel.js +2 -0
  219. package/modern/PieChart/PieArcLabelPlot.js +2 -0
  220. package/modern/PieChart/PieArcPlot.js +2 -0
  221. package/modern/PieChart/PieChart.js +13 -0
  222. package/modern/PieChart/PiePlot.js +2 -0
  223. package/modern/PieChart/dataTransform/useTransformData.js +2 -0
  224. package/modern/PieChart/legend.js +3 -1
  225. package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +12 -0
  226. package/modern/ResponsiveChartContainer/useChartContainerDimensions.js +35 -9
  227. package/modern/ResponsiveChartContainer/useResponsiveChartContainerProps.js +5 -2
  228. package/modern/ScatterChart/Scatter.js +2 -0
  229. package/modern/ScatterChart/ScatterChart.js +13 -0
  230. package/modern/ScatterChart/ScatterPlot.js +2 -0
  231. package/modern/ScatterChart/legend.js +3 -2
  232. package/modern/ScatterChart/useScatterChartProps.js +2 -0
  233. package/modern/SparkLineChart/SparkLineChart.js +12 -0
  234. package/modern/context/CartesianProvider/CartesianProvider.js +5 -3
  235. package/modern/context/CartesianProvider/getAxisExtremum.js +5 -4
  236. package/modern/context/CartesianProvider/index.js +1 -6
  237. package/modern/context/CartesianProvider/useCartesianContext.js +2 -0
  238. package/modern/context/DrawingProvider.js +2 -0
  239. package/modern/context/HighlightedProvider/HighlightedProvider.js +2 -0
  240. package/modern/context/HighlightedProvider/useHighlighted.js +2 -0
  241. package/modern/context/HighlightedProvider/useItemHighlighted.js +2 -0
  242. package/modern/context/InteractionProvider.js +2 -0
  243. package/modern/context/PluginProvider/PluginContext.js +3 -1
  244. package/modern/context/PluginProvider/PluginProvider.js +2 -0
  245. package/modern/context/PluginProvider/index.js +3 -1
  246. package/modern/context/PluginProvider/mergePlugins.js +11 -1
  247. package/modern/context/PluginProvider/useColorProcessor.js +2 -0
  248. package/modern/context/PluginProvider/useRadiusExtremumGetter.js +17 -0
  249. package/modern/context/PluginProvider/useRotationExtremumGetter.js +17 -0
  250. package/modern/context/PluginProvider/useSeriesFormatter.js +2 -0
  251. package/modern/context/PolarProvider/Polar.types.js +1 -0
  252. package/modern/context/PolarProvider/PolarContext.js +13 -0
  253. package/modern/context/PolarProvider/PolarProvider.js +49 -0
  254. package/modern/context/PolarProvider/getAxisExtremum.js +20 -0
  255. package/modern/context/PolarProvider/index.js +0 -0
  256. package/modern/context/PolarProvider/usePolarContext.js +10 -0
  257. package/modern/context/SeriesProvider/SeriesProvider.js +2 -0
  258. package/modern/context/ZAxisContextProvider.js +2 -0
  259. package/modern/hooks/useAxis.js +2 -0
  260. package/modern/hooks/useAxisEvents.js +2 -0
  261. package/modern/hooks/useChartDimensions.js +2 -0
  262. package/modern/hooks/useChartId.js +2 -0
  263. package/modern/hooks/useColorScale.js +2 -0
  264. package/modern/hooks/useDrawingArea.js +2 -0
  265. package/modern/hooks/useInteractionItemProps.js +2 -0
  266. package/modern/hooks/useMounted.js +2 -0
  267. package/modern/hooks/useReducedMotion.js +2 -0
  268. package/modern/hooks/useScale.js +2 -0
  269. package/modern/hooks/useSeries.js +2 -0
  270. package/modern/hooks/useSvgRef.js +2 -0
  271. package/modern/hooks/useTicks.js +2 -0
  272. package/modern/index.js +1 -1
  273. package/{context/CartesianProvider/computeValue.js → modern/internals/computeAxisValue.js} +28 -15
  274. package/modern/internals/index.js +1 -0
  275. package/node/BarChart/BarChart.js +12 -0
  276. package/node/BarChart/BarElement.js +1 -0
  277. package/node/BarChart/BarLabel/BarLabel.js +1 -0
  278. package/node/BarChart/BarPlot.js +1 -0
  279. package/node/BarChart/legend.js +3 -2
  280. package/node/BarChart/useBarChartProps.js +1 -0
  281. package/node/ChartContainer/ChartContainer.js +1 -0
  282. package/node/ChartContainer/useChartContainerProps.js +1 -0
  283. package/node/ChartContainer/useDefaultizeAxis.js +1 -0
  284. package/node/ChartsAxis/ChartsAxis.js +1 -0
  285. package/node/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -0
  286. package/node/ChartsClipPath/ChartsClipPath.js +1 -0
  287. package/node/ChartsGrid/ChartsGrid.js +1 -0
  288. package/node/ChartsLegend/ChartsLegend.js +10 -1
  289. package/node/ChartsLegend/ChartsLegendItem.js +72 -0
  290. package/node/ChartsLegend/ContinuousColorLegend.js +1 -0
  291. package/node/ChartsLegend/DefaultChartsLegend.js +25 -4
  292. package/node/ChartsLegend/LegendPerItem.js +18 -28
  293. package/node/ChartsLegend/PiecewiseColorLegend.js +27 -7
  294. package/node/ChartsLegend/chartsLegendClasses.js +1 -1
  295. package/node/ChartsLegend/useAxis.js +1 -0
  296. package/node/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -1
  297. package/node/ChartsOverlay/ChartsLoadingOverlay.js +1 -0
  298. package/node/ChartsOverlay/ChartsNoDataOverlay.js +1 -0
  299. package/node/ChartsOverlay/ChartsOverlay.js +1 -0
  300. package/node/ChartsReferenceLine/ChartsReferenceLine.js +1 -0
  301. package/node/ChartsReferenceLine/ChartsXReferenceLine.js +2 -1
  302. package/node/ChartsReferenceLine/ChartsYReferenceLine.js +2 -1
  303. package/node/ChartsSurface/ChartsSurface.js +1 -0
  304. package/node/ChartsText/ChartsText.js +1 -0
  305. package/node/ChartsTooltip/ChartsTooltip.js +1 -0
  306. package/node/ChartsTooltip/DefaultChartsAxisTooltipContent.js +1 -0
  307. package/node/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -0
  308. package/node/ChartsTooltip/index.js +42 -1
  309. package/node/ChartsTooltip/useAxisTooltip.js +90 -0
  310. package/node/ChartsTooltip/useItemTooltip.js +71 -0
  311. package/node/ChartsVoronoiHandler/ChartsVoronoiHandler.js +1 -0
  312. package/node/ChartsXAxis/ChartsXAxis.js +1 -0
  313. package/node/ChartsYAxis/ChartsYAxis.js +1 -0
  314. package/node/Gauge/Gauge.js +1 -0
  315. package/node/Gauge/GaugeContainer.js +1 -0
  316. package/node/Gauge/GaugeReferenceArc.js +1 -0
  317. package/node/Gauge/GaugeValueArc.js +1 -0
  318. package/node/Gauge/GaugeValueText.js +1 -0
  319. package/node/LineChart/AnimatedArea.js +1 -0
  320. package/node/LineChart/AnimatedLine.js +13 -22
  321. package/node/LineChart/AreaElement.js +1 -0
  322. package/node/LineChart/AreaPlot.js +1 -0
  323. package/node/LineChart/CircleMarkElement.js +113 -0
  324. package/node/LineChart/LineChart.js +16 -0
  325. package/node/LineChart/LineElement.js +1 -0
  326. package/node/LineChart/LineHighlightElement.js +1 -0
  327. package/node/LineChart/LineHighlightPlot.js +1 -0
  328. package/node/LineChart/LinePlot.js +1 -0
  329. package/node/LineChart/MarkElement.js +3 -22
  330. package/node/LineChart/MarkPlot.js +12 -3
  331. package/node/LineChart/index.js +29 -1
  332. package/node/LineChart/legend.js +3 -2
  333. package/node/LineChart/markElementClasses.js +28 -0
  334. package/node/LineChart/useLineChartProps.js +6 -3
  335. package/node/PieChart/PieArc.js +1 -0
  336. package/node/PieChart/PieArcLabel.js +1 -0
  337. package/node/PieChart/PieArcLabelPlot.js +1 -0
  338. package/node/PieChart/PieArcPlot.js +1 -0
  339. package/node/PieChart/PieChart.js +12 -0
  340. package/node/PieChart/PiePlot.js +1 -0
  341. package/node/PieChart/dataTransform/useTransformData.js +1 -0
  342. package/node/PieChart/legend.js +3 -1
  343. package/node/ResponsiveChartContainer/ResponsiveChartContainer.js +11 -0
  344. package/node/ResponsiveChartContainer/useChartContainerDimensions.js +34 -9
  345. package/node/ResponsiveChartContainer/useResponsiveChartContainerProps.js +4 -2
  346. package/node/ScatterChart/Scatter.js +1 -0
  347. package/node/ScatterChart/ScatterChart.js +12 -0
  348. package/node/ScatterChart/ScatterPlot.js +1 -0
  349. package/node/ScatterChart/legend.js +3 -2
  350. package/node/ScatterChart/useScatterChartProps.js +1 -0
  351. package/node/SparkLineChart/SparkLineChart.js +11 -0
  352. package/node/context/CartesianProvider/CartesianProvider.js +4 -3
  353. package/node/context/CartesianProvider/getAxisExtremum.js +5 -4
  354. package/node/context/CartesianProvider/index.js +1 -13
  355. package/node/context/CartesianProvider/useCartesianContext.js +1 -0
  356. package/node/context/DrawingProvider.js +1 -0
  357. package/node/context/HighlightedProvider/HighlightedProvider.js +1 -0
  358. package/node/context/HighlightedProvider/useHighlighted.js +1 -0
  359. package/node/context/HighlightedProvider/useItemHighlighted.js +1 -0
  360. package/node/context/InteractionProvider.js +1 -0
  361. package/node/context/PluginProvider/PluginContext.js +3 -1
  362. package/node/context/PluginProvider/PluginProvider.js +1 -0
  363. package/node/context/PluginProvider/index.js +22 -0
  364. package/node/context/PluginProvider/mergePlugins.js +11 -1
  365. package/node/context/PluginProvider/useColorProcessor.js +1 -0
  366. package/node/context/PluginProvider/useRadiusExtremumGetter.js +23 -0
  367. package/node/context/PluginProvider/useRotationExtremumGetter.js +23 -0
  368. package/node/context/PluginProvider/useSeriesFormatter.js +1 -0
  369. package/node/context/PolarProvider/Polar.types.js +5 -0
  370. package/node/context/PolarProvider/PolarContext.js +20 -0
  371. package/node/context/PolarProvider/PolarProvider.js +54 -0
  372. package/node/context/PolarProvider/getAxisExtremum.js +27 -0
  373. package/node/context/PolarProvider/index.js +1 -0
  374. package/node/context/PolarProvider/usePolarContext.js +17 -0
  375. package/node/context/SeriesProvider/SeriesProvider.js +1 -0
  376. package/node/context/ZAxisContextProvider.js +1 -0
  377. package/node/hooks/useAxis.js +1 -0
  378. package/node/hooks/useAxisEvents.js +1 -0
  379. package/node/hooks/useChartDimensions.js +1 -0
  380. package/node/hooks/useChartId.js +1 -0
  381. package/node/hooks/useColorScale.js +1 -0
  382. package/node/hooks/useDrawingArea.js +1 -0
  383. package/node/hooks/useInteractionItemProps.js +1 -0
  384. package/node/hooks/useMounted.js +1 -0
  385. package/node/hooks/useReducedMotion.js +1 -0
  386. package/node/hooks/useScale.js +1 -0
  387. package/node/hooks/useSeries.js +1 -0
  388. package/node/hooks/useSvgRef.js +1 -0
  389. package/node/hooks/useTicks.js +1 -0
  390. package/node/index.js +1 -1
  391. package/node/{context/CartesianProvider/computeValue.js → internals/computeAxisValue.js} +29 -16
  392. package/node/internals/index.js +12 -0
  393. package/package.json +4 -4
  394. package/context/CartesianProvider/computeValue.d.ts +0 -30
  395. package/internals/warning.d.ts +0 -2
  396. package/internals/warning.js +0 -21
  397. package/modern/internals/warning.js +0 -21
  398. package/node/internals/warning.js +0 -28
@@ -0,0 +1,107 @@
1
+ 'use client';
2
+
3
+ import _extends from "@babel/runtime/helpers/esm/extends";
4
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
5
+ const _excluded = ["x", "y", "id", "classes", "color", "dataIndex", "onClick", "skipAnimation", "shape"];
6
+ import * as React from 'react';
7
+ import PropTypes from 'prop-types';
8
+ import { useTheme } from '@mui/material/styles';
9
+ import { warnOnce } from '@mui/x-internals/warning';
10
+ import { animated, useSpring } from '@react-spring/web';
11
+ import { InteractionContext } from "../context/InteractionProvider.js";
12
+ import { useInteractionItemProps } from "../hooks/useInteractionItemProps.js";
13
+ import { useItemHighlighted } from "../context/index.js";
14
+ import { useUtilityClasses } from "./markElementClasses.js";
15
+ import { jsx as _jsx } from "react/jsx-runtime";
16
+ /**
17
+ * The line mark element that only render circle for performance improvement.
18
+ *
19
+ * Demos:
20
+ *
21
+ * - [Lines](https://mui.com/x/react-charts/lines/)
22
+ * - [Line demonstration](https://mui.com/x/react-charts/line-demo/)
23
+ *
24
+ * API:
25
+ *
26
+ * - [CircleMarkElement API](https://mui.com/x/api/charts/circle-mark-element/)
27
+ */
28
+ function CircleMarkElement(props) {
29
+ const {
30
+ x,
31
+ y,
32
+ id,
33
+ classes: innerClasses,
34
+ color,
35
+ dataIndex,
36
+ onClick,
37
+ skipAnimation,
38
+ shape
39
+ } = props,
40
+ other = _objectWithoutPropertiesLoose(props, _excluded);
41
+ if (shape !== 'circle') {
42
+ warnOnce([`MUI X: The mark element of your line chart have shape "${shape}" which is not supported when using \`experimentalRendering=true\`.`, 'Only "circle" are supported with `experimentalRendering`.'].join('\n'), 'error');
43
+ }
44
+ const theme = useTheme();
45
+ const getInteractionItemProps = useInteractionItemProps();
46
+ const {
47
+ isFaded,
48
+ isHighlighted
49
+ } = useItemHighlighted({
50
+ seriesId: id
51
+ });
52
+ const {
53
+ axis
54
+ } = React.useContext(InteractionContext);
55
+ const position = useSpring({
56
+ to: {
57
+ x,
58
+ y
59
+ },
60
+ immediate: skipAnimation
61
+ });
62
+ const ownerState = {
63
+ id,
64
+ classes: innerClasses,
65
+ isHighlighted: axis.x?.index === dataIndex || isHighlighted,
66
+ isFaded,
67
+ color
68
+ };
69
+ const classes = useUtilityClasses(ownerState);
70
+ return /*#__PURE__*/_jsx(animated.circle, _extends({}, other, {
71
+ cx: position.x,
72
+ cy: position.y,
73
+ r: 5,
74
+ fill: (theme.vars || theme).palette.background.paper,
75
+ stroke: color,
76
+ strokeWidth: 2,
77
+ className: classes.root,
78
+ onClick: onClick,
79
+ cursor: onClick ? 'pointer' : 'unset'
80
+ }, getInteractionItemProps({
81
+ type: 'line',
82
+ seriesId: id,
83
+ dataIndex
84
+ })));
85
+ }
86
+ process.env.NODE_ENV !== "production" ? CircleMarkElement.propTypes = {
87
+ // ----------------------------- Warning --------------------------------
88
+ // | These PropTypes are generated from the TypeScript type definitions |
89
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
90
+ // ----------------------------------------------------------------------
91
+ classes: PropTypes.object,
92
+ /**
93
+ * The index to the element in the series' data array.
94
+ */
95
+ dataIndex: PropTypes.number.isRequired,
96
+ id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
97
+ /**
98
+ * The shape of the marker.
99
+ */
100
+ shape: PropTypes.oneOf(['circle', 'cross', 'diamond', 'square', 'star', 'triangle', 'wye']).isRequired,
101
+ /**
102
+ * If `true`, animations are skipped.
103
+ * @default false
104
+ */
105
+ skipAnimation: PropTypes.bool
106
+ } : void 0;
107
+ export { CircleMarkElement };
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import _extends from "@babel/runtime/helpers/esm/extends";
2
4
  import * as React from 'react';
3
5
  import PropTypes from 'prop-types';
@@ -102,6 +104,10 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
102
104
  * If `true`, render the line highlight item.
103
105
  */
104
106
  disableLineItemHighlight: PropTypes.bool,
107
+ /**
108
+ * If `true` marks will render `<circle />` instead of `<path />` and drop theme override for faster rendering.
109
+ */
110
+ experimentalMarkRendering: PropTypes.bool,
105
111
  /**
106
112
  * Option to display a cartesian grid in the background.
107
113
  */
@@ -138,6 +144,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
138
144
  itemMarkWidth: PropTypes.number,
139
145
  labelStyle: PropTypes.object,
140
146
  markGap: PropTypes.number,
147
+ onItemClick: PropTypes.func,
141
148
  padding: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
142
149
  bottom: PropTypes.number,
143
150
  left: PropTypes.number,
@@ -193,6 +200,16 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
193
200
  * Callback fired when a mark element is clicked.
194
201
  */
195
202
  onMarkClick: PropTypes.func,
203
+ /**
204
+ * The chart will try to wait for the parent container to resolve its size
205
+ * before it renders for the first time.
206
+ *
207
+ * This can be useful in some scenarios where the chart appear to grow after
208
+ * the first render, like when used inside a grid.
209
+ *
210
+ * @default false
211
+ */
212
+ resolveSizeBeforeRender: PropTypes.bool,
196
213
  /**
197
214
  * Indicate which axis to display the right of the charts.
198
215
  * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import _extends from "@babel/runtime/helpers/esm/extends";
2
4
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
5
  const _excluded = ["id", "classes", "color", "gradientId", "slots", "slotProps", "onClick"];
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import _extends from "@babel/runtime/helpers/esm/extends";
2
4
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
5
  const _excluded = ["x", "y", "id", "classes", "color"];
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import _extends from "@babel/runtime/helpers/esm/extends";
2
4
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
5
  const _excluded = ["slots", "slotProps"];
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
4
  import _extends from "@babel/runtime/helpers/esm/extends";
3
5
  const _excluded = ["slots", "slotProps", "skipAnimation", "onItemClick"];
@@ -1,35 +1,19 @@
1
+ 'use client';
2
+
1
3
  import _extends from "@babel/runtime/helpers/esm/extends";
2
4
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
5
  const _excluded = ["x", "y", "id", "classes", "color", "shape", "dataIndex", "onClick", "skipAnimation"];
4
6
  import * as React from 'react';
5
7
  import PropTypes from 'prop-types';
6
- import composeClasses from '@mui/utils/composeClasses';
7
- import generateUtilityClass from '@mui/utils/generateUtilityClass';
8
8
  import { styled } from '@mui/material/styles';
9
- import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
10
9
  import { symbol as d3Symbol, symbolsFill as d3SymbolsFill } from '@mui/x-charts-vendor/d3-shape';
11
10
  import { animated, to, useSpring } from '@react-spring/web';
12
11
  import { getSymbol } from "../internals/getSymbol.js";
13
12
  import { InteractionContext } from "../context/InteractionProvider.js";
14
13
  import { useInteractionItemProps } from "../hooks/useInteractionItemProps.js";
15
14
  import { useItemHighlighted } from "../context/index.js";
15
+ import { useUtilityClasses } from "./markElementClasses.js";
16
16
  import { jsx as _jsx } from "react/jsx-runtime";
17
- export function getMarkElementUtilityClass(slot) {
18
- return generateUtilityClass('MuiMarkElement', slot);
19
- }
20
- export const markElementClasses = generateUtilityClasses('MuiMarkElement', ['root', 'highlighted', 'faded']);
21
- const useUtilityClasses = ownerState => {
22
- const {
23
- classes,
24
- id,
25
- isFaded,
26
- isHighlighted
27
- } = ownerState;
28
- const slots = {
29
- root: ['root', `series-${id}`, isHighlighted && 'highlighted', isFaded && 'faded']
30
- };
31
- return composeClasses(slots, getMarkElementUtilityClass, classes);
32
- };
33
17
  const MarkElementPath = styled(animated.path, {
34
18
  name: 'MuiMarkElement',
35
19
  slot: 'Root',
@@ -1,6 +1,8 @@
1
+ 'use client';
2
+
1
3
  import _extends from "@babel/runtime/helpers/esm/extends";
2
4
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["slots", "slotProps", "skipAnimation", "onItemClick"];
5
+ const _excluded = ["slots", "slotProps", "skipAnimation", "onItemClick", "experimentalRendering"];
4
6
  import * as React from 'react';
5
7
  import PropTypes from 'prop-types';
6
8
  import { useCartesianContext } from "../context/CartesianProvider/index.js";
@@ -12,6 +14,7 @@ import { cleanId } from "../internals/cleanId.js";
12
14
  import getColor from "./getColor.js";
13
15
  import { useLineSeries } from "../hooks/useSeries.js";
14
16
  import { useDrawingArea } from "../hooks/useDrawingArea.js";
17
+ import { CircleMarkElement } from "./CircleMarkElement.js";
15
18
  import { jsx as _jsx } from "react/jsx-runtime";
16
19
  /**
17
20
  * Demos:
@@ -28,14 +31,15 @@ function MarkPlot(props) {
28
31
  slots,
29
32
  slotProps,
30
33
  skipAnimation,
31
- onItemClick
34
+ onItemClick,
35
+ experimentalRendering
32
36
  } = props,
33
37
  other = _objectWithoutPropertiesLoose(props, _excluded);
34
38
  const seriesData = useLineSeries();
35
39
  const axisData = useCartesianContext();
36
40
  const chartId = useChartId();
37
41
  const drawingArea = useDrawingArea();
38
- const Mark = slots?.mark ?? MarkElement;
42
+ const Mark = slots?.mark ?? (experimentalRendering ? CircleMarkElement : MarkElement);
39
43
  if (seriesData === undefined) {
40
44
  return null;
41
45
  }
@@ -149,6 +153,12 @@ process.env.NODE_ENV !== "production" ? MarkPlot.propTypes = {
149
153
  // | These PropTypes are generated from the TypeScript type definitions |
150
154
  // | To update them edit the TypeScript types and run "pnpm proptypes" |
151
155
  // ----------------------------------------------------------------------
156
+ /**
157
+ * If `true` the mark element will only be able to render circle.
158
+ * Giving fewer customization options, but saving around 40ms per 1.000 marks.
159
+ * @default false
160
+ */
161
+ experimentalRendering: PropTypes.bool,
152
162
  /**
153
163
  * Callback fired when a line mark item is clicked.
154
164
  * @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
@@ -8,4 +8,5 @@ export * from "./AnimatedArea.js";
8
8
  export * from "./LineElement.js";
9
9
  export * from "./AnimatedLine.js";
10
10
  export * from "./MarkElement.js";
11
- export * from "./LineHighlightElement.js";
11
+ export * from "./LineHighlightElement.js";
12
+ export { getMarkElementUtilityClass, markElementClasses } from "./markElementClasses.js";
@@ -10,9 +10,10 @@ const legendGetter = params => {
10
10
  return acc;
11
11
  }
12
12
  acc.push({
13
+ id: seriesId,
14
+ seriesId,
13
15
  color: series[seriesId].color,
14
- label: formattedLabel,
15
- id: seriesId
16
+ label: formattedLabel
16
17
  });
17
18
  return acc;
18
19
  }, []);
@@ -0,0 +1,19 @@
1
+ import composeClasses from '@mui/utils/composeClasses';
2
+ import generateUtilityClass from '@mui/utils/generateUtilityClass';
3
+ import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
4
+ export function getMarkElementUtilityClass(slot) {
5
+ return generateUtilityClass('MuiMarkElement', slot);
6
+ }
7
+ export const markElementClasses = generateUtilityClasses('MuiMarkElement', ['root', 'highlighted', 'faded']);
8
+ export const useUtilityClasses = ownerState => {
9
+ const {
10
+ classes,
11
+ id,
12
+ isFaded,
13
+ isHighlighted
14
+ } = ownerState;
15
+ const slots = {
16
+ root: ['root', `series-${id}`, isHighlighted && 'highlighted', isFaded && 'faded']
17
+ };
18
+ return composeClasses(slots, getMarkElementUtilityClass, classes);
19
+ };
@@ -1,6 +1,8 @@
1
+ 'use client';
2
+
1
3
  import _extends from "@babel/runtime/helpers/esm/extends";
2
4
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["xAxis", "yAxis", "series", "width", "height", "margin", "colors", "dataset", "sx", "tooltip", "onAxisClick", "onAreaClick", "onLineClick", "onMarkClick", "axisHighlight", "disableLineItemHighlight", "legend", "grid", "topAxis", "leftAxis", "rightAxis", "bottomAxis", "children", "slots", "slotProps", "skipAnimation", "loading", "highlightedItem", "onHighlightChange", "className"];
5
+ const _excluded = ["xAxis", "yAxis", "series", "width", "height", "margin", "colors", "dataset", "sx", "tooltip", "onAxisClick", "onAreaClick", "onLineClick", "onMarkClick", "axisHighlight", "disableLineItemHighlight", "legend", "grid", "topAxis", "leftAxis", "rightAxis", "bottomAxis", "children", "slots", "slotProps", "skipAnimation", "loading", "highlightedItem", "onHighlightChange", "className", "experimentalMarkRendering"];
4
6
  import useId from '@mui/utils/useId';
5
7
  import { DEFAULT_X_AXIS_KEY } from "../constants/index.js";
6
8
  /**
@@ -41,7 +43,8 @@ export const useLineChartProps = props => {
41
43
  loading,
42
44
  highlightedItem,
43
45
  onHighlightChange,
44
- className
46
+ className,
47
+ experimentalMarkRendering
45
48
  } = props,
46
49
  other = _objectWithoutPropertiesLoose(props, _excluded);
47
50
  const id = useId();
@@ -99,7 +102,8 @@ export const useLineChartProps = props => {
99
102
  slots,
100
103
  slotProps,
101
104
  onItemClick: onMarkClick,
102
- skipAnimation
105
+ skipAnimation,
106
+ experimentalRendering: experimentalMarkRendering
103
107
  };
104
108
  const overlayProps = {
105
109
  slots,
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import _extends from "@babel/runtime/helpers/esm/extends";
2
4
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
5
  const _excluded = ["classes", "color", "cornerRadius", "dataIndex", "endAngle", "id", "innerRadius", "isFaded", "isHighlighted", "onClick", "outerRadius", "paddingAngle", "startAngle", "highlightScope"];
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import _extends from "@babel/runtime/helpers/esm/extends";
2
4
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
5
  const _excluded = ["id", "classes", "color", "startAngle", "endAngle", "paddingAngle", "arcLabelRadius", "innerRadius", "outerRadius", "cornerRadius", "formattedArcLabel", "isHighlighted", "isFaded", "style"];
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
4
  import _extends from "@babel/runtime/helpers/esm/extends";
3
5
  const _excluded = ["arcLabel", "arcLabelMinAngle", "arcLabelRadius", "cornerRadius", "data", "faded", "highlighted", "id", "innerRadius", "outerRadius", "paddingAngle", "skipAnimation", "slotProps", "slots"],
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import _extends from "@babel/runtime/helpers/esm/extends";
2
4
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
5
  const _excluded = ["slots", "slotProps", "innerRadius", "outerRadius", "cornerRadius", "paddingAngle", "id", "highlighted", "faded", "data", "onItemClick", "skipAnimation"],
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import _extends from "@babel/runtime/helpers/esm/extends";
2
4
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
5
  const _excluded = ["xAxis", "yAxis", "series", "width", "height", "margin", "colors", "sx", "tooltip", "axisHighlight", "skipAnimation", "legend", "topAxis", "leftAxis", "rightAxis", "bottomAxis", "children", "slots", "slotProps", "onItemClick", "loading", "highlightedItem", "onHighlightChange", "className"];
@@ -197,6 +199,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
197
199
  itemMarkWidth: PropTypes.number,
198
200
  labelStyle: PropTypes.object,
199
201
  markGap: PropTypes.number,
202
+ onItemClick: PropTypes.func,
200
203
  padding: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
201
204
  bottom: PropTypes.number,
202
205
  left: PropTypes.number,
@@ -237,6 +240,16 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
237
240
  * Callback fired when a pie arc is clicked.
238
241
  */
239
242
  onItemClick: PropTypes.func,
243
+ /**
244
+ * The chart will try to wait for the parent container to resolve its size
245
+ * before it renders for the first time.
246
+ *
247
+ * This can be useful in some scenarios where the chart appear to grow after
248
+ * the first render, like when used inside a grid.
249
+ *
250
+ * @default false
251
+ */
252
+ resolveSizeBeforeRender: PropTypes.bool,
240
253
  /**
241
254
  * Indicate which axis to display the right of the charts.
242
255
  * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import * as React from 'react';
2
4
  import PropTypes from 'prop-types';
3
5
  import { DrawingContext } from "../context/DrawingProvider.js";
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import _extends from "@babel/runtime/helpers/esm/extends";
2
4
  import * as React from 'react';
3
5
  import { useHighlighted } from "../../context/index.js";
@@ -11,9 +11,11 @@ const legendGetter = params => {
11
11
  return;
12
12
  }
13
13
  acc.push({
14
+ id: item.id,
15
+ seriesId,
14
16
  color: item.color,
15
17
  label: formattedLabel,
16
- id: item.id
18
+ itemId: item.id
17
19
  });
18
20
  });
19
21
  return acc;
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import _extends from "@babel/runtime/helpers/esm/extends";
2
4
  import * as React from 'react';
3
5
  import PropTypes from 'prop-types';
@@ -72,6 +74,16 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
72
74
  * If not provided, the container supports line, bar, scatter and pie charts.
73
75
  */
74
76
  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,
75
87
  /**
76
88
  * The array of series to display.
77
89
  * Each type of series has its own specificity.
@@ -1,8 +1,14 @@
1
+ 'use client';
2
+
1
3
  import * as React from 'react';
2
4
  import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
3
5
  import ownerWindow from '@mui/utils/ownerWindow';
4
- export const useChartContainerDimensions = (inWidth, inHeight) => {
5
- const displayError = React.useRef(false);
6
+ export const useChartContainerDimensions = (inWidth, inHeight, resolveSizeBeforeRender) => {
7
+ const stateRef = React.useRef({
8
+ displayError: false,
9
+ initialCompute: true,
10
+ computeRun: 0
11
+ });
6
12
  const rootRef = React.useRef(null);
7
13
  const [width, setWidth] = React.useState(0);
8
14
  const [height, setHeight] = React.useState(0);
@@ -11,7 +17,7 @@ export const useChartContainerDimensions = (inWidth, inHeight) => {
11
17
  const computeSize = React.useCallback(() => {
12
18
  const mainEl = rootRef?.current;
13
19
  if (!mainEl) {
14
- return;
20
+ return {};
15
21
  }
16
22
  const win = ownerWindow(mainEl);
17
23
  const computedStyle = win.getComputedStyle(mainEl);
@@ -19,11 +25,31 @@ export const useChartContainerDimensions = (inWidth, inHeight) => {
19
25
  const newWidth = Math.floor(parseFloat(computedStyle.width)) || 0;
20
26
  setWidth(newWidth);
21
27
  setHeight(newHeight);
28
+ return {
29
+ width: newWidth,
30
+ height: newHeight
31
+ };
22
32
  }, []);
23
33
  React.useEffect(() => {
24
34
  // Ensure the error detection occurs after the first rendering.
25
- displayError.current = true;
35
+ stateRef.current.displayError = true;
26
36
  }, []);
37
+
38
+ // This effect is used to compute the size of the container on the initial render.
39
+ // It is not bound to the raf loop to avoid an unwanted "resize" event.
40
+ // https://github.com/mui/mui-x/issues/13477#issuecomment-2336634785
41
+ useEnhancedEffect(() => {
42
+ // computeRun is used to avoid infinite loops.
43
+ if (!resolveSizeBeforeRender || !stateRef.current.initialCompute || stateRef.current.computeRun > 20) {
44
+ return;
45
+ }
46
+ const computedSize = computeSize();
47
+ if (computedSize.width !== width || computedSize.height !== height) {
48
+ stateRef.current.computeRun += 1;
49
+ } else if (stateRef.current.initialCompute) {
50
+ stateRef.current.initialCompute = false;
51
+ }
52
+ }, [width, height, computeSize, resolveSizeBeforeRender]);
27
53
  useEnhancedEffect(() => {
28
54
  if (inWidth !== undefined && inHeight !== undefined) {
29
55
  return () => {};
@@ -45,7 +71,7 @@ export const useChartContainerDimensions = (inWidth, inHeight) => {
45
71
  }
46
72
  return () => {
47
73
  if (animationFrame) {
48
- window.cancelAnimationFrame(animationFrame);
74
+ cancelAnimationFrame(animationFrame);
49
75
  }
50
76
  if (elementToObserve) {
51
77
  observer.unobserve(elementToObserve);
@@ -53,13 +79,13 @@ export const useChartContainerDimensions = (inWidth, inHeight) => {
53
79
  };
54
80
  }, [computeSize, inHeight, inWidth]);
55
81
  if (process.env.NODE_ENV !== 'production') {
56
- if (displayError.current && inWidth === undefined && width === 0) {
82
+ if (stateRef.current.displayError && inWidth === undefined && width === 0) {
57
83
  console.error(`MUI X: ChartContainer does not have \`width\` prop, and its container has no \`width\` defined.`);
58
- displayError.current = false;
84
+ stateRef.current.displayError = false;
59
85
  }
60
- if (displayError.current && inHeight === undefined && height === 0) {
86
+ if (stateRef.current.displayError && inHeight === undefined && height === 0) {
61
87
  console.error(`MUI X: ChartContainer does not have \`height\` prop, and its container has no \`height\` defined.`);
62
- displayError.current = false;
88
+ stateRef.current.displayError = false;
63
89
  }
64
90
  }
65
91
  return {
@@ -1,11 +1,14 @@
1
+ 'use client';
2
+
1
3
  import _extends from "@babel/runtime/helpers/esm/extends";
2
4
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["width", "height", "margin", "children", "series", "colors", "dataset", "desc", "disableAxisListener", "highlightedItem", "onHighlightChange", "plugins", "sx", "title", "viewBox", "xAxis", "yAxis", "zAxis"];
5
+ const _excluded = ["width", "height", "resolveSizeBeforeRender", "margin", "children", "series", "colors", "dataset", "desc", "disableAxisListener", "highlightedItem", "onHighlightChange", "plugins", "sx", "title", "viewBox", "xAxis", "yAxis", "zAxis"];
4
6
  import { useChartContainerDimensions } from "./useChartContainerDimensions.js";
5
7
  export const useResponsiveChartContainerProps = (props, ref) => {
6
8
  const {
7
9
  width,
8
10
  height,
11
+ resolveSizeBeforeRender,
9
12
  margin,
10
13
  children,
11
14
  series,
@@ -28,7 +31,7 @@ export const useResponsiveChartContainerProps = (props, ref) => {
28
31
  containerRef,
29
32
  width: dWidth,
30
33
  height: dHeight
31
- } = useChartContainerDimensions(width, height);
34
+ } = useChartContainerDimensions(width, height, resolveSizeBeforeRender);
32
35
  const resizableChartContainerProps = _extends({}, other, {
33
36
  ownerState: {
34
37
  width,
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import _extends from "@babel/runtime/helpers/esm/extends";
2
4
  import * as React from 'react';
3
5
  import PropTypes from 'prop-types';
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import _extends from "@babel/runtime/helpers/esm/extends";
2
4
  import * as React from 'react';
3
5
  import PropTypes from 'prop-types';
@@ -132,6 +134,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
132
134
  itemMarkWidth: PropTypes.number,
133
135
  labelStyle: PropTypes.object,
134
136
  markGap: PropTypes.number,
137
+ onItemClick: PropTypes.func,
135
138
  padding: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
136
139
  bottom: PropTypes.number,
137
140
  left: PropTypes.number,
@@ -174,6 +177,16 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
174
177
  * @param {ScatterItemIdentifier} scatterItemIdentifier The scatter item identifier.
175
178
  */
176
179
  onItemClick: PropTypes.func,
180
+ /**
181
+ * The chart will try to wait for the parent container to resolve its size
182
+ * before it renders for the first time.
183
+ *
184
+ * This can be useful in some scenarios where the chart appear to grow after
185
+ * the first render, like when used inside a grid.
186
+ *
187
+ * @default false
188
+ */
189
+ resolveSizeBeforeRender: PropTypes.bool,
177
190
  /**
178
191
  * Indicate which axis to display the right of the charts.
179
192
  * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import _extends from "@babel/runtime/helpers/esm/extends";
2
4
  import * as React from 'react';
3
5
  import PropTypes from 'prop-types';
@@ -10,9 +10,10 @@ const legendGetter = params => {
10
10
  return acc;
11
11
  }
12
12
  acc.push({
13
+ id: seriesId,
14
+ seriesId,
13
15
  color: series[seriesId].color,
14
- label: formattedLabel,
15
- id: seriesId
16
+ label: formattedLabel
16
17
  });
17
18
  return acc;
18
19
  }, []);
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import _extends from "@babel/runtime/helpers/esm/extends";
2
4
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
5
  const _excluded = ["xAxis", "yAxis", "zAxis", "series", "tooltip", "axisHighlight", "voronoiMaxRadius", "disableVoronoi", "legend", "width", "height", "margin", "colors", "sx", "grid", "topAxis", "leftAxis", "rightAxis", "bottomAxis", "onItemClick", "children", "slots", "slotProps", "loading", "highlightedItem", "onHighlightChange", "className"];
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import _extends from "@babel/runtime/helpers/esm/extends";
2
4
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
5
  const _excluded = ["xAxis", "yAxis", "width", "height", "margin", "colors", "sx", "showTooltip", "tooltip", "showHighlight", "axisHighlight", "children", "slots", "slotProps", "data", "plotType", "valueFormatter", "area", "curve", "className"];
@@ -191,6 +193,16 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
191
193
  * @default 'line'
192
194
  */
193
195
  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,
194
206
  /**
195
207
  * Set to `true` to highlight the value.
196
208
  * With line, it shows a point.