@mui/x-charts 7.10.0 → 7.11.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 (299) hide show
  1. package/BarChart/BarChart.js +2 -2
  2. package/BarChart/BarElement.d.ts +2 -1
  3. package/BarChart/BarLabel/BarLabelItem.d.ts +2 -1
  4. package/BarChart/BarPlot.js +8 -8
  5. package/BarChart/checkScaleErrors.d.ts +4 -4
  6. package/BarChart/checkScaleErrors.js +11 -11
  7. package/BarChart/extremums.js +4 -1
  8. package/BarChart/formatter.js +2 -2
  9. package/BarChart/useBarChartProps.js +38 -33
  10. package/CHANGELOG.md +169 -0
  11. package/ChartContainer/ChartContainer.d.ts +28 -2
  12. package/ChartContainer/ChartContainer.js +25 -66
  13. package/ChartContainer/useChartContainerHooks.d.ts +1 -1
  14. package/ChartContainer/useChartContainerHooks.js +2 -2
  15. package/ChartContainer/useChartContainerProps.d.ts +86 -0
  16. package/ChartContainer/useChartContainerProps.js +95 -0
  17. package/ChartContainer/useDefaultizeAxis.d.ts +36 -0
  18. package/ChartContainer/useDefaultizeAxis.js +29 -0
  19. package/ChartsAxis/ChartsAxis.js +4 -4
  20. package/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
  21. package/ChartsLegend/ChartsLegend.d.ts +3 -12
  22. package/ChartsLegend/ContinuousColorLegend.d.ts +65 -0
  23. package/ChartsLegend/ContinuousColorLegend.js +398 -0
  24. package/ChartsLegend/DefaultChartsLegend.d.ts +7 -50
  25. package/ChartsLegend/DefaultChartsLegend.js +13 -198
  26. package/ChartsLegend/LegendPerItem.d.ts +61 -0
  27. package/ChartsLegend/LegendPerItem.js +151 -0
  28. package/ChartsLegend/PiecewiseColorLegend.d.ts +26 -0
  29. package/ChartsLegend/PiecewiseColorLegend.js +169 -0
  30. package/ChartsLegend/chartsLegend.types.d.ts +31 -0
  31. package/ChartsLegend/chartsLegend.types.js +5 -0
  32. package/ChartsLegend/index.d.ts +2 -0
  33. package/ChartsLegend/index.js +22 -0
  34. package/ChartsLegend/legend.types.d.ts +62 -0
  35. package/ChartsLegend/legend.types.js +5 -0
  36. package/ChartsLegend/legendItemsPlacement.d.ts +3 -0
  37. package/ChartsLegend/legendItemsPlacement.js +79 -0
  38. package/ChartsLegend/useAxis.d.ts +7 -0
  39. package/ChartsLegend/useAxis.js +47 -0
  40. package/ChartsLegend/utils.d.ts +1 -8
  41. package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +3 -1
  42. package/ChartsOverlay/ChartsOverlay.d.ts +3 -2
  43. package/ChartsReferenceLine/ChartsReferenceLine.d.ts +1 -1
  44. package/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  45. package/ChartsReferenceLine/ChartsXReferenceLine.js +1 -2
  46. package/ChartsReferenceLine/ChartsYReferenceLine.js +1 -2
  47. package/ChartsSurface.js +3 -1
  48. package/ChartsTooltip/ChartsAxisTooltipContent.js +7 -3
  49. package/ChartsTooltip/ChartsItemTooltipContent.js +4 -4
  50. package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +30 -20
  51. package/ChartsXAxis/ChartsXAxis.js +1 -1
  52. package/ChartsYAxis/ChartsYAxis.js +15 -3
  53. package/Gauge/Gauge.d.ts +1 -4
  54. package/Gauge/Gauge.js +9 -6
  55. package/Gauge/GaugeContainer.js +8 -4
  56. package/Gauge/GaugeProvider.js +9 -9
  57. package/LineChart/AnimatedArea.js +2 -2
  58. package/LineChart/AnimatedLine.js +2 -2
  59. package/LineChart/AreaElement.d.ts +2 -1
  60. package/LineChart/AreaPlot.js +10 -6
  61. package/LineChart/LineChart.js +5 -2
  62. package/LineChart/LineElement.d.ts +2 -1
  63. package/LineChart/LineHighlightPlot.d.ts +2 -1
  64. package/LineChart/LineHighlightPlot.js +17 -5
  65. package/LineChart/LinePlot.js +10 -6
  66. package/LineChart/MarkElement.js +2 -2
  67. package/LineChart/MarkPlot.js +13 -25
  68. package/LineChart/extremums.js +4 -1
  69. package/LineChart/formatter.js +2 -2
  70. package/LineChart/useLineChartProps.js +38 -33
  71. package/PieChart/PieArc.js +1 -0
  72. package/PieChart/PieChart.d.ts +1 -4
  73. package/PieChart/PieChart.js +40 -34
  74. package/PieChart/PiePlot.js +6 -6
  75. package/PieChart/getPieCoordinates.js +3 -3
  76. package/ResponsiveChartContainer/ResponsiveChartContainer.js +8 -20
  77. package/ResponsiveChartContainer/useChartContainerDimensions.d.ts +5 -1
  78. package/ResponsiveChartContainer/useChartContainerDimensions.js +8 -4
  79. package/ResponsiveChartContainer/useResponsiveChartContainerProps.d.ts +20 -0
  80. package/ResponsiveChartContainer/useResponsiveChartContainerProps.js +73 -0
  81. package/ScatterChart/Scatter.js +6 -9
  82. package/ScatterChart/ScatterChart.js +4 -1
  83. package/ScatterChart/ScatterPlot.js +6 -3
  84. package/ScatterChart/extremums.js +8 -2
  85. package/ScatterChart/useScatterChartProps.js +35 -30
  86. package/SparkLineChart/SparkLineChart.js +27 -22
  87. package/context/CartesianProvider/CartesianContext.d.ts +1 -1
  88. package/context/CartesianProvider/CartesianProvider.d.ts +2 -3
  89. package/context/CartesianProvider/CartesianProvider.js +18 -7
  90. package/context/CartesianProvider/computeValue.d.ts +32 -9
  91. package/context/CartesianProvider/computeValue.js +20 -16
  92. package/context/CartesianProvider/defaultizeAxis.d.ts +36 -0
  93. package/context/CartesianProvider/defaultizeAxis.js +21 -0
  94. package/context/CartesianProvider/index.d.ts +0 -1
  95. package/context/CartesianProvider/index.js +1 -3
  96. package/context/CartesianProvider/normalizeAxis.d.ts +1 -1
  97. package/context/CartesianProvider/normalizeAxis.js +2 -2
  98. package/context/DrawingProvider.d.ts +12 -0
  99. package/context/DrawingProvider.js +15 -2
  100. package/context/HighlightedProvider/HighlightedProvider.js +2 -2
  101. package/context/SeriesContextProvider.js +1 -1
  102. package/context/ZAxisContextProvider.d.ts +1 -1
  103. package/context/ZAxisContextProvider.js +1 -1
  104. package/esm/BarChart/BarChart.js +2 -2
  105. package/esm/BarChart/BarPlot.js +8 -8
  106. package/esm/BarChart/checkScaleErrors.js +11 -11
  107. package/esm/BarChart/extremums.js +4 -1
  108. package/esm/BarChart/formatter.js +2 -2
  109. package/esm/BarChart/useBarChartProps.js +38 -33
  110. package/esm/ChartContainer/ChartContainer.js +25 -66
  111. package/esm/ChartContainer/useChartContainerHooks.js +2 -2
  112. package/esm/ChartContainer/useChartContainerProps.js +87 -0
  113. package/esm/ChartContainer/useDefaultizeAxis.js +19 -0
  114. package/esm/ChartsAxis/ChartsAxis.js +4 -4
  115. package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
  116. package/esm/ChartsLegend/ContinuousColorLegend.js +390 -0
  117. package/esm/ChartsLegend/DefaultChartsLegend.js +14 -198
  118. package/esm/ChartsLegend/LegendPerItem.js +141 -0
  119. package/esm/ChartsLegend/PiecewiseColorLegend.js +161 -0
  120. package/esm/ChartsLegend/chartsLegend.types.js +1 -0
  121. package/esm/ChartsLegend/index.js +2 -0
  122. package/esm/ChartsLegend/legend.types.js +1 -0
  123. package/esm/ChartsLegend/legendItemsPlacement.js +72 -0
  124. package/esm/ChartsLegend/useAxis.js +39 -0
  125. package/esm/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +3 -1
  126. package/esm/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  127. package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +2 -3
  128. package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +2 -3
  129. package/esm/ChartsSurface.js +3 -1
  130. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +7 -3
  131. package/esm/ChartsTooltip/ChartsItemTooltipContent.js +4 -4
  132. package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +30 -20
  133. package/esm/ChartsXAxis/ChartsXAxis.js +1 -1
  134. package/esm/ChartsYAxis/ChartsYAxis.js +15 -3
  135. package/esm/Gauge/Gauge.js +8 -5
  136. package/esm/Gauge/GaugeContainer.js +8 -4
  137. package/esm/Gauge/GaugeProvider.js +1 -1
  138. package/esm/LineChart/AnimatedArea.js +1 -1
  139. package/esm/LineChart/AnimatedLine.js +1 -1
  140. package/esm/LineChart/AreaPlot.js +10 -6
  141. package/esm/LineChart/LineChart.js +5 -2
  142. package/esm/LineChart/LineHighlightPlot.js +17 -5
  143. package/esm/LineChart/LinePlot.js +10 -6
  144. package/esm/LineChart/MarkElement.js +1 -1
  145. package/esm/LineChart/MarkPlot.js +12 -24
  146. package/esm/LineChart/extremums.js +4 -1
  147. package/esm/LineChart/formatter.js +2 -2
  148. package/esm/LineChart/useLineChartProps.js +38 -33
  149. package/esm/PieChart/PieArc.js +1 -0
  150. package/esm/PieChart/PieChart.js +39 -33
  151. package/esm/PieChart/PiePlot.js +1 -1
  152. package/esm/PieChart/getPieCoordinates.js +1 -1
  153. package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +8 -20
  154. package/esm/ResponsiveChartContainer/useChartContainerDimensions.js +8 -4
  155. package/esm/ResponsiveChartContainer/useResponsiveChartContainerProps.js +65 -0
  156. package/esm/ScatterChart/Scatter.js +6 -9
  157. package/esm/ScatterChart/ScatterChart.js +4 -1
  158. package/esm/ScatterChart/ScatterPlot.js +6 -3
  159. package/esm/ScatterChart/extremums.js +8 -2
  160. package/esm/ScatterChart/useScatterChartProps.js +35 -30
  161. package/esm/SparkLineChart/SparkLineChart.js +27 -22
  162. package/esm/context/CartesianProvider/CartesianProvider.js +18 -7
  163. package/esm/context/CartesianProvider/computeValue.js +20 -16
  164. package/esm/context/CartesianProvider/defaultizeAxis.js +13 -0
  165. package/esm/context/CartesianProvider/index.js +1 -3
  166. package/esm/context/CartesianProvider/normalizeAxis.js +2 -2
  167. package/esm/context/DrawingProvider.js +15 -2
  168. package/esm/context/HighlightedProvider/HighlightedProvider.js +2 -2
  169. package/esm/context/SeriesContextProvider.js +1 -1
  170. package/esm/context/ZAxisContextProvider.js +1 -1
  171. package/esm/hooks/useAxisEvents.js +14 -17
  172. package/esm/hooks/useDrawingArea.js +5 -3
  173. package/esm/hooks/useReducedMotion.js +4 -2
  174. package/esm/internals/SlotComponentPropsFromProps.js +1 -0
  175. package/esm/internals/cleanId.js +6 -0
  176. package/esm/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +3 -2
  177. package/esm/internals/geometry.js +1 -1
  178. package/esm/internals/{utils.js → getPercentageValue.js} +1 -13
  179. package/esm/internals/getSymbol.js +5 -0
  180. package/esm/internals/index.js +3 -1
  181. package/esm/internals/isDefined.js +3 -0
  182. package/esm/internals/notNull.js +3 -0
  183. package/esm/internals/ts-generic.js +1 -0
  184. package/esm/internals/warning.js +19 -11
  185. package/hooks/useAxisEvents.js +14 -17
  186. package/hooks/useDrawingArea.js +5 -3
  187. package/hooks/useReducedMotion.js +4 -2
  188. package/index.js +1 -1
  189. package/internals/SlotComponentPropsFromProps.d.ts +1 -0
  190. package/internals/SlotComponentPropsFromProps.js +5 -0
  191. package/internals/cleanId.d.ts +4 -0
  192. package/internals/cleanId.js +12 -0
  193. package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.d.ts +6 -0
  194. package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +3 -2
  195. package/internals/defaultizeColor.d.ts +7 -0
  196. package/internals/geometry.js +1 -1
  197. package/internals/getPercentageValue.d.ts +7 -0
  198. package/internals/{utils.js → getPercentageValue.js} +1 -15
  199. package/internals/getSymbol.d.ts +2 -0
  200. package/internals/getSymbol.js +11 -0
  201. package/internals/index.d.ts +3 -1
  202. package/internals/index.js +25 -5
  203. package/internals/isDefined.d.ts +1 -0
  204. package/internals/isDefined.js +9 -0
  205. package/internals/notNull.d.ts +1 -0
  206. package/internals/notNull.js +9 -0
  207. package/internals/ts-generic.d.ts +5 -0
  208. package/internals/ts-generic.js +5 -0
  209. package/internals/warning.d.ts +2 -1
  210. package/internals/warning.js +21 -12
  211. package/models/axis.d.ts +5 -2
  212. package/models/helpers.d.ts +1 -0
  213. package/models/seriesType/common.d.ts +10 -0
  214. package/models/seriesType/config.d.ts +2 -16
  215. package/models/seriesType/scatter.d.ts +5 -0
  216. package/modern/BarChart/BarChart.js +2 -2
  217. package/modern/BarChart/BarPlot.js +8 -8
  218. package/modern/BarChart/checkScaleErrors.js +11 -11
  219. package/modern/BarChart/extremums.js +4 -1
  220. package/modern/BarChart/formatter.js +2 -2
  221. package/modern/BarChart/useBarChartProps.js +38 -33
  222. package/modern/ChartContainer/ChartContainer.js +25 -66
  223. package/modern/ChartContainer/useChartContainerHooks.js +2 -2
  224. package/modern/ChartContainer/useChartContainerProps.js +87 -0
  225. package/modern/ChartContainer/useDefaultizeAxis.js +19 -0
  226. package/modern/ChartsAxis/ChartsAxis.js +4 -4
  227. package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
  228. package/modern/ChartsLegend/ContinuousColorLegend.js +390 -0
  229. package/modern/ChartsLegend/DefaultChartsLegend.js +14 -198
  230. package/modern/ChartsLegend/LegendPerItem.js +141 -0
  231. package/modern/ChartsLegend/PiecewiseColorLegend.js +161 -0
  232. package/modern/ChartsLegend/chartsLegend.types.js +1 -0
  233. package/modern/ChartsLegend/index.js +2 -0
  234. package/modern/ChartsLegend/legend.types.js +1 -0
  235. package/modern/ChartsLegend/legendItemsPlacement.js +72 -0
  236. package/modern/ChartsLegend/useAxis.js +39 -0
  237. package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +3 -1
  238. package/modern/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  239. package/modern/ChartsReferenceLine/ChartsXReferenceLine.js +2 -3
  240. package/modern/ChartsReferenceLine/ChartsYReferenceLine.js +2 -3
  241. package/modern/ChartsSurface.js +3 -1
  242. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +7 -3
  243. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +4 -4
  244. package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +30 -20
  245. package/modern/ChartsXAxis/ChartsXAxis.js +1 -1
  246. package/modern/ChartsYAxis/ChartsYAxis.js +15 -3
  247. package/modern/Gauge/Gauge.js +8 -5
  248. package/modern/Gauge/GaugeContainer.js +8 -4
  249. package/modern/Gauge/GaugeProvider.js +1 -1
  250. package/modern/LineChart/AnimatedArea.js +1 -1
  251. package/modern/LineChart/AnimatedLine.js +1 -1
  252. package/modern/LineChart/AreaPlot.js +10 -6
  253. package/modern/LineChart/LineChart.js +5 -2
  254. package/modern/LineChart/LineHighlightPlot.js +17 -5
  255. package/modern/LineChart/LinePlot.js +10 -6
  256. package/modern/LineChart/MarkElement.js +1 -1
  257. package/modern/LineChart/MarkPlot.js +12 -24
  258. package/modern/LineChart/extremums.js +4 -1
  259. package/modern/LineChart/formatter.js +2 -2
  260. package/modern/LineChart/useLineChartProps.js +38 -33
  261. package/modern/PieChart/PieArc.js +1 -0
  262. package/modern/PieChart/PieChart.js +39 -33
  263. package/modern/PieChart/PiePlot.js +1 -1
  264. package/modern/PieChart/getPieCoordinates.js +1 -1
  265. package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +8 -20
  266. package/modern/ResponsiveChartContainer/useChartContainerDimensions.js +8 -4
  267. package/modern/ResponsiveChartContainer/useResponsiveChartContainerProps.js +65 -0
  268. package/modern/ScatterChart/Scatter.js +6 -9
  269. package/modern/ScatterChart/ScatterChart.js +4 -1
  270. package/modern/ScatterChart/ScatterPlot.js +6 -3
  271. package/modern/ScatterChart/extremums.js +8 -2
  272. package/modern/ScatterChart/useScatterChartProps.js +35 -30
  273. package/modern/SparkLineChart/SparkLineChart.js +27 -22
  274. package/modern/context/CartesianProvider/CartesianProvider.js +18 -7
  275. package/modern/context/CartesianProvider/computeValue.js +20 -16
  276. package/modern/context/CartesianProvider/defaultizeAxis.js +13 -0
  277. package/modern/context/CartesianProvider/index.js +1 -3
  278. package/modern/context/CartesianProvider/normalizeAxis.js +2 -2
  279. package/modern/context/DrawingProvider.js +15 -2
  280. package/modern/context/HighlightedProvider/HighlightedProvider.js +2 -2
  281. package/modern/context/SeriesContextProvider.js +1 -1
  282. package/modern/context/ZAxisContextProvider.js +1 -1
  283. package/modern/hooks/useAxisEvents.js +14 -17
  284. package/modern/hooks/useDrawingArea.js +5 -3
  285. package/modern/hooks/useReducedMotion.js +4 -2
  286. package/modern/index.js +1 -1
  287. package/modern/internals/SlotComponentPropsFromProps.js +1 -0
  288. package/modern/internals/cleanId.js +6 -0
  289. package/modern/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +3 -2
  290. package/modern/internals/geometry.js +1 -1
  291. package/modern/internals/{utils.js → getPercentageValue.js} +1 -13
  292. package/modern/internals/getSymbol.js +5 -0
  293. package/modern/internals/index.js +3 -1
  294. package/modern/internals/isDefined.js +3 -0
  295. package/modern/internals/notNull.js +3 -0
  296. package/modern/internals/ts-generic.js +1 -0
  297. package/modern/internals/warning.js +19 -11
  298. package/package.json +4 -4
  299. package/internals/utils.d.ts +0 -18
