@mui/x-charts 6.0.0-alpha.9 → 6.18.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 (325) hide show
  1. package/BarChart/BarChart.d.ts +26 -5
  2. package/BarChart/BarChart.js +93 -17
  3. package/BarChart/BarElement.d.ts +1319 -4
  4. package/BarChart/BarElement.js +10 -10
  5. package/BarChart/BarPlot.d.ts +17 -1
  6. package/BarChart/BarPlot.js +152 -66
  7. package/BarChart/formatter.js +2 -3
  8. package/BarChart/legend.js +1 -2
  9. package/CHANGELOG.md +797 -59
  10. package/ChartContainer/index.js +7 -5
  11. package/ChartsAxis/ChartsAxis.d.ts +9 -0
  12. package/ChartsAxis/ChartsAxis.js +33 -7
  13. package/ChartsAxis/axisClasses.d.ts +3 -3
  14. package/ChartsAxis/axisClasses.js +1 -2
  15. package/ChartsAxisHighlight/ChartsAxisHighlight.d.ts +21 -0
  16. package/ChartsAxisHighlight/ChartsAxisHighlight.js +61 -22
  17. package/ChartsClipPath/ChartsClipPath.d.ts +5 -0
  18. package/ChartsClipPath/ChartsClipPath.js +7 -2
  19. package/ChartsLegend/ChartsLegend.d.ts +45 -24
  20. package/ChartsLegend/ChartsLegend.js +193 -151
  21. package/ChartsLegend/chartsLegendClasses.d.ts +1 -1
  22. package/ChartsLegend/chartsLegendClasses.js +3 -4
  23. package/ChartsLegend/utils.d.ts +1 -6
  24. package/ChartsReferenceLine/ChartsReferenceLine.d.ts +10 -0
  25. package/ChartsReferenceLine/ChartsReferenceLine.js +78 -0
  26. package/ChartsReferenceLine/ChartsXReferenceLine.d.ts +13 -0
  27. package/ChartsReferenceLine/ChartsXReferenceLine.js +112 -0
  28. package/ChartsReferenceLine/ChartsYReferenceLine.d.ts +13 -0
  29. package/ChartsReferenceLine/ChartsYReferenceLine.js +112 -0
  30. package/ChartsReferenceLine/chartsReferenceLineClasses.d.ts +15 -0
  31. package/ChartsReferenceLine/chartsReferenceLineClasses.js +14 -0
  32. package/ChartsReferenceLine/common.d.ts +41 -0
  33. package/ChartsReferenceLine/common.js +27 -0
  34. package/ChartsReferenceLine/index.d.ts +2 -0
  35. package/ChartsReferenceLine/index.js +27 -0
  36. package/ChartsReferenceLine/package.json +6 -0
  37. package/ChartsSurface.d.ts +12 -1
  38. package/ChartsSurface.js +9 -18
  39. package/ChartsTooltip/ChartsAxisTooltipContent.d.ts +1 -0
  40. package/ChartsTooltip/ChartsAxisTooltipContent.js +46 -32
  41. package/ChartsTooltip/ChartsItemTooltipContent.d.ts +3 -2
  42. package/ChartsTooltip/ChartsItemTooltipContent.js +18 -9
  43. package/ChartsTooltip/ChartsTooltip.d.ts +32 -0
  44. package/ChartsTooltip/ChartsTooltip.js +62 -18
  45. package/ChartsTooltip/ChartsTooltipTable.d.ts +3 -10
  46. package/ChartsTooltip/ChartsTooltipTable.js +22 -20
  47. package/ChartsTooltip/tooltipClasses.js +1 -2
  48. package/ChartsTooltip/utils.js +2 -2
  49. package/ChartsXAxis/ChartsXAxis.d.ts +9 -0
  50. package/ChartsXAxis/ChartsXAxis.js +170 -45
  51. package/ChartsYAxis/ChartsYAxis.d.ts +9 -0
  52. package/ChartsYAxis/ChartsYAxis.js +95 -38
  53. package/LineChart/AreaElement.d.ts +11 -1
  54. package/LineChart/AreaElement.js +14 -6
  55. package/LineChart/AreaPlot.d.ts +11 -0
  56. package/LineChart/AreaPlot.js +27 -8
  57. package/LineChart/LineChart.d.ts +23 -3
  58. package/LineChart/LineChart.js +89 -17
  59. package/LineChart/LineElement.d.ts +11 -1
  60. package/LineChart/LineElement.js +14 -6
  61. package/LineChart/LineHighlightElement.d.ts +10 -0
  62. package/LineChart/LineHighlightElement.js +13 -4
  63. package/LineChart/LineHighlightPlot.d.ts +10 -0
  64. package/LineChart/LineHighlightPlot.js +15 -4
  65. package/LineChart/LinePlot.d.ts +10 -0
  66. package/LineChart/LinePlot.js +25 -12
  67. package/LineChart/MarkElement.d.ts +10 -0
  68. package/LineChart/MarkElement.js +14 -5
  69. package/LineChart/MarkPlot.d.ts +10 -0
  70. package/LineChart/MarkPlot.js +42 -10
  71. package/LineChart/formatter.js +5 -5
  72. package/LineChart/legend.js +1 -2
  73. package/PieChart/PieArc.d.ts +11 -13
  74. package/PieChart/PieArc.js +28 -60
  75. package/PieChart/PieArcLabel.d.ts +8 -9
  76. package/PieChart/PieArcLabel.js +46 -38
  77. package/PieChart/PieArcLabelPlot.d.ts +28 -0
  78. package/PieChart/PieArcLabelPlot.js +99 -0
  79. package/PieChart/PieArcPlot.d.ts +35 -0
  80. package/PieChart/PieArcPlot.js +92 -0
  81. package/PieChart/PieChart.d.ts +19 -5
  82. package/PieChart/PieChart.js +95 -18
  83. package/PieChart/PiePlot.d.ts +15 -9
  84. package/PieChart/PiePlot.js +77 -55
  85. package/PieChart/dataTransform/transition.d.ts +4 -0
  86. package/PieChart/dataTransform/transition.js +136 -0
  87. package/PieChart/dataTransform/useTransformData.d.ts +15 -0
  88. package/PieChart/dataTransform/useTransformData.js +67 -0
  89. package/PieChart/formatter.js +1 -2
  90. package/PieChart/legend.js +1 -2
  91. package/README.md +8 -14
  92. package/ResponsiveChartContainer/index.d.ts +13 -3
  93. package/ResponsiveChartContainer/index.js +7 -8
  94. package/ScatterChart/Scatter.d.ts +10 -0
  95. package/ScatterChart/Scatter.js +12 -2
  96. package/ScatterChart/ScatterChart.d.ts +16 -3
  97. package/ScatterChart/ScatterChart.js +77 -16
  98. package/ScatterChart/ScatterPlot.d.ts +10 -0
  99. package/ScatterChart/ScatterPlot.js +12 -2
  100. package/ScatterChart/formatter.js +1 -2
  101. package/ScatterChart/legend.js +1 -2
  102. package/SparkLineChart/SparkLineChart.d.ts +12 -3
  103. package/SparkLineChart/SparkLineChart.js +50 -7
  104. package/colorPalettes/colorPalettes.js +6 -12
  105. package/constants.js +5 -8
  106. package/context/CartesianContextProvider.d.ts +26 -1
  107. package/context/CartesianContextProvider.js +42 -16
  108. package/context/DrawingProvider.d.ts +25 -0
  109. package/context/DrawingProvider.js +18 -6
  110. package/context/HighlightProvider.d.ts +17 -0
  111. package/context/HighlightProvider.js +3 -4
  112. package/context/InteractionProvider.d.ts +6 -0
  113. package/context/InteractionProvider.js +3 -4
  114. package/context/SeriesContextProvider.d.ts +5 -0
  115. package/context/SeriesContextProvider.js +3 -4
  116. package/esm/BarChart/BarChart.js +90 -13
  117. package/esm/BarChart/BarElement.js +7 -4
  118. package/esm/BarChart/BarPlot.js +152 -67
  119. package/esm/BarChart/formatter.js +1 -1
  120. package/esm/ChartContainer/index.js +3 -0
  121. package/esm/ChartsAxis/ChartsAxis.js +32 -5
  122. package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +57 -20
  123. package/esm/ChartsClipPath/ChartsClipPath.js +5 -0
  124. package/esm/ChartsLegend/ChartsLegend.js +190 -144
  125. package/esm/ChartsLegend/chartsLegendClasses.js +1 -1
  126. package/esm/ChartsReferenceLine/ChartsReferenceLine.js +70 -0
  127. package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +105 -0
  128. package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +105 -0
  129. package/esm/ChartsReferenceLine/chartsReferenceLineClasses.js +6 -0
  130. package/esm/ChartsReferenceLine/common.js +20 -0
  131. package/esm/ChartsReferenceLine/index.js +2 -0
  132. package/esm/ChartsSurface.js +4 -12
  133. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +44 -30
  134. package/esm/ChartsTooltip/ChartsItemTooltipContent.js +15 -7
  135. package/esm/ChartsTooltip/ChartsTooltip.js +59 -14
  136. package/esm/ChartsTooltip/ChartsTooltipTable.js +17 -10
  137. package/esm/ChartsXAxis/ChartsXAxis.js +168 -43
  138. package/esm/ChartsYAxis/ChartsYAxis.js +93 -36
  139. package/esm/LineChart/AreaElement.js +10 -0
  140. package/esm/LineChart/AreaPlot.js +26 -6
  141. package/esm/LineChart/LineChart.js +86 -13
  142. package/esm/LineChart/LineElement.js +10 -0
  143. package/esm/LineChart/LineHighlightElement.js +10 -0
  144. package/esm/LineChart/LineHighlightPlot.js +13 -2
  145. package/esm/LineChart/LinePlot.js +25 -14
  146. package/esm/LineChart/MarkElement.js +11 -1
  147. package/esm/LineChart/MarkPlot.js +40 -8
  148. package/esm/LineChart/formatter.js +7 -3
  149. package/esm/PieChart/PieArc.js +26 -58
  150. package/esm/PieChart/PieArcLabel.js +43 -34
  151. package/esm/PieChart/PieArcLabelPlot.js +92 -0
  152. package/esm/PieChart/PieArcPlot.js +84 -0
  153. package/esm/PieChart/PieChart.js +93 -16
  154. package/esm/PieChart/PiePlot.js +76 -57
  155. package/esm/PieChart/dataTransform/transition.js +130 -0
  156. package/esm/PieChart/dataTransform/useTransformData.js +59 -0
  157. package/esm/ResponsiveChartContainer/index.js +3 -3
  158. package/esm/ScatterChart/Scatter.js +10 -0
  159. package/esm/ScatterChart/ScatterChart.js +74 -12
  160. package/esm/ScatterChart/ScatterPlot.js +10 -0
  161. package/esm/SparkLineChart/SparkLineChart.js +47 -3
  162. package/esm/constants.js +1 -1
  163. package/esm/context/CartesianContextProvider.js +41 -14
  164. package/esm/context/DrawingProvider.js +14 -0
  165. package/esm/hooks/useChartDimensions.js +2 -0
  166. package/esm/hooks/useMounted.js +16 -0
  167. package/esm/hooks/useReducedMotion.js +27 -0
  168. package/esm/hooks/useTicks.js +15 -9
  169. package/esm/index.js +1 -0
  170. package/esm/internals/components/AxisSharedComponents.js +15 -70
  171. package/esm/internals/components/ChartsText.js +77 -0
  172. package/esm/internals/domUtils.js +113 -0
  173. package/esm/internals/geometry.js +36 -0
  174. package/hooks/useAxisEvents.js +2 -2
  175. package/hooks/useChartDimensions.d.ts +2 -0
  176. package/hooks/useChartDimensions.js +5 -4
  177. package/hooks/useDrawingArea.js +2 -2
  178. package/hooks/useInteractionItemProps.js +2 -2
  179. package/hooks/useMounted.d.ts +1 -0
  180. package/hooks/useMounted.js +25 -0
  181. package/hooks/useReducedMotion.d.ts +8 -0
  182. package/hooks/useReducedMotion.js +33 -0
  183. package/hooks/useScale.d.ts +2 -2
  184. package/hooks/useScale.js +2 -2
  185. package/hooks/useTicks.d.ts +19 -11
  186. package/hooks/useTicks.js +19 -14
  187. package/index.d.ts +1 -0
  188. package/index.js +12 -1
  189. package/internals/components/AxisSharedComponents.d.ts +0 -4
  190. package/internals/components/AxisSharedComponents.js +18 -78
  191. package/internals/components/ChartsText.d.ts +35 -0
  192. package/internals/components/ChartsText.js +87 -0
  193. package/internals/defaultizeColor.d.ts +7 -2
  194. package/internals/defaultizeValueFormatter.js +1 -2
  195. package/internals/domUtils.d.ts +13 -0
  196. package/internals/domUtils.js +122 -0
  197. package/internals/geometry.d.ts +9 -0
  198. package/internals/geometry.js +42 -0
  199. package/internals/isBandScale.d.ts +3 -1
  200. package/internals/stackSeries.js +2 -4
  201. package/internals/utils.d.ts +5 -0
  202. package/legacy/BarChart/BarChart.js +90 -13
  203. package/legacy/BarChart/BarElement.js +6 -3
  204. package/legacy/BarChart/BarPlot.js +151 -63
  205. package/legacy/BarChart/formatter.js +1 -1
  206. package/legacy/ChartContainer/index.js +3 -0
  207. package/legacy/ChartsAxis/ChartsAxis.js +32 -5
  208. package/legacy/ChartsAxisHighlight/ChartsAxisHighlight.js +60 -20
  209. package/legacy/ChartsClipPath/ChartsClipPath.js +5 -0
  210. package/legacy/ChartsLegend/ChartsLegend.js +205 -142
  211. package/legacy/ChartsLegend/chartsLegendClasses.js +1 -1
  212. package/legacy/ChartsReferenceLine/ChartsReferenceLine.js +70 -0
  213. package/legacy/ChartsReferenceLine/ChartsXReferenceLine.js +105 -0
  214. package/legacy/ChartsReferenceLine/ChartsYReferenceLine.js +105 -0
  215. package/legacy/ChartsReferenceLine/chartsReferenceLineClasses.js +6 -0
  216. package/legacy/ChartsReferenceLine/common.js +20 -0
  217. package/legacy/ChartsReferenceLine/index.js +2 -0
  218. package/legacy/ChartsSurface.js +3 -12
  219. package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +22 -10
  220. package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +15 -7
  221. package/legacy/ChartsTooltip/ChartsTooltip.js +62 -14
  222. package/legacy/ChartsTooltip/ChartsTooltipTable.js +34 -26
  223. package/legacy/ChartsXAxis/ChartsXAxis.js +176 -50
  224. package/legacy/ChartsYAxis/ChartsYAxis.js +97 -41
  225. package/legacy/LineChart/AreaElement.js +10 -0
  226. package/legacy/LineChart/AreaPlot.js +31 -7
  227. package/legacy/LineChart/LineChart.js +86 -13
  228. package/legacy/LineChart/LineElement.js +10 -0
  229. package/legacy/LineChart/LineHighlightElement.js +10 -0
  230. package/legacy/LineChart/LineHighlightPlot.js +13 -2
  231. package/legacy/LineChart/LinePlot.js +29 -12
  232. package/legacy/LineChart/MarkElement.js +11 -1
  233. package/legacy/LineChart/MarkPlot.js +39 -8
  234. package/legacy/LineChart/formatter.js +7 -3
  235. package/legacy/PieChart/PieArc.js +30 -62
  236. package/legacy/PieChart/PieArcLabel.js +48 -34
  237. package/legacy/PieChart/PieArcLabelPlot.js +93 -0
  238. package/legacy/PieChart/PieArcPlot.js +84 -0
  239. package/legacy/PieChart/PieChart.js +93 -16
  240. package/legacy/PieChart/PiePlot.js +76 -59
  241. package/legacy/PieChart/dataTransform/transition.js +142 -0
  242. package/legacy/PieChart/dataTransform/useTransformData.js +60 -0
  243. package/legacy/ResponsiveChartContainer/index.js +3 -3
  244. package/legacy/ScatterChart/Scatter.js +10 -0
  245. package/legacy/ScatterChart/ScatterChart.js +74 -12
  246. package/legacy/ScatterChart/ScatterPlot.js +10 -0
  247. package/legacy/SparkLineChart/SparkLineChart.js +47 -3
  248. package/legacy/constants.js +1 -1
  249. package/legacy/context/CartesianContextProvider.js +41 -14
  250. package/legacy/context/DrawingProvider.js +14 -0
  251. package/legacy/hooks/useChartDimensions.js +2 -0
  252. package/legacy/hooks/useMounted.js +21 -0
  253. package/legacy/hooks/useReducedMotion.js +27 -0
  254. package/legacy/hooks/useTicks.js +16 -9
  255. package/legacy/index.js +2 -1
  256. package/legacy/internals/components/AxisSharedComponents.js +11 -65
  257. package/legacy/internals/components/ChartsText.js +79 -0
  258. package/legacy/internals/domUtils.js +121 -0
  259. package/legacy/internals/geometry.js +37 -0
  260. package/models/axis.d.ts +58 -20
  261. package/models/layout.d.ts +13 -6
  262. package/models/seriesType/common.d.ts +16 -0
  263. package/models/seriesType/line.d.ts +8 -3
  264. package/models/seriesType/pie.d.ts +5 -1
  265. package/modern/BarChart/BarChart.js +90 -13
  266. package/modern/BarChart/BarElement.js +7 -4
  267. package/modern/BarChart/BarPlot.js +149 -65
  268. package/modern/BarChart/formatter.js +1 -1
  269. package/modern/ChartContainer/index.js +3 -0
  270. package/modern/ChartsAxis/ChartsAxis.js +31 -5
  271. package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +57 -20
  272. package/modern/ChartsClipPath/ChartsClipPath.js +5 -0
  273. package/modern/ChartsLegend/ChartsLegend.js +190 -144
  274. package/modern/ChartsLegend/chartsLegendClasses.js +1 -1
  275. package/modern/ChartsReferenceLine/ChartsReferenceLine.js +70 -0
  276. package/modern/ChartsReferenceLine/ChartsXReferenceLine.js +104 -0
  277. package/modern/ChartsReferenceLine/ChartsYReferenceLine.js +104 -0
  278. package/modern/ChartsReferenceLine/chartsReferenceLineClasses.js +6 -0
  279. package/modern/ChartsReferenceLine/common.js +20 -0
  280. package/modern/ChartsReferenceLine/index.js +2 -0
  281. package/modern/ChartsSurface.js +4 -12
  282. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +44 -30
  283. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +15 -7
  284. package/modern/ChartsTooltip/ChartsTooltip.js +58 -14
  285. package/modern/ChartsTooltip/ChartsTooltipTable.js +17 -10
  286. package/modern/ChartsXAxis/ChartsXAxis.js +167 -42
  287. package/modern/ChartsYAxis/ChartsYAxis.js +92 -35
  288. package/modern/LineChart/AreaElement.js +10 -0
  289. package/modern/LineChart/AreaPlot.js +25 -6
  290. package/modern/LineChart/LineChart.js +86 -13
  291. package/modern/LineChart/LineElement.js +10 -0
  292. package/modern/LineChart/LineHighlightElement.js +10 -0
  293. package/modern/LineChart/LineHighlightPlot.js +13 -2
  294. package/modern/LineChart/LinePlot.js +23 -10
  295. package/modern/LineChart/MarkElement.js +11 -1
  296. package/modern/LineChart/MarkPlot.js +40 -8
  297. package/modern/LineChart/formatter.js +4 -3
  298. package/modern/PieChart/PieArc.js +26 -57
  299. package/modern/PieChart/PieArcLabel.js +43 -34
  300. package/modern/PieChart/PieArcLabelPlot.js +90 -0
  301. package/modern/PieChart/PieArcPlot.js +83 -0
  302. package/modern/PieChart/PieChart.js +93 -16
  303. package/modern/PieChart/PiePlot.js +76 -55
  304. package/modern/PieChart/dataTransform/transition.js +130 -0
  305. package/modern/PieChart/dataTransform/useTransformData.js +58 -0
  306. package/modern/ResponsiveChartContainer/index.js +3 -3
  307. package/modern/ScatterChart/Scatter.js +10 -0
  308. package/modern/ScatterChart/ScatterChart.js +74 -12
  309. package/modern/ScatterChart/ScatterPlot.js +10 -0
  310. package/modern/SparkLineChart/SparkLineChart.js +47 -3
  311. package/modern/constants.js +1 -1
  312. package/modern/context/CartesianContextProvider.js +40 -13
  313. package/modern/context/DrawingProvider.js +14 -0
  314. package/modern/hooks/useChartDimensions.js +2 -0
  315. package/modern/hooks/useMounted.js +16 -0
  316. package/modern/hooks/useReducedMotion.js +27 -0
  317. package/modern/hooks/useTicks.js +15 -9
  318. package/modern/index.js +2 -1
  319. package/modern/internals/components/AxisSharedComponents.js +15 -70
  320. package/modern/internals/components/ChartsText.js +77 -0
  321. package/modern/internals/domUtils.js +113 -0
  322. package/modern/internals/geometry.js +36 -0
  323. package/package.json +9 -6
  324. package/themeAugmentation/components.d.ts +1 -0
  325. package/themeAugmentation/overrides.d.ts +2 -0
@@ -1,11 +1,18 @@
1
- import Box from '@mui/material/Box';
2
- import Paper from '@mui/material/Paper';
1
+ import Box from '@mui/system/Box';
3
2
  import { styled } from '@mui/material/styles';
4
3
  import { tooltipClasses } from './tooltipClasses';
5
- export const ChartsTooltipPaper = styled(Paper, {
4
+ export const ChartsTooltipPaper = styled('div', {
6
5
  name: 'MuiChartsTooltip',
7
- slot: 'Table'
8
- })({});
6
+ slot: 'Container'
7
+ })(({
8
+ theme
9
+ }) => ({
10
+ backgroundColor: (theme.vars || theme).palette.background.paper,
11
+ color: (theme.vars || theme).palette.text.primary,
12
+ transition: theme.transitions.create('box-shadow'),
13
+ border: `1px solid ${(theme.vars || theme).palette.divider}`,
14
+ borderRadius: theme.shape.borderRadius
15
+ }));
9
16
  export const ChartsTooltipTable = styled('table', {
10
17
  name: 'MuiChartsTooltip',
11
18
  slot: 'Table'
@@ -14,7 +21,7 @@ export const ChartsTooltipTable = styled('table', {
14
21
  }) => ({
15
22
  borderSpacing: 0,
16
23
  '& thead td': {
17
- borderBottom: `solid ${theme.palette.divider} 1px`
24
+ borderBottom: `solid ${(theme.vars || theme).palette.divider} 1px`
18
25
  }
19
26
  }));
20
27
  export const ChartsTooltipRow = styled('tr', {
@@ -37,13 +44,13 @@ export const ChartsTooltipCell = styled('td', {
37
44
  theme
38
45
  }) => ({
39
46
  verticalAlign: 'middle',
40
- color: theme.palette.text.secondary,
47
+ color: (theme.vars || theme).palette.text.secondary,
41
48
  [`&.${tooltipClasses.labelCell}`]: {
42
49
  paddingLeft: theme.spacing(1)
43
50
  },
44
51
  [`&.${tooltipClasses.valueCell}`]: {
45
52
  paddingLeft: theme.spacing(4),
46
- color: theme.palette.text.primary
53
+ color: (theme.vars || theme).palette.text.primary
47
54
  },
48
55
  'td:first-of-type&': {
49
56
  paddingLeft: theme.spacing(2)
@@ -63,7 +70,7 @@ export const ChartsTooltipMark = styled(Box, {
63
70
  height: theme.spacing(1),
64
71
  borderRadius: '50%',
65
72
  backgroundColor: ownerState.color,
66
- borderColor: theme.palette.background.paper,
67
- border: `solid ${theme.palette.background.paper} ${theme.spacing(0.25)}`,
73
+ borderColor: (theme.vars || theme).palette.background.paper,
74
+ border: `solid ${(theme.vars || theme).palette.background.paper} ${theme.spacing(0.25)}`,
68
75
  boxSizing: 'content-box'
69
76
  }));
@@ -1,15 +1,19 @@
1
1
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
- const _excluded = ["scale", "ticksNumber"];
3
+ const _excluded = ["scale", "tickNumber"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
+ import { useSlotProps } from '@mui/base/utils';
6
7
  import { unstable_composeClasses as composeClasses } from '@mui/utils';
7
8
  import { useThemeProps, useTheme } from '@mui/material/styles';
8
9
  import { CartesianContext } from '../context/CartesianContextProvider';
9
10
  import { DrawingContext } from '../context/DrawingProvider';
10
11
  import useTicks from '../hooks/useTicks';
11
12
  import { getAxisUtilityClass } from '../ChartsAxis/axisClasses';
12
- import { ChartsLine, ChartsTick, ChartsTickLabel, ChartsLabel, AxisRoot } from '../internals/components/AxisSharedComponents';
13
+ import { AxisRoot } from '../internals/components/AxisSharedComponents';
14
+ import { ChartsText, getWordsByLines } from '../internals/components/ChartsText';
15
+ import { getMinXTranslation } from '../internals/geometry';
16
+ import { useMounted } from '../hooks/useMounted';
13
17
  import { jsx as _jsx } from "react/jsx-runtime";
14
18
  import { jsxs as _jsxs } from "react/jsx-runtime";
15
19
  const useUtilityClasses = ownerState => {
@@ -27,43 +31,113 @@ const useUtilityClasses = ownerState => {
27
31
  };
28
32
  return composeClasses(slots, getAxisUtilityClass, classes);
29
33
  };
34
+ function addLabelDimension(xTicks, {
35
+ tickLabelStyle: style,
36
+ tickLabelInterval,
37
+ isMounted
38
+ }) {
39
+ const withDimension = xTicks.map(tick => {
40
+ if (!isMounted || tick.formattedValue === undefined) {
41
+ return _extends({}, tick, {
42
+ width: 0,
43
+ height: 0
44
+ });
45
+ }
46
+ const tickSizes = getWordsByLines({
47
+ style,
48
+ needsComputation: true,
49
+ text: tick.formattedValue
50
+ });
51
+ return _extends({}, tick, {
52
+ width: Math.max(...tickSizes.map(size => size.width)),
53
+ height: Math.max(tickSizes.length * tickSizes[0].height)
54
+ });
55
+ });
56
+ if (typeof tickLabelInterval === 'function') {
57
+ return withDimension.map((item, index) => _extends({}, item, {
58
+ skipLabel: !tickLabelInterval(item.value, index)
59
+ }));
60
+ }
61
+
62
+ // Filter label to avoid overlap
63
+ let textStart = 0;
64
+ let textEnd = 0;
65
+ return withDimension.map((item, labelIndex) => {
66
+ const {
67
+ width,
68
+ offset,
69
+ labelOffset,
70
+ height
71
+ } = item;
72
+ const distance = getMinXTranslation(width, height, style == null ? void 0 : style.angle);
73
+ const textPosition = offset + labelOffset;
74
+ const gapRatio = 1.2; // Ratio applied to the minimal distance to add some margin.
75
+
76
+ textStart = textPosition - gapRatio * distance / 2;
77
+ if (labelIndex > 0 && textStart < textEnd) {
78
+ // Except for the first label, we skip all label that overlap with the last accepted.
79
+ // Notice that the early return prevents `textEnd` from being updated.
80
+ return _extends({}, item, {
81
+ skipLabel: true
82
+ });
83
+ }
84
+ textEnd = textPosition + gapRatio * distance / 2;
85
+ return item;
86
+ });
87
+ }
30
88
  const defaultProps = {
31
89
  position: 'bottom',
32
90
  disableLine: false,
33
91
  disableTicks: false,
34
- tickFontSize: 12,
35
- labelFontSize: 14,
36
92
  tickSize: 6
37
93
  };
94
+
95
+ /**
96
+ * Demos:
97
+ *
98
+ * - [Axis](https://mui.com/x/react-charts/axis/)
99
+ *
100
+ * API:
101
+ *
102
+ * - [ChartsXAxis API](https://mui.com/x/api/charts/charts-x-axis/)
103
+ */
38
104
  function ChartsXAxis(inProps) {
39
- var _slots$axisLine, _slots$axisTick, _slots$axisTickLabel, _slots$axisLabel;
105
+ var _props$axisId, _slots$axisLine, _slots$axisTick, _slots$axisTickLabel, _slots$axisLabel;
40
106
  const props = useThemeProps({
41
107
  props: _extends({}, defaultProps, inProps),
42
108
  name: 'MuiChartsXAxis'
43
109
  });
110
+ const {
111
+ xAxisIds
112
+ } = React.useContext(CartesianContext);
44
113
  const _React$useContext = React.useContext(CartesianContext),
45
- _props$axisId = props.axisId,
114
+ _ref = (_props$axisId = props.axisId) != null ? _props$axisId : xAxisIds[0],
46
115
  {
47
116
  xAxis: {
48
- [_props$axisId]: {
117
+ [_ref]: {
49
118
  scale: xScale,
50
- ticksNumber
119
+ tickNumber
51
120
  }
52
121
  }
53
122
  } = _React$useContext,
54
- settings = _objectWithoutPropertiesLoose(_React$useContext.xAxis[_props$axisId], _excluded);
123
+ settings = _objectWithoutPropertiesLoose(_React$useContext.xAxis[_ref], _excluded);
124
+ const isMounted = useMounted();
55
125
  const defaultizedProps = _extends({}, defaultProps, settings, props);
56
126
  const {
57
127
  position,
58
128
  disableLine,
59
129
  disableTicks,
60
- tickFontSize,
130
+ tickLabelStyle,
61
131
  label,
132
+ labelStyle,
133
+ tickFontSize,
62
134
  labelFontSize,
63
135
  tickSize: tickSizeProp,
64
136
  valueFormatter,
65
137
  slots,
66
- slotProps
138
+ slotProps,
139
+ tickInterval,
140
+ tickLabelInterval
67
141
  } = defaultizedProps;
68
142
  const theme = useTheme();
69
143
  const classes = useUtilityClasses(_extends({}, defaultizedProps, {
@@ -76,20 +150,52 @@ function ChartsXAxis(inProps) {
76
150
  height
77
151
  } = React.useContext(DrawingContext);
78
152
  const tickSize = disableTicks ? 4 : tickSizeProp;
153
+ const positionSign = position === 'bottom' ? 1 : -1;
154
+ const Line = (_slots$axisLine = slots == null ? void 0 : slots.axisLine) != null ? _slots$axisLine : 'line';
155
+ const Tick = (_slots$axisTick = slots == null ? void 0 : slots.axisTick) != null ? _slots$axisTick : 'line';
156
+ const TickLabel = (_slots$axisTickLabel = slots == null ? void 0 : slots.axisTickLabel) != null ? _slots$axisTickLabel : ChartsText;
157
+ const Label = (_slots$axisLabel = slots == null ? void 0 : slots.axisLabel) != null ? _slots$axisLabel : ChartsText;
158
+ const axisTickLabelProps = useSlotProps({
159
+ elementType: TickLabel,
160
+ externalSlotProps: slotProps == null ? void 0 : slotProps.axisTickLabel,
161
+ additionalProps: {
162
+ style: _extends({
163
+ textAnchor: 'middle',
164
+ dominantBaseline: position === 'bottom' ? 'hanging' : 'auto',
165
+ fontSize: tickFontSize != null ? tickFontSize : 12
166
+ }, tickLabelStyle),
167
+ className: classes.tickLabel
168
+ },
169
+ className: classes.tickLabel,
170
+ ownerState: {}
171
+ });
79
172
  const xTicks = useTicks({
80
173
  scale: xScale,
81
- ticksNumber,
82
- valueFormatter
174
+ tickNumber,
175
+ valueFormatter,
176
+ tickInterval
177
+ });
178
+ const xTicksWithDimension = addLabelDimension(xTicks, {
179
+ tickLabelStyle: axisTickLabelProps.style,
180
+ tickLabelInterval,
181
+ isMounted
83
182
  });
84
- const positionSigne = position === 'bottom' ? 1 : -1;
85
183
  const labelRefPoint = {
86
184
  x: left + width / 2,
87
- y: positionSigne * (tickFontSize + tickSize + 10)
185
+ y: positionSign * (tickSize + 22)
88
186
  };
89
- const Line = (_slots$axisLine = slots == null ? void 0 : slots.axisLine) != null ? _slots$axisLine : ChartsLine;
90
- const Tick = (_slots$axisTick = slots == null ? void 0 : slots.axisTick) != null ? _slots$axisTick : ChartsTick;
91
- const TickLabel = (_slots$axisTickLabel = slots == null ? void 0 : slots.axisTickLabel) != null ? _slots$axisTickLabel : ChartsTickLabel;
92
- const Label = (_slots$axisLabel = slots == null ? void 0 : slots.axisLabel) != null ? _slots$axisLabel : ChartsLabel;
187
+ const axisLabelProps = useSlotProps({
188
+ elementType: Label,
189
+ externalSlotProps: slotProps == null ? void 0 : slotProps.axisLabel,
190
+ additionalProps: {
191
+ style: _extends({
192
+ fontSize: labelFontSize != null ? labelFontSize : 14,
193
+ textAnchor: 'middle',
194
+ dominantBaseline: position === 'bottom' ? 'hanging' : 'auto'
195
+ }, labelStyle)
196
+ },
197
+ ownerState: {}
198
+ });
93
199
  return /*#__PURE__*/_jsxs(AxisRoot, {
94
200
  transform: `translate(0, ${position === 'bottom' ? top + height : top})`,
95
201
  className: classes.root,
@@ -97,40 +203,33 @@ function ChartsXAxis(inProps) {
97
203
  x1: xScale.range()[0],
98
204
  x2: xScale.range()[1],
99
205
  className: classes.line
100
- }, slotProps == null ? void 0 : slotProps.axisLine)), xTicks.map(({
206
+ }, slotProps == null ? void 0 : slotProps.axisLine)), xTicksWithDimension.map(({
101
207
  formattedValue,
102
208
  offset,
103
- labelOffset
209
+ labelOffset,
210
+ skipLabel
104
211
  }, index) => {
105
212
  const xTickLabel = labelOffset != null ? labelOffset : 0;
106
- const yTickLabel = positionSigne * (tickSize + 3);
213
+ const yTickLabel = positionSign * (tickSize + 3);
107
214
  return /*#__PURE__*/_jsxs("g", {
108
215
  transform: `translate(${offset}, 0)`,
109
216
  className: classes.tickContainer,
110
217
  children: [!disableTicks && /*#__PURE__*/_jsx(Tick, _extends({
111
- y2: positionSigne * tickSize,
218
+ y2: positionSign * tickSize,
112
219
  className: classes.tick
113
- }, slotProps == null ? void 0 : slotProps.axisTick)), formattedValue !== undefined && /*#__PURE__*/_jsx(TickLabel, _extends({
220
+ }, slotProps == null ? void 0 : slotProps.axisTick)), formattedValue !== undefined && !skipLabel && /*#__PURE__*/_jsx(TickLabel, _extends({
114
221
  x: xTickLabel,
115
- y: yTickLabel,
116
- "transform-origin": `${xTickLabel}px ${yTickLabel}px`,
117
- sx: {
118
- fontSize: tickFontSize
119
- },
120
- className: classes.tickLabel
121
- }, slotProps == null ? void 0 : slotProps.axisTickLabel, {
122
- children: formattedValue
222
+ y: yTickLabel
223
+ }, axisTickLabelProps, {
224
+ text: formattedValue.toString()
123
225
  }))]
124
226
  }, index);
125
- }), label && /*#__PURE__*/_jsx(Label, _extends({}, labelRefPoint, {
126
- sx: {
127
- fontSize: labelFontSize,
128
- transformOrigin: `${labelRefPoint.x}px ${labelRefPoint.y}px`
129
- },
130
- className: classes.label
131
- }, slotProps == null ? void 0 : slotProps.axisLabel, {
132
- children: label
133
- }))]
227
+ }), label && /*#__PURE__*/_jsx("g", {
228
+ className: classes.label,
229
+ children: /*#__PURE__*/_jsx(Label, _extends({}, labelRefPoint, axisLabelProps, {
230
+ text: label
231
+ }))
232
+ })]
134
233
  });
135
234
  }
136
235
  process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
@@ -139,9 +238,10 @@ process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
139
238
  // | To update them edit the TypeScript types and run "yarn proptypes" |
140
239
  // ----------------------------------------------------------------------
141
240
  /**
142
- * Id of the axis to render.
241
+ * The id of the axis to render.
242
+ * If undefined, it will be the first defined axis.
143
243
  */
144
- axisId: PropTypes.string.isRequired,
244
+ axisId: PropTypes.string,
145
245
  /**
146
246
  * Override or extend the styles applied to the component.
147
247
  */
@@ -168,8 +268,13 @@ process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
168
268
  /**
169
269
  * The font size of the axis label.
170
270
  * @default 14
271
+ * @deprecated Consider using `labelStyle.fontSize` instead.
171
272
  */
172
273
  labelFontSize: PropTypes.number,
274
+ /**
275
+ * The style applied to the axis label.
276
+ */
277
+ labelStyle: PropTypes.object,
173
278
  /**
174
279
  * Position of the axis.
175
280
  */
@@ -192,8 +297,28 @@ process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
192
297
  /**
193
298
  * The font size of the axis ticks text.
194
299
  * @default 12
300
+ * @deprecated Consider using `tickLabelStyle.fontSize` instead.
195
301
  */
196
302
  tickFontSize: PropTypes.number,
303
+ /**
304
+ * Defines which ticks are displayed. Its value can be:
305
+ * - 'auto' In such case the ticks are computed based on axis scale and other parameters.
306
+ * - a filtering function of the form `(value, index) => boolean` which is available only if the axis has a data property.
307
+ * - an array containing the values where ticks should be displayed.
308
+ * @default 'auto'
309
+ */
310
+ tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
311
+ /**
312
+ * Defines which ticks get its label displayed. Its value can be:
313
+ * - 'auto' In such case, labels are displayed if they do not overlap with the previous one.
314
+ * - a filtering function of the form (value, index) => boolean. Warning: the index is tick index, not data ones.
315
+ * @default 'auto'
316
+ */
317
+ tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
318
+ /**
319
+ * The style applied to ticks text.
320
+ */
321
+ tickLabelStyle: PropTypes.object,
197
322
  /**
198
323
  * Maximal step between two ticks.
199
324
  * When using time data, the value is assumed to be in ms.
@@ -1,14 +1,16 @@
1
1
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
- const _excluded = ["scale", "ticksNumber"];
3
+ const _excluded = ["scale", "tickNumber"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
+ import { useSlotProps } from '@mui/base/utils';
6
7
  import { unstable_composeClasses as composeClasses } from '@mui/utils';
7
8
  import { useThemeProps, useTheme } from '@mui/material/styles';
8
9
  import { CartesianContext } from '../context/CartesianContextProvider';
9
10
  import { DrawingContext } from '../context/DrawingProvider';
10
11
  import useTicks from '../hooks/useTicks';
11
- import { ChartsLine, ChartsTick, ChartsTickLabel, ChartsLabel, AxisRoot } from '../internals/components/AxisSharedComponents';
12
+ import { AxisRoot } from '../internals/components/AxisSharedComponents';
13
+ import { ChartsText } from '../internals/components/ChartsText';
12
14
  import { getAxisUtilityClass } from '../ChartsAxis/axisClasses';
13
15
  import { jsx as _jsx } from "react/jsx-runtime";
14
16
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -35,23 +37,36 @@ const defaultProps = {
35
37
  labelFontSize: 14,
36
38
  tickSize: 6
37
39
  };
40
+
41
+ /**
42
+ * Demos:
43
+ *
44
+ * - [Axis](https://mui.com/x/react-charts/axis/)
45
+ *
46
+ * API:
47
+ *
48
+ * - [ChartsYAxis API](https://mui.com/x/api/charts/charts-y-axis/)
49
+ */
38
50
  function ChartsYAxis(inProps) {
39
- var _slots$axisLine, _slots$axisTick, _slots$axisTickLabel, _slots$axisLabel;
51
+ var _props$axisId, _slots$axisLine, _slots$axisTick, _slots$axisTickLabel, _slots$axisLabel;
40
52
  const props = useThemeProps({
41
53
  props: _extends({}, defaultProps, inProps),
42
54
  name: 'MuiChartsYAxis'
43
55
  });
56
+ const {
57
+ yAxisIds
58
+ } = React.useContext(CartesianContext);
44
59
  const _React$useContext = React.useContext(CartesianContext),
45
- _props$axisId = props.axisId,
60
+ _ref = (_props$axisId = props.axisId) != null ? _props$axisId : yAxisIds[0],
46
61
  {
47
62
  yAxis: {
48
- [_props$axisId]: {
63
+ [_ref]: {
49
64
  scale: yScale,
50
- ticksNumber
65
+ tickNumber
51
66
  }
52
67
  }
53
68
  } = _React$useContext,
54
- settings = _objectWithoutPropertiesLoose(_React$useContext.yAxis[_props$axisId], _excluded);
69
+ settings = _objectWithoutPropertiesLoose(_React$useContext.yAxis[_ref], _excluded);
55
70
  const defaultizedProps = _extends({}, defaultProps, settings, props);
56
71
  const {
57
72
  position,
@@ -78,18 +93,44 @@ function ChartsYAxis(inProps) {
78
93
  const tickSize = disableTicks ? 4 : tickSizeProp;
79
94
  const yTicks = useTicks({
80
95
  scale: yScale,
81
- ticksNumber,
96
+ tickNumber,
82
97
  valueFormatter
83
98
  });
84
- const positionSigne = position === 'right' ? 1 : -1;
99
+ const positionSign = position === 'right' ? 1 : -1;
85
100
  const labelRefPoint = {
86
- x: positionSigne * (tickFontSize + tickSize + 10),
101
+ x: positionSign * (tickFontSize + tickSize + 10),
87
102
  y: top + height / 2
88
103
  };
89
- const Line = (_slots$axisLine = slots == null ? void 0 : slots.axisLine) != null ? _slots$axisLine : ChartsLine;
90
- const Tick = (_slots$axisTick = slots == null ? void 0 : slots.axisTick) != null ? _slots$axisTick : ChartsTick;
91
- const TickLabel = (_slots$axisTickLabel = slots == null ? void 0 : slots.axisTickLabel) != null ? _slots$axisTickLabel : ChartsTickLabel;
92
- const Label = (_slots$axisLabel = slots == null ? void 0 : slots.axisLabel) != null ? _slots$axisLabel : ChartsLabel;
104
+ const Line = (_slots$axisLine = slots == null ? void 0 : slots.axisLine) != null ? _slots$axisLine : 'line';
105
+ const Tick = (_slots$axisTick = slots == null ? void 0 : slots.axisTick) != null ? _slots$axisTick : 'line';
106
+ const TickLabel = (_slots$axisTickLabel = slots == null ? void 0 : slots.axisTickLabel) != null ? _slots$axisTickLabel : ChartsText;
107
+ const Label = (_slots$axisLabel = slots == null ? void 0 : slots.axisLabel) != null ? _slots$axisLabel : ChartsText;
108
+ const axisTickLabelProps = useSlotProps({
109
+ elementType: TickLabel,
110
+ externalSlotProps: slotProps == null ? void 0 : slotProps.axisTickLabel,
111
+ additionalProps: {
112
+ style: {
113
+ fontSize: tickFontSize,
114
+ textAnchor: position === 'right' ? 'start' : 'end',
115
+ dominantBaseline: 'central'
116
+ },
117
+ className: classes.tickLabel
118
+ },
119
+ ownerState: {}
120
+ });
121
+ const axisLabelProps = useSlotProps({
122
+ elementType: Label,
123
+ externalSlotProps: slotProps == null ? void 0 : slotProps.axisLabel,
124
+ additionalProps: {
125
+ style: {
126
+ fontSize: labelFontSize,
127
+ angle: positionSign * 90,
128
+ textAnchor: 'middle',
129
+ dominantBaseline: 'auto'
130
+ }
131
+ },
132
+ ownerState: {}
133
+ });
93
134
  return /*#__PURE__*/_jsxs(AxisRoot, {
94
135
  transform: `translate(${position === 'right' ? left + width : left}, 0)`,
95
136
  className: classes.root,
@@ -102,36 +143,26 @@ function ChartsYAxis(inProps) {
102
143
  offset,
103
144
  labelOffset
104
145
  }, index) => {
105
- const xTickLabel = positionSigne * (tickSize + 2);
146
+ const xTickLabel = positionSign * (tickSize + 2);
106
147
  const yTickLabel = labelOffset;
107
148
  return /*#__PURE__*/_jsxs("g", {
108
149
  transform: `translate(0, ${offset})`,
109
150
  className: classes.tickContainer,
110
151
  children: [!disableTicks && /*#__PURE__*/_jsx(Tick, _extends({
111
- x2: positionSigne * tickSize,
152
+ x2: positionSign * tickSize,
112
153
  className: classes.tick
113
154
  }, slotProps == null ? void 0 : slotProps.axisTick)), formattedValue !== undefined && /*#__PURE__*/_jsx(TickLabel, _extends({
114
155
  x: xTickLabel,
115
156
  y: yTickLabel,
116
- "transform-origin": `${xTickLabel}px ${yTickLabel}px`,
117
- sx: {
118
- fontSize: tickFontSize
119
- },
120
- className: classes.tickLabel
121
- }, slotProps == null ? void 0 : slotProps.axisTickLabel, {
122
- children: formattedValue.toLocaleString()
123
- }))]
157
+ text: formattedValue.toString()
158
+ }, axisTickLabelProps))]
124
159
  }, index);
125
- }), label && /*#__PURE__*/_jsx(Label, _extends({}, labelRefPoint, {
126
- sx: {
127
- fontSize: labelFontSize,
128
- transform: `rotate(${positionSigne * 90}deg)`,
129
- transformOrigin: `${labelRefPoint.x}px ${labelRefPoint.y}px`
130
- },
131
- className: classes.label
132
- }, slotProps == null ? void 0 : slotProps.axisLabel, {
133
- children: label
134
- }))]
160
+ }), label && /*#__PURE__*/_jsx("g", {
161
+ className: classes.label,
162
+ children: /*#__PURE__*/_jsx(Label, _extends({}, labelRefPoint, axisLabelProps, {
163
+ text: label
164
+ }))
165
+ })]
135
166
  });