@@ -1,4 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
+ 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"];
2
4
  import useId from '@mui/utils/useId';
3
5
  import { DEFAULT_X_AXIS_KEY } from '../constants';
4
6
  /**
@@ -10,39 +12,41 @@ import { DEFAULT_X_AXIS_KEY } from '../constants';
10
12
  */
11
13
  export const useLineChartProps = props => {
12
14
  const {
13
- xAxis,
14
- yAxis,
15
- series,
16
- width,
17
- height,
18
- margin,
19
- colors,
20
- dataset,
21
- sx,
22
- tooltip,
23
- onAxisClick,
24
- onAreaClick,
25
- onLineClick,
26
- onMarkClick,
27
- axisHighlight,
28
- disableLineItemHighlight,
29
- legend,
30
- grid,
31
- topAxis,
32
- leftAxis,
33
- rightAxis,
34
- bottomAxis,
35
- children,
36
- slots,
37
- slotProps,
38
- skipAnimation,
39
- loading,
40
- highlightedItem,
41
- onHighlightChange
42
- } = props;
15
+ xAxis,
16
+ yAxis,
17
+ series,
18
+ width,
19
+ height,
20
+ margin,
21
+ colors,
22
+ dataset,
23
+ sx,
24
+ tooltip,
25
+ onAxisClick,
26
+ onAreaClick,
27
+ onLineClick,
28
+ onMarkClick,
29
+ axisHighlight,
30
+ disableLineItemHighlight,
31
+ legend,
32
+ grid,
33
+ topAxis,
34
+ leftAxis,
35
+ rightAxis,
36
+ bottomAxis,
37
+ children,
38
+ slots,
39
+ slotProps,
40
+ skipAnimation,
41
+ loading,
42
+ highlightedItem,
43
+ onHighlightChange,
44
+ className
45
+ } = props,
46
+ other = _objectWithoutPropertiesLoose(props, _excluded);
43
47
  const id = useId();