136
167
  }
137
168
  process.env.NODE_ENV !== "production" ? ChartsYAxis.propTypes = {
@@ -140,9 +171,10 @@ process.env.NODE_ENV !== "production" ? ChartsYAxis.propTypes = {
140
171
  // | To update them edit the TypeScript types and run "yarn proptypes" |
141
172
  // ----------------------------------------------------------------------
142
173
  /**
143
- * Id of the axis to render.
174
+ * The id of the axis to render.
175
+ * If undefined, it will be the first defined axis.
144
176
  */
145
- axisId: PropTypes.string.isRequired,
177
+ axisId: PropTypes.string,
146
178
  /**
147
179
  * Override or extend the styles applied to the component.
148
180
  */
@@ -169,8 +201,13 @@ process.env.NODE_ENV !== "production" ? ChartsYAxis.propTypes = {
169
201
  /**
170
202
  * The font size of the axis label.
171
203
  * @default 14
204
+ * @deprecated Consider using `labelStyle.fontSize` instead.
172
205
  */
173
206
  labelFontSize: PropTypes.number,
207
+ /**
208
+ * The style applied to the axis label.
209
+ */
210
+ labelStyle: PropTypes.object,
174
211
  /**
175
212
  * Position of the axis.
176
213
  */
@@ -193,8 +230,28 @@ process.env.NODE_ENV !== "production" ? ChartsYAxis.propTypes = {
193
230
  /**
194
231
  * The font size of the axis ticks text.
195
232
  * @default 12
233
+ * @deprecated Consider using `tickLabelStyle.fontSize` instead.
196
234
  */
197
235
  tickFontSize: PropTypes.number,
236
+ /**
237
+ * Defines which ticks are displayed. Its value can be:
238
+ * - 'auto' In such case the ticks are computed based on axis scale and other parameters.
239
+ * - a filtering function of the form `(value, index) => boolean` which is available only if the axis has a data property.
240
+ * - an array containing the values where ticks should be displayed.
241
+ * @default 'auto'
242
+ */
243
+ tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
244
+ /**
245
+ * Defines which ticks get its label displayed. Its value can be:
246
+ * - 'auto' In such case, labels are displayed if they do not overlap with the previous one.
247
+ * - a filtering function of the form (value, index) => boolean. Warning: the index is tick index, not data ones.
248
+ * @default 'auto'
249
+ */
250
+ tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
251
+ /**
252
+ * The style applied to ticks text.
253
+ */
254
+ tickLabelStyle: PropTypes.object,
198
255
  /**
199
256
  * Maximal step between two ticks.
200
257
  * When using time data, the value is assumed to be in ms.
@@ -55,6 +55,16 @@ AreaElementPath.propTypes = {
55
55
  }).isRequired,
56
56
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
57
57
  };
58
+ /**
59
+ * Demos:
60
+ *
61
+ * - [Lines](https://mui.com/x/react-charts/lines/)
62
+ * - [Areas demonstration](https://mui.com/x/react-charts/areas-demo/)
63
+ *
64
+ * API:
65
+ *
66
+ * - [AreaElement API](https://mui.com/x/api/charts/area-element/)
67
+ */
58
68
  function AreaElement(props) {
59
69
  var _slots$area;
60
70
  const {
@@ -10,6 +10,17 @@ import { AreaElement } from './AreaElement';
10
10
  import { getValueToPositionMapper } from '../hooks/useScale';
11
11
  import getCurveFactory from '../internals/getCurve';
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
+ /**
14
+ * Demos:
15
+ *
16
+ * - [Lines](https://mui.com/x/react-charts/lines/)
17
+ * - [Areas demonstration](https://mui.com/x/react-charts/areas-demo/)
18
+ * - [Stacking](https://mui.com/x/react-charts/stacking/)
19
+ *
20
+ * API:
21
+ *
22
+ * - [AreaPlot API](https://mui.com/x/api/charts/area-plot/)
23
+ */
13
24
  function AreaPlot(props) {
14
25
  const {
15
26
  slots,
@@ -38,23 +49,32 @@ function AreaPlot(props) {
38
49
  ids: groupIds
39
50
  }) => {
40
51
  return groupIds.flatMap(seriesId => {
52
+ var _xData$map;
41
53
  const {
42
54
  xAxisKey = defaultXAxisId,
43
55
  yAxisKey = defaultYAxisId,
44
- stackedData
56
+ stackedData,
57
+ data,
58
+ connectNulls
45
59
  } = series[seriesId];
46
60
  const xScale = getValueToPositionMapper(xAxis[xAxisKey].scale);
47
61
  const yScale = yAxis[yAxisKey].scale;
48
62
  const xData = xAxis[xAxisKey].data;
49
- if (xData === undefined) {
50
- throw new Error(`Axis of id "${xAxisKey}" should have data property to be able to display a line plot.`);
63
+ if (process.env.NODE_ENV !== 'production') {
64
+ if (xData === undefined) {
65
+ throw new Error(`Axis of id "${xAxisKey}" should have data property to be able to display a line plot.`);
66
+ }
67
+ if (xData.length < stackedData.length) {
68
+ throw new Error(`MUI: data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items)`);
69
+ }
51
70
  }
52
- const areaPath = d3Area().x(d => xScale(d.x)).y0(d => yScale(d.y[0])).y1(d => yScale(d.y[1]));
71
+ const areaPath = d3Area().x(d => xScale(d.x)).defined((_, i) => connectNulls || data[i] != null).y0(d => d.y && yScale(d.y[0])).y1(d => d.y && yScale(d.y[1]));
53
72
  const curve = getCurveFactory(series[seriesId].curve);
54
- const d3Data = xData == null ? void 0 : xData.map((x, index) => ({
73
+ const formattedData = (_xData$map = xData == null ? void 0 : xData.map((x, index) => ({
55
74
  x,
56
75
  y: stackedData[index]
57
- }));
76
+ }))) != null ? _xData$map : [];
77
+ const d3Data = connectNulls ? formattedData.filter((_, i) => data[i] != null) : formattedData;
58
78
  return !!series[seriesId].area && /*#__PURE__*/_jsx(AreaElement, {
59
79
  id: seriesId,
60
80
  d: areaPath.curve(curve)(d3Data) || undefined,