44
48
  const clipPathId = `${id}-clip-path`;
45
- const chartContainerProps = {
49
+ const chartContainerProps = _extends({}, other, {
46
50
  series: series.map(s => _extends({
47
51
  disableHighlight: !!disableLineItemHighlight,
48
52
  type: 'line'
@@ -63,8 +67,9 @@ export const useLineChartProps = props => {
63
67
  sx,
64
68
  highlightedItem,
65
69
  onHighlightChange,
66
- disableAxisListener: tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none' && !onAxisClick
67
- };
70
+ disableAxisListener: tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none' && !onAxisClick,
71
+ className
72
+ });
68
73
  const axisClickHandlerProps = {
69
74
  onAxisClick
70
75
  };
@@ -73,6 +73,7 @@ function PieArc(props) {
73
73
  innerRadius: iR,
74
74
  outerRadius: oR
75
75
  })),
76
+ visibility: to([startAngle, endAngle], (sA, eA) => sA === eA ? 'hidden' : 'visible'),
76
77
  onClick: onClick,
77
78
  cursor: onClick ? 'pointer' : 'unset',
78
79
  ownerState: ownerState,
@@ -1,4 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ 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"];
2
4
  import * as React from 'react';
3
5
  import PropTypes from 'prop-types';
4
6
  import { ResponsiveChartContainer } from '../ResponsiveChartContainer';
@@ -34,37 +36,39 @@ const defaultRTLMargin = {
34
36
  *
35
37
  * - [PieChart API](https://mui.com/x/api/charts/pie-chart/)
36
38
  */
37
- function PieChart(props) {
39
+ const PieChart = /*#__PURE__*/React.forwardRef(function PieChart(props, ref) {
38
40
  const {
39
- xAxis,
40
- yAxis,
41
- series,
42
- width,
43
- height,
44
- margin: marginProps,
45
- colors,
46
- sx,
47
- tooltip = {
48
- trigger: 'item'
49
- },
50
- axisHighlight = {
51
- x: 'none',
52
- y: 'none'
53
- },
54
- skipAnimation,
55
- legend: legendProps,
56
- topAxis = null,
57
- leftAxis = null,
58
- rightAxis = null,
59
- bottomAxis = null,
60
- children,
61
- slots,
62
- slotProps,
63
- onItemClick,
64
- loading,
65
- highlightedItem,
66
- onHighlightChange
67
- } = props;
41
+ xAxis,
42
+ yAxis,
43
+ series,
44
+ width,
45
+ height,
46
+ margin: marginProps,
47
+ colors,
48
+ sx,
49
+ tooltip = {
50
+ trigger: 'item'
51
+ },
52
+ axisHighlight = {
53
+ x: 'none',
54
+ y: 'none'
55
+ },
56
+ skipAnimation,
57
+ legend: legendProps,
58
+ topAxis = null,
59
+ leftAxis = null,
60
+ rightAxis = null,
61
+ bottomAxis = null,
62
+ children,
63
+ slots,
64
+ slotProps,
65
+ onItemClick,
66
+ loading,
67
+ highlightedItem,
68
+ onHighlightChange,
69
+ className
70
+ } = props,
71
+ other = _objectWithoutPropertiesLoose(props, _excluded);
68
72
  const isRTL = useIsRTL();
69
73
  const margin = _extends({}, isRTL ? defaultRTLMargin : defaultMargin, marginProps);
70
74
  const legend = _extends({
@@ -74,7 +78,8 @@ function PieChart(props) {
74
78
  horizontal: isRTL ? 'left' : 'right'
75
79
  }
76
80
  }, legendProps);
77
- return /*#__PURE__*/_jsxs(ResponsiveChartContainer, {
81
+ return /*#__PURE__*/_jsxs(ResponsiveChartContainer, _extends({}, other, {
82
+ ref: ref,
78
83
  series: series.map(s => _extends({
79
84
  type: 'pie'
80
85
  }, s)),
@@ -92,6 +97,7 @@ function PieChart(props) {
92
97
  disableAxisListener: tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none',
93
98
  highlightedItem: highlightedItem,
94
99
  onHighlightChange: onHighlightChange,
100
+ className: className,
95
101
  children: [/*#__PURE__*/_jsx(ChartsAxis, {
96
102
  topAxis: topAxis,
97
103
  leftAxis: leftAxis,
@@ -115,8 +121,8 @@ function PieChart(props) {
115
121
  slots: slots,
116
122
  slotProps: slotProps
117
123
  })), children]
118
- });
119
- }
124
+ }));
125
+ });
120
126
  process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
121
127
  // ----------------------------- Warning --------------------------------
122
128
  // | These PropTypes are generated from the TypeScript type definitions |
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
3
3
  import { DrawingContext } from '../context/DrawingProvider';
4
4
  import { PieArcPlot } from './PieArcPlot';
5
5
  import { PieArcLabelPlot } from './PieArcLabelPlot';
6
- import { getPercentageValue } from '../internals/utils';
6
+ import { getPercentageValue } from '../internals/getPercentageValue';
7
7
  import { getPieCoordinates } from './getPieCoordinates';
8
8
  import { usePieSeries } from '../hooks/useSeries';
9
9
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
@@ -1,4 +1,4 @@
1
- import { getPercentageValue } from '../internals/utils';
1
+ import { getPercentageValue } from '../internals/getPercentageValue';
2
2
  export function getPieCoordinates(series, drawing) {
3
3
  const {
4
4
  height,
@@ -1,31 +1,19 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["width", "height"];
4
2
  import * as React from 'react';
5
3
  import PropTypes from 'prop-types';
6
4
  import { ChartContainer } from '../ChartContainer';
7
- import { useChartContainerDimensions } from './useChartContainerDimensions';
8
5
  import { ResizableContainer } from './ResizableContainer';
6
+ import { useResponsiveChartContainerProps } from './useResponsiveChartContainerProps';
9
7
  import { jsx as _jsx } from "react/jsx-runtime";
10
8
  const ResponsiveChartContainer = /*#__PURE__*/React.forwardRef(function ResponsiveChartContainer(props, ref) {
11
9
  const {
12
- width: inWidth,
13
- height: inHeight
14
- } = props,
15
- other = _objectWithoutPropertiesLoose(props, _excluded);
16
- const [containerRef, width, height] = useChartContainerDimensions(inWidth, inHeight);
17
- return /*#__PURE__*/_jsx(ResizableContainer, {
18
- ref: containerRef,
19
- ownerState: {
20
- width: inWidth,
21
- height: inHeight
22
- },
23
- children: width && height ? /*#__PURE__*/_jsx(ChartContainer, _extends({}, other, {
24
- width: width,
25
- height: height,
26
- ref: ref
27
- })) : null
28
- });
10
+ hasIntrinsicSize,
11
+ chartContainerProps,
12
+ resizableChartContainerProps
13
+ } = useResponsiveChartContainerProps(props, ref);
14
+ return /*#__PURE__*/_jsx(ResizableContainer, _extends({}, resizableChartContainerProps, {
15
+ children: hasIntrinsicSize ? /*#__PURE__*/_jsx(ChartContainer, _extends({}, chartContainerProps)) : null
16
+ }));
29
17
  });
30
18
  process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
31
19
  // ----------------------------- Warning --------------------------------
@@ -2,8 +2,8 @@ import * as React from 'react';
2
2
  import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
3
3
  import ownerWindow from '@mui/utils/ownerWindow';
4
4
  export const useChartContainerDimensions = (inWidth, inHeight) => {
5
- const rootRef = React.useRef(null);
6
5
  const displayError = React.useRef(false);
6
+ const rootRef = React.useRef(null);
7
7
  const [width, setWidth] = React.useState(0);
8
8
  const [height, setHeight] = React.useState(0);
9
9
 
@@ -54,13 +54,17 @@ export const useChartContainerDimensions = (inWidth, inHeight) => {
54
54
  }, [computeSize, inHeight, inWidth]);
55
55
  if (process.env.NODE_ENV !== 'production') {
56
56
  if (displayError.current && inWidth === undefined && width === 0) {
57
- console.error(`MUI X Charts: ChartContainer does not have \`width\` prop, and its container has no \`width\` defined.`);
57
+ console.error(`MUI X: ChartContainer does not have \`width\` prop, and its container has no \`width\` defined.`);
58
58
  displayError.current = false;
59
59
  }
60
60
  if (displayError.current && inHeight === undefined && height === 0) {
61
- console.error(`MUI X Charts: ChartContainer does not have \`height\` prop, and its container has no \`height\` defined.`);
61
+ console.error(`MUI X: ChartContainer does not have \`height\` prop, and its container has no \`height\` defined.`);
62
62
  displayError.current = false;
63
63
  }
64
64
  }
65
- return [rootRef, inWidth ?? width, inHeight ?? height];
65
+ return {
66
+ containerRef: rootRef,
67
+ width: inWidth ?? width,
68
+ height: inHeight ?? height
69
+ };
66
70
  };
@@ -0,0 +1,65 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ 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"];
4
+ import { useChartContainerDimensions } from './useChartContainerDimensions';
5
+ export const useResponsiveChartContainerProps = (props, ref) => {
6
+ const {
7
+ width,
8
+ height,
9
+ margin,
10
+ children,
11
+ series,
12
+ colors,
13
+ dataset,
14
+ desc,
15
+ disableAxisListener,
16
+ highlightedItem,
17
+ onHighlightChange,
18
+ plugins,
19
+ sx,
20
+ title,
21
+ viewBox,
22
+ xAxis,
23
+ yAxis,
24
+ zAxis
25
+ } = props,
26
+ other = _objectWithoutPropertiesLoose(props, _excluded);
27
+ const {
28
+ containerRef,
29
+ width: dWidth,
30
+ height: dHeight
31
+ } = useChartContainerDimensions(width, height);
32
+ const resizableChartContainerProps = _extends({}, other, {
33
+ ownerState: {
34
+ width,
35
+ height
36
+ },
37
+ ref: containerRef
38
+ });
39
+ const chartContainerProps = {
40
+ margin,
41
+ children,
42
+ series,
43
+ colors,
44
+ dataset,
45
+ desc,
46
+ disableAxisListener,
47
+ highlightedItem,
48
+ onHighlightChange,
49
+ plugins,
50
+ sx,
51
+ title,
52
+ viewBox,
53
+ xAxis,
54
+ yAxis,
55
+ zAxis,
56
+ width: dWidth,
57
+ height: dHeight,
58
+ ref
59
+ };
60
+ return {
61
+ hasIntrinsicSize: dWidth && dHeight,
62
+ chartContainerProps,
63
+ resizableChartContainerProps
64
+ };
65
+ };
@@ -27,10 +27,7 @@ function Scatter(props) {
27
27
  markerSize,
28
28
  onItemClick
29
29
  } = props;
30
- const {
31
- left,
32
- width
33
- } = useDrawingArea();
30
+ const drawingArea = useDrawingArea();
34
31
  const {
35
32
  useVoronoiInteraction
36
33
  } = React.useContext(InteractionContext);
@@ -43,15 +40,15 @@ function Scatter(props) {
43
40
  const cleanData = React.useMemo(() => {
44
41
  const getXPosition = getValueToPositionMapper(xScale);
45
42
  const getYPosition = getValueToPositionMapper(yScale);
46
- const yRange = yScale.range();
47
- const minYRange = Math.min(...yRange);
48
- const maxYRange = Math.max(...yRange);
49
43
  const temp = [];
50
44
  for (let i = 0; i < series.data.length; i += 1) {
51
45
  const scatterPoint = series.data[i];
52
46
  const x = getXPosition(scatterPoint.x);
53
47
  const y = getYPosition(scatterPoint.y);
54
- const isInRange = x >= left && x <= left + width && y >= minYRange && y <= maxYRange;
48
+ const isInRange = drawingArea.isPointInside({
49
+ x,
50
+ y
51
+ });
55
52
  const pointCtx = {
56
53
  type: 'scatter',
57
54
  seriesId: series.id,
@@ -76,7 +73,7 @@ function Scatter(props) {
76
73
  }
77
74
  }
78
75
  return temp;
79
- }, [xScale, yScale, left, width, series.data, series.id, isHighlighted, isFaded, getInteractionItemProps, colorGetter, color]);
76
+ }, [xScale, yScale, drawingArea, series.data, series.id, isHighlighted, isFaded, getInteractionItemProps, colorGetter, color]);
80
77
  return /*#__PURE__*/_jsx("g", {
81
78
  children: cleanData.map(dataPoint => /*#__PURE__*/_jsx("circle", _extends({
82
79
  cx: 0,
@@ -41,7 +41,10 @@ const ScatterChart = /*#__PURE__*/React.forwardRef(function ScatterChart(props,
41
41
  ref: ref
42
42
  }, chartContainerProps, {
43
43
  children: /*#__PURE__*/_jsxs(ZAxisContextProvider, _extends({}, zAxisProps, {
44
- children: [!props.disableVoronoi && /*#__PURE__*/_jsx(ChartsVoronoiHandler, _extends({}, voronoiHandlerProps)), /*#__PURE__*/_jsx(ChartsAxis, _extends({}, chartsAxisProps)), props.grid && /*#__PURE__*/_jsx(ChartsGrid, _extends({}, gridProps)), /*#__PURE__*/_jsx(ScatterPlot, _extends({}, scatterPlotProps)), /*#__PURE__*/_jsx(ChartsOverlay, _extends({}, overlayProps)), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legendProps)), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlightProps)), !props.loading && /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltipProps)), children]
44
+ children: [!props.disableVoronoi && /*#__PURE__*/_jsx(ChartsVoronoiHandler, _extends({}, voronoiHandlerProps)), /*#__PURE__*/_jsx(ChartsAxis, _extends({}, chartsAxisProps)), props.grid && /*#__PURE__*/_jsx(ChartsGrid, _extends({}, gridProps)), /*#__PURE__*/_jsx("g", {
45
+ "data-drawing-container": true,
46
+ children: /*#__PURE__*/_jsx(ScatterPlot, _extends({}, scatterPlotProps))
47
+ }), /*#__PURE__*/_jsx(ChartsOverlay, _extends({}, overlayProps)), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legendProps)), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlightProps)), !props.loading && /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltipProps)), children]
45
48
  }))
46
49
  }));
47
50
  });
@@ -53,12 +53,15 @@ function ScatterPlot(props) {
53
53
  xAxisKey,
54
54
  yAxisKey,
55
55
  zAxisKey,
56
+ xAxisId,
57
+ yAxisId,
58
+ zAxisId,
56
59
  markerSize,
57
60
  color
58
61
  } = series[seriesId];
59
- const colorGetter = getColor(series[seriesId], xAxis[xAxisKey ?? defaultXAxisId], yAxis[yAxisKey ?? defaultYAxisId], zAxis[zAxisKey ?? defaultZAxisId]);
60
- const xScale = xAxis[xAxisKey ?? defaultXAxisId].scale;
61
- const yScale = yAxis[yAxisKey ?? defaultYAxisId].scale;
62
+ const colorGetter = getColor(series[seriesId], xAxis[xAxisId ?? xAxisKey ?? defaultXAxisId], yAxis[yAxisId ?? yAxisKey ?? defaultYAxisId], zAxis[zAxisId ?? zAxisKey ?? defaultZAxisId]);
63
+ const xScale = xAxis[xAxisId ?? xAxisKey ?? defaultXAxisId].scale;
64
+ const yScale = yAxis[yAxisId ?? yAxisKey ?? defaultYAxisId].scale;
62
65
  return /*#__PURE__*/_jsx(ScatterItems, _extends({
63
66
  xScale: xScale,
64
67
  yScale: yScale,
@@ -13,7 +13,10 @@ export const getExtremumX = params => {
13
13
  axis,
14
14
  isDefaultAxis
15
15
  } = params;
16
- return Object.keys(series).filter(seriesId => series[seriesId].xAxisKey === axis.id || series[seriesId].xAxisKey === undefined && isDefaultAxis).reduce((acc, seriesId) => {
16
+ return Object.keys(series).filter(seriesId => {
17
+ const axisId = series[seriesId].xAxisId ?? series[seriesId].xAxisKey;
18
+ return axisId === axis.id || axisId === undefined && isDefaultAxis;
19
+ }).reduce((acc, seriesId) => {
17
20
  const seriesMinMax = series[seriesId].data.reduce((accSeries, {
18
21
  x
19
22
  }) => {
@@ -29,7 +32,10 @@ export const getExtremumY = params => {
29
32
  axis,
30
33
  isDefaultAxis
31
34
  } = params;
32
- return Object.keys(series).filter(seriesId => series[seriesId].yAxisKey === axis.id || series[seriesId].yAxisKey === undefined && isDefaultAxis).reduce((acc, seriesId) => {
35
+ return Object.keys(series).filter(seriesId => {
36
+ const axisId = series[seriesId].yAxisId ?? series[seriesId].yAxisKey;
37
+ return axisId === axis.id || axisId === undefined && isDefaultAxis;
38
+ }).reduce((acc, seriesId) => {
33
39
  const seriesMinMax = series[seriesId].data.reduce((accSeries, {
34
40
  y
35
41
  }) => {
@@ -1,4 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ 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"];
2
4
  /**
3
5
  * A helper function that extracts ScatterChartProps from the input props
4
6
  * and returns an object with props for the children components of ScatterChart.
@@ -8,34 +10,36 @@ import _extends from "@babel/runtime/helpers/esm/extends";
8
10
  */
9
11
  export const useScatterChartProps = props => {
10
12
  const {
11
- xAxis,
12
- yAxis,
13
- zAxis,
14
- series,
15
- tooltip,
16
- axisHighlight,
17
- voronoiMaxRadius,
18
- disableVoronoi,
19
- legend,
20
- width,
21
- height,
22
- margin,
23
- colors,
24
- sx,
25
- grid,
26
- topAxis,
27
- leftAxis,
28
- rightAxis,
29
- bottomAxis,
30
- onItemClick,
31
- children,
32
- slots,
33
- slotProps,
34
- loading,
35
- highlightedItem,
36
- onHighlightChange
37
- } = props;
38
- const chartContainerProps = {
13
+ xAxis,
14
+ yAxis,
15
+ zAxis,
16
+ series,
17
+ tooltip,
18
+ axisHighlight,
19
+ voronoiMaxRadius,
20
+ disableVoronoi,
21
+ legend,
22
+ width,
23
+ height,
24
+ margin,
25
+ colors,
26
+ sx,
27
+ grid,
28
+ topAxis,
29
+ leftAxis,
30
+ rightAxis,
31
+ bottomAxis,
32
+ onItemClick,
33
+ children,
34
+ slots,
35
+ slotProps,
36
+ loading,
37
+ highlightedItem,
38
+ onHighlightChange,
39
+ className
40
+ } = props,
41
+ other = _objectWithoutPropertiesLoose(props, _excluded);
42
+ const chartContainerProps = _extends({}, other, {
39
43
  series: series.map(s => _extends({
40
44
  type: 'scatter'
41
45
  }, s)),
@@ -47,8 +51,9 @@ export const useScatterChartProps = props => {
47
51
  yAxis,
48
52
  sx,
49
53
  highlightedItem,
50
- onHighlightChange
51
- };
54
+ onHighlightChange,
55
+ className
56
+ });
52
57
  const zAxisProps = {
53
58
  zAxis
54
59
  };
@@ -1,4 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["xAxis", "yAxis", "width", "height", "margin", "colors", "sx", "showTooltip", "tooltip", "showHighlight", "axisHighlight", "children", "slots", "slotProps", "data", "plotType", "valueFormatter", "area", "curve", "className"];
2
4
  import * as React from 'react';
3
5
  import PropTypes from 'prop-types';
4
6
  import { BarPlot } from '../BarChart';
@@ -26,33 +28,35 @@ const SPARKLINE_DEFAULT_MARGIN = {
26
28
  */
27
29
  const SparkLineChart = /*#__PURE__*/React.forwardRef(function SparkLineChart(props, ref) {
28
30
  const {
29
- xAxis,
30
- yAxis,
31
- width,
32
- height,
33
- margin = SPARKLINE_DEFAULT_MARGIN,
34
- colors,
35
- sx,
36
- showTooltip,
37
- tooltip,
38
- showHighlight,
39
- axisHighlight: inAxisHighlight,
40
- children,
41
- slots,
42
- slotProps,
43
- data,
44
- plotType = 'line',
45
- valueFormatter = value => value === null ? '' : value.toString(),
46
- area,
47
- curve = 'linear'
48
- } = props;
31
+ xAxis,
32
+ yAxis,
33
+ width,
34
+ height,
35
+ margin = SPARKLINE_DEFAULT_MARGIN,
36
+ colors,
37
+ sx,
38
+ showTooltip,
39
+ tooltip,
40
+ showHighlight,
41
+ axisHighlight: inAxisHighlight,
42
+ children,
43
+ slots,
44
+ slotProps,
45
+ data,
46
+ plotType = 'line',
47
+ valueFormatter = value => value === null ? '' : value.toString(),
48
+ area,
49
+ curve = 'linear',
50
+ className
51
+ } = props,
52
+ other = _objectWithoutPropertiesLoose(props, _excluded);
49
53
  const defaultXHighlight = showHighlight && plotType === 'bar' ? {
50
54
  x: 'band'
51
55
  } : {
52
56
  x: 'none'
53
57
  };
54
58
  const axisHighlight = _extends({}, defaultXHighlight, inAxisHighlight);
55
- return /*#__PURE__*/_jsxs(ResponsiveChartContainer, {
59
+ return /*#__PURE__*/_jsxs(ResponsiveChartContainer, _extends({}, other, {
56
60
  ref: ref,
57
61
  series: [_extends({
58
62
  type: plotType,
@@ -66,6 +70,7 @@ const SparkLineChart = /*#__PURE__*/React.forwardRef(function SparkLineChart(pro
66
70
  width: width,
67
71
  height: height,
68
72
  margin: margin,
73
+ className: className,
69
74
  xAxis: [_extends({
70
75
  id: DEFAULT_X_AXIS_KEY,
71
76
  scaleType: plotType === 'bar' ? 'band' : 'point',
@@ -104,7 +109,7 @@ const SparkLineChart = /*#__PURE__*/React.forwardRef(function SparkLineChart(pro
104
109
  slotProps: slotProps,
105
110
  slots: slots
106
111
  })), children]
107
- });
112
+ }));
108
113
  });
109
114
  process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
110
115
  // ----------------------------- Warning --------------------------------