@mui/x-charts 8.0.0-alpha.12 → 8.0.0-alpha.13

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 (314) hide show
  1. package/BarChart/BarChart.d.ts +1 -1
  2. package/BarChart/BarChart.js +14 -30
  3. package/BarChart/useBarChartProps.js +3 -18
  4. package/CHANGELOG.md +299 -0
  5. package/ChartContainer/ChartContainer.d.ts +1 -1
  6. package/ChartContainer/ChartContainer.js +15 -7
  7. package/ChartDataProvider/ChartDataProvider.d.ts +2 -2
  8. package/ChartDataProvider/ChartDataProvider.js +4 -3
  9. package/ChartsAxis/ChartsAxis.d.ts +1 -25
  10. package/ChartsAxis/ChartsAxis.js +25 -87
  11. package/ChartsAxis/axisClasses.d.ts +5 -1
  12. package/ChartsLabel/ChartsLabelMark.d.ts +6 -1
  13. package/ChartsLabel/ChartsLabelMark.js +15 -2
  14. package/ChartsLabel/index.d.ts +1 -1
  15. package/ChartsLabel/labelGradientClasses.d.ts +1 -1
  16. package/ChartsLabel/labelMarkClasses.d.ts +1 -1
  17. package/ChartsLabel/labelMarkClasses.js +1 -1
  18. package/ChartsLegend/chartsLegendClasses.d.ts +1 -1
  19. package/ChartsLegend/continuousColorLegendClasses.d.ts +1 -1
  20. package/ChartsLegend/piecewiseColorLegendClasses.d.ts +1 -1
  21. package/ChartsReferenceLine/ChartsXReferenceLine.d.ts +1 -1
  22. package/ChartsReferenceLine/ChartsYReferenceLine.d.ts +1 -1
  23. package/ChartsTooltip/ChartsTooltipTable.js +1 -1
  24. package/ChartsTooltip/chartsTooltipClasses.d.ts +1 -1
  25. package/ChartsXAxis/ChartsXAxis.js +70 -57
  26. package/ChartsYAxis/ChartsYAxis.js +11 -15
  27. package/Gauge/Gauge.js +4 -3
  28. package/Gauge/GaugeContainer.js +7 -5
  29. package/LineChart/LineChart.d.ts +1 -1
  30. package/LineChart/LineChart.js +14 -30
  31. package/LineChart/useLineChartProps.js +2 -17
  32. package/PieChart/PieArcLabelPlot.js +1 -1
  33. package/PieChart/PieArcPlot.js +1 -1
  34. package/PieChart/PieChart.d.ts +1 -1
  35. package/PieChart/PieChart.js +6 -4
  36. package/ScatterChart/ScatterChart.d.ts +1 -1
  37. package/ScatterChart/ScatterChart.js +14 -30
  38. package/ScatterChart/useScatterChartProps.js +2 -17
  39. package/SparkLineChart/SparkLineChart.d.ts +4 -8
  40. package/SparkLineChart/SparkLineChart.js +23 -21
  41. package/constants/index.d.ts +8 -1
  42. package/constants/index.js +13 -6
  43. package/context/AnimationProvider/useSkipAnimation.js +1 -1
  44. package/context/ChartProvider/ChartProvider.types.d.ts +6 -6
  45. package/context/PolarProvider/Polar.types.d.ts +3 -2
  46. package/esm/BarChart/BarChart.d.ts +1 -1
  47. package/esm/BarChart/BarChart.js +14 -30
  48. package/esm/BarChart/useBarChartProps.js +3 -18
  49. package/esm/ChartContainer/ChartContainer.d.ts +1 -1
  50. package/esm/ChartContainer/ChartContainer.js +15 -7
  51. package/esm/ChartDataProvider/ChartDataProvider.d.ts +2 -2
  52. package/esm/ChartDataProvider/ChartDataProvider.js +4 -3
  53. package/esm/ChartsAxis/ChartsAxis.d.ts +1 -25
  54. package/esm/ChartsAxis/ChartsAxis.js +24 -86
  55. package/esm/ChartsAxis/axisClasses.d.ts +5 -1
  56. package/esm/ChartsLabel/ChartsLabelMark.d.ts +6 -1
  57. package/esm/ChartsLabel/ChartsLabelMark.js +15 -2
  58. package/esm/ChartsLabel/index.d.ts +1 -1
  59. package/esm/ChartsLabel/index.js +0 -3
  60. package/esm/ChartsLabel/labelGradientClasses.d.ts +1 -1
  61. package/esm/ChartsLabel/labelMarkClasses.d.ts +1 -1
  62. package/esm/ChartsLabel/labelMarkClasses.js +1 -1
  63. package/esm/ChartsLegend/chartsLegendClasses.d.ts +1 -1
  64. package/esm/ChartsLegend/continuousColorLegendClasses.d.ts +1 -1
  65. package/esm/ChartsLegend/piecewiseColorLegendClasses.d.ts +1 -1
  66. package/esm/ChartsReferenceLine/ChartsXReferenceLine.d.ts +1 -1
  67. package/esm/ChartsReferenceLine/ChartsYReferenceLine.d.ts +1 -1
  68. package/esm/ChartsTooltip/ChartsTooltipTable.js +1 -1
  69. package/esm/ChartsTooltip/chartsTooltipClasses.d.ts +1 -1
  70. package/esm/ChartsXAxis/ChartsXAxis.js +70 -57
  71. package/esm/ChartsYAxis/ChartsYAxis.js +12 -16
  72. package/esm/Gauge/Gauge.js +4 -3
  73. package/esm/Gauge/GaugeContainer.js +7 -5
  74. package/esm/LineChart/LineChart.d.ts +1 -1
  75. package/esm/LineChart/LineChart.js +14 -30
  76. package/esm/LineChart/useLineChartProps.js +2 -17
  77. package/esm/PieChart/PieArcLabelPlot.js +1 -1
  78. package/esm/PieChart/PieArcPlot.js +1 -1
  79. package/esm/PieChart/PieChart.d.ts +1 -1
  80. package/esm/PieChart/PieChart.js +6 -4
  81. package/esm/ScatterChart/ScatterChart.d.ts +1 -1
  82. package/esm/ScatterChart/ScatterChart.js +14 -30
  83. package/esm/ScatterChart/useScatterChartProps.js +2 -17
  84. package/esm/SparkLineChart/SparkLineChart.d.ts +4 -8
  85. package/esm/SparkLineChart/SparkLineChart.js +23 -21
  86. package/esm/constants/index.d.ts +8 -1
  87. package/esm/constants/index.js +12 -5
  88. package/esm/context/AnimationProvider/useSkipAnimation.js +1 -1
  89. package/esm/context/ChartProvider/ChartProvider.types.d.ts +6 -6
  90. package/esm/context/PolarProvider/Polar.types.d.ts +3 -2
  91. package/esm/hooks/useAxis.d.ts +2 -2
  92. package/esm/hooks/useAxis.js +1 -1
  93. package/esm/hooks/useSvgRef.js +1 -1
  94. package/esm/index.js +1 -1
  95. package/esm/internals/defaultizeColor.d.ts +23 -23
  96. package/esm/internals/defaultizeMargin.d.ts +3 -0
  97. package/esm/internals/defaultizeMargin.js +15 -0
  98. package/esm/internals/domUtils.js +1 -0
  99. package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.d.ts +1 -1
  100. package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.js +52 -31
  101. package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.d.ts +549 -105
  102. package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.js +19 -18
  103. package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types.d.ts +7 -16
  104. package/esm/internals/plugins/corePlugins/useChartSeries/processSeries.d.ts +2 -2
  105. package/esm/internals/plugins/corePlugins/useChartSeries/useChartSeries.js +2 -3
  106. package/esm/internals/plugins/corePlugins/useChartSeries/useChartSeries.types.d.ts +3 -3
  107. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.d.ts +1 -1
  108. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +7 -2
  109. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.d.ts +13 -15
  110. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.js +37 -35
  111. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.d.ts +3 -36
  112. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.js +37 -9
  113. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/index.d.ts +1 -1
  114. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/index.js +1 -1
  115. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.d.ts +216 -0
  116. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.js +6 -0
  117. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +15 -14
  118. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +15 -13
  119. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisLayout.selectors.d.ts +70 -0
  120. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisLayout.selectors.js +4 -0
  121. package/{internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.selectors.d.ts → esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts} +1815 -911
  122. package/{modern/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.selectors.js → esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js} +4 -6
  123. package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.d.ts +86 -130
  124. package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +2 -2
  125. package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +188 -71
  126. package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.js +9 -4
  127. package/esm/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.types.d.ts +2 -2
  128. package/esm/internals/plugins/models/plugin.d.ts +1 -1
  129. package/esm/internals/plugins/models/seriesConfig/seriesProcessor.types.d.ts +1 -1
  130. package/esm/internals/plugins/utils/ChartStore.d.ts +7 -7
  131. package/esm/internals/plugins/utils/selectors.d.ts +1 -0
  132. package/esm/internals/store/useCharts.js +0 -8
  133. package/esm/internals/store/useSelector.d.ts +1 -1
  134. package/esm/internals/store/useSelector.js +4 -1
  135. package/esm/internals/store/useStore.js +1 -1
  136. package/esm/models/axis.d.ts +56 -10
  137. package/esm/models/colorMapping.d.ts +1 -1
  138. package/esm/models/index.d.ts +0 -1
  139. package/esm/models/index.js +0 -1
  140. package/esm/models/seriesType/bar.d.ts +1 -1
  141. package/esm/models/seriesType/config.d.ts +1 -1
  142. package/esm/models/seriesType/line.d.ts +1 -1
  143. package/esm/models/seriesType/pie.d.ts +1 -1
  144. package/esm/models/seriesType/scatter.d.ts +1 -1
  145. package/esm/models/z-axis.d.ts +1 -1
  146. package/hooks/useAxis.d.ts +2 -2
  147. package/hooks/useAxis.js +5 -5
  148. package/hooks/useSvgRef.js +1 -1
  149. package/index.js +1 -1
  150. package/internals/defaultizeColor.d.ts +23 -23
  151. package/internals/defaultizeMargin.d.ts +3 -0
  152. package/internals/defaultizeMargin.js +22 -0
  153. package/internals/domUtils.js +1 -0
  154. package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.d.ts +1 -1
  155. package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.js +51 -30
  156. package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.d.ts +549 -105
  157. package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.js +20 -19
  158. package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types.d.ts +7 -16
  159. package/internals/plugins/corePlugins/useChartSeries/processSeries.d.ts +2 -2
  160. package/internals/plugins/corePlugins/useChartSeries/useChartSeries.js +2 -3
  161. package/internals/plugins/corePlugins/useChartSeries/useChartSeries.types.d.ts +3 -3
  162. package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.d.ts +1 -1
  163. package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +7 -2
  164. package/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.d.ts +13 -15
  165. package/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.js +39 -37
  166. package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.d.ts +3 -36
  167. package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.js +36 -8
  168. package/internals/plugins/featurePlugins/useChartCartesianAxis/index.d.ts +1 -1
  169. package/internals/plugins/featurePlugins/useChartCartesianAxis/index.js +4 -4
  170. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.d.ts +216 -0
  171. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.js +12 -0
  172. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +16 -15
  173. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +15 -13
  174. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisLayout.selectors.d.ts +70 -0
  175. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisLayout.selectors.js +11 -0
  176. package/{modern/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.selectors.d.ts → internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts} +1815 -911
  177. package/internals/plugins/featurePlugins/useChartCartesianAxis/{useChartCartesianAxis.selectors.js → useChartCartesianAxisRendering.selectors.js} +10 -13
  178. package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.d.ts +86 -130
  179. package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +2 -2
  180. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +188 -71
  181. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.js +10 -5
  182. package/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.types.d.ts +2 -2
  183. package/internals/plugins/models/plugin.d.ts +1 -1
  184. package/internals/plugins/models/seriesConfig/seriesProcessor.types.d.ts +1 -1
  185. package/internals/plugins/utils/ChartStore.d.ts +7 -7
  186. package/internals/plugins/utils/selectors.d.ts +1 -0
  187. package/internals/store/useCharts.js +0 -8
  188. package/internals/store/useSelector.d.ts +1 -1
  189. package/internals/store/useSelector.js +5 -1
  190. package/internals/store/useStore.js +1 -1
  191. package/models/axis.d.ts +56 -10
  192. package/models/colorMapping.d.ts +1 -1
  193. package/models/index.d.ts +0 -1
  194. package/models/index.js +0 -11
  195. package/models/seriesType/bar.d.ts +1 -1
  196. package/models/seriesType/config.d.ts +1 -1
  197. package/models/seriesType/line.d.ts +1 -1
  198. package/models/seriesType/pie.d.ts +1 -1
  199. package/models/seriesType/scatter.d.ts +1 -1
  200. package/models/z-axis.d.ts +1 -1
  201. package/modern/BarChart/BarChart.d.ts +1 -1
  202. package/modern/BarChart/BarChart.js +14 -30
  203. package/modern/BarChart/useBarChartProps.js +3 -18
  204. package/modern/ChartContainer/ChartContainer.d.ts +1 -1
  205. package/modern/ChartContainer/ChartContainer.js +15 -7
  206. package/modern/ChartDataProvider/ChartDataProvider.d.ts +2 -2
  207. package/modern/ChartDataProvider/ChartDataProvider.js +4 -3
  208. package/modern/ChartsAxis/ChartsAxis.d.ts +1 -25
  209. package/modern/ChartsAxis/ChartsAxis.js +24 -86
  210. package/modern/ChartsAxis/axisClasses.d.ts +5 -1
  211. package/modern/ChartsLabel/ChartsLabelMark.d.ts +6 -1
  212. package/modern/ChartsLabel/ChartsLabelMark.js +15 -2
  213. package/modern/ChartsLabel/index.d.ts +1 -1
  214. package/modern/ChartsLabel/index.js +0 -3
  215. package/modern/ChartsLabel/labelGradientClasses.d.ts +1 -1
  216. package/modern/ChartsLabel/labelMarkClasses.d.ts +1 -1
  217. package/modern/ChartsLabel/labelMarkClasses.js +1 -1
  218. package/modern/ChartsLegend/chartsLegendClasses.d.ts +1 -1
  219. package/modern/ChartsLegend/continuousColorLegendClasses.d.ts +1 -1
  220. package/modern/ChartsLegend/piecewiseColorLegendClasses.d.ts +1 -1
  221. package/modern/ChartsReferenceLine/ChartsXReferenceLine.d.ts +1 -1
  222. package/modern/ChartsReferenceLine/ChartsYReferenceLine.d.ts +1 -1
  223. package/modern/ChartsTooltip/ChartsTooltipTable.js +1 -1
  224. package/modern/ChartsTooltip/chartsTooltipClasses.d.ts +1 -1
  225. package/modern/ChartsXAxis/ChartsXAxis.js +70 -57
  226. package/modern/ChartsYAxis/ChartsYAxis.js +12 -16
  227. package/modern/Gauge/Gauge.js +4 -3
  228. package/modern/Gauge/GaugeContainer.js +7 -5
  229. package/modern/LineChart/LineChart.d.ts +1 -1
  230. package/modern/LineChart/LineChart.js +14 -30
  231. package/modern/LineChart/useLineChartProps.js +2 -17
  232. package/modern/PieChart/PieArcLabelPlot.js +1 -1
  233. package/modern/PieChart/PieArcPlot.js +1 -1
  234. package/modern/PieChart/PieChart.d.ts +1 -1
  235. package/modern/PieChart/PieChart.js +6 -4
  236. package/modern/ScatterChart/ScatterChart.d.ts +1 -1
  237. package/modern/ScatterChart/ScatterChart.js +14 -30
  238. package/modern/ScatterChart/useScatterChartProps.js +2 -17
  239. package/modern/SparkLineChart/SparkLineChart.d.ts +4 -8
  240. package/modern/SparkLineChart/SparkLineChart.js +23 -21
  241. package/modern/constants/index.d.ts +8 -1
  242. package/modern/constants/index.js +12 -5
  243. package/modern/context/AnimationProvider/useSkipAnimation.js +1 -1
  244. package/modern/context/ChartProvider/ChartProvider.types.d.ts +6 -6
  245. package/modern/context/PolarProvider/Polar.types.d.ts +3 -2
  246. package/modern/hooks/useAxis.d.ts +2 -2
  247. package/modern/hooks/useAxis.js +1 -1
  248. package/modern/hooks/useSvgRef.js +1 -1
  249. package/modern/index.js +1 -1
  250. package/modern/internals/defaultizeColor.d.ts +23 -23
  251. package/modern/internals/defaultizeMargin.d.ts +3 -0
  252. package/modern/internals/defaultizeMargin.js +15 -0
  253. package/modern/internals/domUtils.js +1 -0
  254. package/modern/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.d.ts +1 -1
  255. package/modern/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.js +52 -31
  256. package/modern/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.d.ts +549 -105
  257. package/modern/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.js +19 -18
  258. package/modern/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types.d.ts +7 -16
  259. package/modern/internals/plugins/corePlugins/useChartSeries/processSeries.d.ts +2 -2
  260. package/modern/internals/plugins/corePlugins/useChartSeries/useChartSeries.js +2 -3
  261. package/modern/internals/plugins/corePlugins/useChartSeries/useChartSeries.types.d.ts +3 -3
  262. package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.d.ts +1 -1
  263. package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +7 -2
  264. package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.d.ts +13 -15
  265. package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.js +37 -35
  266. package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.d.ts +3 -36
  267. package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.js +37 -9
  268. package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/index.d.ts +1 -1
  269. package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/index.js +1 -1
  270. package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.d.ts +216 -0
  271. package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.js +6 -0
  272. package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +15 -14
  273. package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +15 -13
  274. package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisLayout.selectors.d.ts +70 -0
  275. package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisLayout.selectors.js +4 -0
  276. package/{esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.selectors.d.ts → modern/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts} +1815 -911
  277. package/{esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.selectors.js → modern/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js} +4 -6
  278. package/modern/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.d.ts +86 -130
  279. package/modern/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +2 -2
  280. package/modern/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +188 -71
  281. package/modern/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.js +9 -4
  282. package/modern/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.types.d.ts +2 -2
  283. package/modern/internals/plugins/models/plugin.d.ts +1 -1
  284. package/modern/internals/plugins/models/seriesConfig/seriesProcessor.types.d.ts +1 -1
  285. package/modern/internals/plugins/utils/ChartStore.d.ts +7 -7
  286. package/modern/internals/plugins/utils/selectors.d.ts +1 -0
  287. package/modern/internals/store/useCharts.js +0 -8
  288. package/modern/internals/store/useSelector.d.ts +1 -1
  289. package/modern/internals/store/useSelector.js +4 -1
  290. package/modern/internals/store/useStore.js +1 -1
  291. package/modern/models/axis.d.ts +56 -10
  292. package/modern/models/colorMapping.d.ts +1 -1
  293. package/modern/models/index.d.ts +0 -1
  294. package/modern/models/index.js +0 -1
  295. package/modern/models/seriesType/bar.d.ts +1 -1
  296. package/modern/models/seriesType/config.d.ts +1 -1
  297. package/modern/models/seriesType/line.d.ts +1 -1
  298. package/modern/models/seriesType/pie.d.ts +1 -1
  299. package/modern/models/seriesType/scatter.d.ts +1 -1
  300. package/modern/models/z-axis.d.ts +1 -1
  301. package/package.json +3 -3
  302. package/tsconfig.build.tsbuildinfo +1 -1
  303. package/esm/internals/calculateMargins.d.ts +0 -7
  304. package/esm/internals/calculateMargins.js +0 -25
  305. package/esm/models/layout.d.ts +0 -18
  306. package/esm/models/layout.js +0 -1
  307. package/internals/calculateMargins.d.ts +0 -7
  308. package/internals/calculateMargins.js +0 -33
  309. package/models/layout.d.ts +0 -18
  310. package/models/layout.js +0 -5
  311. package/modern/internals/calculateMargins.d.ts +0 -7
  312. package/modern/internals/calculateMargins.js +0 -25
  313. package/modern/models/layout.d.ts +0 -18
  314. package/modern/models/layout.js +0 -1
@@ -1,30 +1,6 @@
1
1
  import * as React from 'react';
2
- import { ChartsAxisSlotProps, ChartsAxisSlots, ChartsXAxisProps, ChartsYAxisProps } from "../models/axis.js";
2
+ import { ChartsAxisSlotProps, ChartsAxisSlots } from "../models/axis.js";
3
3
  export interface ChartsAxisProps {
4
- /**
5
- * Indicate which axis to display the top of the charts.
6
- * Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
7
- * @default null
8
- */
9
- topAxis?: null | string | ChartsXAxisProps;
10
- /**
11
- * Indicate which axis to display the bottom of the charts.
12
- * Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
13
- * @default xAxisIds[0] The id of the first provided axis
14
- */
15
- bottomAxis?: null | string | ChartsXAxisProps;
16
- /**
17
- * Indicate which axis to display the left of the charts.
18
- * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
19
- * @default yAxisIds[0] The id of the first provided axis
20
- */
21
- leftAxis?: null | string | ChartsYAxisProps;
22
- /**
23
- * Indicate which axis to display the right of the charts.
24
- * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
25
- * @default null
26
- */
27
- rightAxis?: null | string | ChartsYAxisProps;
28
4
  /**
29
5
  * Overridable component slots.
30
6
  * @default {}
@@ -1,38 +1,18 @@
1
1
  "use strict";
2
2
  'use client';
3
3
 
4
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
6
6
  Object.defineProperty(exports, "__esModule", {
7
7
  value: true
8
8
  });
9
9
  exports.ChartsAxis = ChartsAxis;
10
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
10
  var React = _interopRequireWildcard(require("react"));
12
11
  var _propTypes = _interopRequireDefault(require("prop-types"));
13
12
  var _ChartsXAxis = require("../ChartsXAxis");
14
13
  var _ChartsYAxis = require("../ChartsYAxis");
15
14
  var _hooks = require("../hooks");
16
15
  var _jsxRuntime = require("react/jsx-runtime");
17
- const getAxisId = (propsValue, defaultAxisId) => {
18
- if (propsValue == null) {
19
- return null;
20
- }
21
- if (typeof propsValue === 'object') {
22
- return propsValue.axisId ?? defaultAxisId ?? null;
23
- }
24
- return propsValue;
25
- };
26
- const mergeProps = (axisConfig, slots, slotProps) => {
27
- return typeof axisConfig === 'object' ? (0, _extends2.default)({}, axisConfig, {
28
- slots: (0, _extends2.default)({}, slots, axisConfig?.slots),
29
- slotProps: (0, _extends2.default)({}, slotProps, axisConfig?.slotProps)
30
- }) : {
31
- slots,
32
- slotProps
33
- };
34
- };
35
-
36
16
  /**
37
17
  * Demos:
38
18
  *
@@ -44,55 +24,37 @@ const mergeProps = (axisConfig, slots, slotProps) => {
44
24
  */
45
25
  function ChartsAxis(props) {
46
26
  const {
47
- topAxis,
48
- leftAxis,
49
- rightAxis,
50
- bottomAxis,
51
27
  slots,
52
28
  slotProps
53
29
  } = props;
54
30
  const {
55
- xAxis,
56
- xAxisIds
31
+ xAxisIds,
32
+ xAxis
57
33
  } = (0, _hooks.useXAxes)();
58
34
  const {
59
- yAxis,
60
- yAxisIds
35
+ yAxisIds,
36
+ yAxis
61
37
  } = (0, _hooks.useYAxes)();
62
- const leftId = getAxisId(leftAxis === undefined ? yAxisIds[0] : leftAxis, yAxisIds[0]);
63
- const bottomId = getAxisId(bottomAxis === undefined ? xAxisIds[0] : bottomAxis, xAxisIds[0]);
64
- const topId = getAxisId(topAxis, xAxisIds[0]);
65
- const rightId = getAxisId(rightAxis, yAxisIds[0]);
66
- if (topId !== null && !xAxis[topId]) {
67
- throw new Error([`MUI X: id used for top axis "${topId}" is not defined.`, `Available ids are: ${xAxisIds.join(', ')}.`].join('\n'));
68
- }
69
- if (leftId !== null && !yAxis[leftId]) {
70
- throw new Error([`MUI X: id used for left axis "${leftId}" is not defined.`, `Available ids are: ${yAxisIds.join(', ')}.`].join('\n'));
71
- }
72
- if (rightId !== null && !yAxis[rightId]) {
73
- throw new Error([`MUI X: id used for right axis "${rightId}" is not defined.`, `Available ids are: ${yAxisIds.join(', ')}.`].join('\n'));
74
- }
75
- if (bottomId !== null && !xAxis[bottomId]) {
76
- throw new Error([`MUI X: id used for bottom axis "${bottomId}" is not defined.`, `Available ids are: ${xAxisIds.join(', ')}.`].join('\n'));
77
- }
78
- const topAxisProps = mergeProps(topAxis, slots, slotProps);
79
- const bottomAxisProps = mergeProps(bottomAxis, slots, slotProps);
80
- const leftAxisProps = mergeProps(leftAxis, slots, slotProps);
81
- const rightAxisProps = mergeProps(rightAxis, slots, slotProps);
82
38
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
83
- children: [topId && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsXAxis.ChartsXAxis, (0, _extends2.default)({}, topAxisProps, {
84
- position: "top",
85
- axisId: topId
86
- })), bottomId && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsXAxis.ChartsXAxis, (0, _extends2.default)({}, bottomAxisProps, {
87
- position: "bottom",
88
- axisId: bottomId
89
- })), leftId && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsYAxis.ChartsYAxis, (0, _extends2.default)({}, leftAxisProps, {
90
- position: "left",
91
- axisId: leftId
92
- })), rightId && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsYAxis.ChartsYAxis, (0, _extends2.default)({}, rightAxisProps, {
93
- position: "right",
94
- axisId: rightId
95
- }))]
39
+ children: [xAxisIds.map(axisId => {
40
+ if (!xAxis[axisId].position || xAxis[axisId].position === 'none') {
41
+ return null;
42
+ }
43
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsXAxis.ChartsXAxis, {
44
+ slots: slots,
45
+ slotProps: slotProps,
46
+ axisId: axisId
47
+ }, axisId);
48
+ }), yAxisIds.map(axisId => {
49
+ if (!yAxis[axisId].position || yAxis[axisId].position === 'none') {
50
+ return null;
51
+ }
52
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsYAxis.ChartsYAxis, {
53
+ slots: slots,
54
+ slotProps: slotProps,
55
+ axisId: axisId
56
+ }, axisId);
57
+ })]
96
58
  });
97
59
  }
98
60
  process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
@@ -100,24 +62,6 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
100
62
  // | These PropTypes are generated from the TypeScript type definitions |
101
63
  // | To update them edit the TypeScript types and run "pnpm proptypes" |
102
64
  // ----------------------------------------------------------------------
103
- /**
104
- * Indicate which axis to display the bottom of the charts.
105
- * Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
106
- * @default xAxisIds[0] The id of the first provided axis
107
- */
108
- bottomAxis: _propTypes.default.oneOfType([_propTypes.default.object, _propTypes.default.string]),
109
- /**
110
- * Indicate which axis to display the left of the charts.
111
- * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
112
- * @default yAxisIds[0] The id of the first provided axis
113
- */
114
- leftAxis: _propTypes.default.oneOfType([_propTypes.default.object, _propTypes.default.string]),
115
- /**
116
- * Indicate which axis to display the right of the charts.
117
- * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
118
- * @default null
119
- */
120
- rightAxis: _propTypes.default.oneOfType([_propTypes.default.object, _propTypes.default.string]),
121
65
  /**
122
66
  * The props used for each component slot.
123
67
  * @default {}
@@ -127,11 +71,5 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
127
71
  * Overridable component slots.
128
72
  * @default {}
129
73
  */
130
- slots: _propTypes.default.object,
131
- /**
132
- * Indicate which axis to display the top of the charts.
133
- * Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
134
- * @default null
135
- */
136
- topAxis: _propTypes.default.oneOfType([_propTypes.default.object, _propTypes.default.string])
74
+ slots: _propTypes.default.object
137
75
  } : void 0;
@@ -7,7 +7,11 @@ export interface ChartsAxisClasses {
7
7
  tickContainer: string;
8
8
  /** Styles applied to ticks. */
9
9
  tick: string;
10
- /** Styles applied to ticks label. */
10
+ /** Styles applied to ticks label.
11
+ *
12
+ * ⚠️ For performance reasons, only the inline styles get considered for bounding box computation.
13
+ * Modifying text size by adding properties like `font-size` or `letter-spacing` to this class might cause labels to overlap.
14
+ */
11
15
  tickLabel: string;
12
16
  /** Styles applied to the group containing the axis label. */
13
17
  label: string;
@@ -1,12 +1,17 @@
1
1
  import * as React from 'react';
2
2
  import { SxProps, Theme } from '@mui/material/styles';
3
3
  import { ChartsLabelMarkClasses } from "./labelMarkClasses.js";
4
+ export interface ChartsLabelCustomMarkProps {
5
+ className?: string;
6
+ /** Color of the series this mark refers to. */
7
+ color?: string;
8
+ }
4
9
  export interface ChartsLabelMarkProps {
5
10
  /**
6
11
  * The type of the mark.
7
12
  * @default 'square'
8
13
  */
9
- type?: 'square' | 'circle' | 'line';
14
+ type?: 'square' | 'circle' | 'line' | React.ComponentType<ChartsLabelCustomMarkProps>;
10
15
  /**
11
16
  * The color of the mark.
12
17
  */
@@ -27,8 +27,11 @@ const Root = (0, _styles.styled)('div', {
27
27
  alignItems: 'center',
28
28
  justifyContent: 'center',
29
29
  flexShrink: 0,
30
+ width: 14,
31
+ height: 14,
30
32
  [`&.${_labelMarkClasses.labelMarkClasses.line}`]: {
31
33
  width: 16,
34
+ height: 'unset',
32
35
  display: 'flex',
33
36
  alignItems: 'center',
34
37
  [`.${_labelMarkClasses.labelMarkClasses.mask}`]: {
@@ -51,7 +54,13 @@ const Root = (0, _styles.styled)('div', {
51
54
  overflow: 'hidden'
52
55
  },
53
56
  svg: {
54
- display: 'block',
57
+ display: 'block'
58
+ },
59
+ [`& .${_labelMarkClasses.labelMarkClasses.mask} > *`]: {
60
+ height: '100%',
61
+ width: '100%'
62
+ },
63
+ [`& .${_labelMarkClasses.labelMarkClasses.mask}`]: {
55
64
  height: '100%',
56
65
  width: '100%'
57
66
  }
@@ -75,6 +84,7 @@ const ChartsLabelMark = exports.ChartsLabelMark = (0, _consumeThemeProps.consume
75
84
  classes
76
85
  } = props,
77
86
  other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
87
+ const Component = type;
78
88
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(Root, (0, _extends2.default)({
79
89
  className: (0, _clsx.default)(classes?.root, className),
80
90
  ownerState: props,
@@ -83,7 +93,10 @@ const ChartsLabelMark = exports.ChartsLabelMark = (0, _consumeThemeProps.consume
83
93
  }, other, {
84
94
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
85
95
  className: classes?.mask,
86
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", {
96
+ children: typeof Component === 'function' ? /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
97
+ className: classes?.fill,
98
+ color: color
99
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", {
87
100
  viewBox: "0 0 24 24",
88
101
  preserveAspectRatio: type === 'line' ? 'none' : undefined,
89
102
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)("rect", {
@@ -1,4 +1,4 @@
1
- export type { ChartsLabelMarkProps } from './ChartsLabelMark';
1
+ export type { ChartsLabelMarkProps, ChartsLabelCustomMarkProps } from './ChartsLabelMark';
2
2
  export { labelClasses } from "./labelClasses.js";
3
3
  export type { ChartsLabelClasses } from './labelClasses';
4
4
  export { labelMarkClasses } from "./labelMarkClasses.js";
@@ -13,4 +13,4 @@ export interface ChartsLabelGradientClasses {
13
13
  }
14
14
  export declare function getLabelGradientUtilityClass(slot: string): string;
15
15
  export declare const labelGradientClasses: ChartsLabelGradientClasses;
16
- export declare const useUtilityClasses: (props: ChartsLabelGradientProps) => Record<"fill" | "mask" | "root", string>;
16
+ export declare const useUtilityClasses: (props: ChartsLabelGradientProps) => Record<"root" | "mask" | "fill", string>;
@@ -15,4 +15,4 @@ export interface ChartsLabelMarkClasses {
15
15
  }
16
16
  export declare function getLabelMarkUtilityClass(slot: string): string;
17
17
  export declare const labelMarkClasses: ChartsLabelMarkClasses;
18
- export declare const useUtilityClasses: (props: ChartsLabelMarkProps) => Record<"fill" | "mask" | "root", string>;
18
+ export declare const useUtilityClasses: (props: ChartsLabelMarkProps) => Record<"root" | "mask" | "fill", string>;
@@ -18,7 +18,7 @@ const useUtilityClasses = props => {
18
18
  type
19
19
  } = props;
20
20
  const slots = {
21
- root: ['root', type],
21
+ root: typeof type === 'function' ? ['root'] : ['root', type],
22
22
  mask: ['mask'],
23
23
  fill: ['fill']
24
24
  };
@@ -14,5 +14,5 @@ export interface ChartsLegendClasses {
14
14
  /** Styles applied to the legend in row layout. */
15
15
  horizontal: string;
16
16
  }
17
- export declare const useUtilityClasses: (props: ChartsLegendProps & ChartsLegendSlotExtension) => Record<"label" | "mark" | "root" | "series", string>;
17
+ export declare const useUtilityClasses: (props: ChartsLegendProps & ChartsLegendSlotExtension) => Record<"root" | "label" | "mark" | "series", string>;
18
18
  export declare const legendClasses: ChartsLegendClasses;
@@ -22,5 +22,5 @@ export interface ContinuousColorLegendClasses {
22
22
  /** Styles applied to the series label. */
23
23
  label: string;
24
24
  }
25
- export declare const useUtilityClasses: (props: ContinuousColorLegendProps & ChartsLegendSlotExtension) => Record<"label" | "mark" | "root" | "minLabel" | "maxLabel" | "gradient", string>;
25
+ export declare const useUtilityClasses: (props: ContinuousColorLegendProps & ChartsLegendSlotExtension) => Record<"root" | "label" | "mark" | "minLabel" | "maxLabel" | "gradient", string>;
26
26
  export declare const continuousColorLegendClasses: ContinuousColorLegendClasses;
@@ -24,5 +24,5 @@ export interface PiecewiseColorLegendClasses {
24
24
  /** Styles applied to the series label. */
25
25
  label: string;
26
26
  }
27
- export declare const useUtilityClasses: (props: PiecewiseColorLegendProps & ChartsLegendSlotExtension) => Record<"label" | "mark" | "root" | "item" | "minLabel" | "maxLabel", string>;
27
+ export declare const useUtilityClasses: (props: PiecewiseColorLegendProps & ChartsLegendSlotExtension) => Record<"root" | "label" | "mark" | "item" | "minLabel" | "maxLabel", string>;
28
28
  export declare const piecewiseColorLegendClasses: PiecewiseColorLegendClasses;
@@ -8,6 +8,6 @@ export type ChartsXReferenceLineProps<TValue extends string | number | Date = st
8
8
  */
9
9
  x: TValue;
10
10
  };
11
- export declare function getXReferenceLineClasses(classes?: Partial<ChartsReferenceLineClasses>): Record<"line" | "label" | "root", string>;
11
+ export declare function getXReferenceLineClasses(classes?: Partial<ChartsReferenceLineClasses>): Record<"root" | "line" | "label", string>;
12
12
  declare function ChartsXReferenceLine(props: ChartsXReferenceLineProps): React.JSX.Element | null;
13
13
  export { ChartsXReferenceLine };
@@ -8,6 +8,6 @@ export type ChartsYReferenceLineProps<TValue extends string | number | Date = st
8
8
  */
9
9
  y: TValue;
10
10
  };
11
- export declare function getYReferenceLineClasses(classes?: Partial<ChartsReferenceLineClasses>): Record<"line" | "label" | "root", string>;
11
+ export declare function getYReferenceLineClasses(classes?: Partial<ChartsReferenceLineClasses>): Record<"root" | "line" | "label", string>;
12
12
  declare function ChartsYReferenceLine(props: ChartsYReferenceLineProps): React.JSX.Element | null;
13
13
  export { ChartsYReferenceLine };
@@ -18,7 +18,7 @@ const ChartsTooltipPaper = exports.ChartsTooltipPaper = (0, _styles.styled)('div
18
18
  }) => ({
19
19
  backgroundColor: (theme.vars || theme).palette.background.paper,
20
20
  color: (theme.vars || theme).palette.text.primary,
21
- borderRadius: theme.shape.borderRadius,
21
+ borderRadius: (theme.vars || theme).shape?.borderRadius,
22
22
  border: `solid ${(theme.vars || theme).palette.divider} 1px`
23
23
  }));
24
24
 
@@ -23,4 +23,4 @@ export interface ChartsTooltipClasses {
23
23
  export type ChartsTooltipClassKey = keyof Omit<ChartsTooltipClasses, 'markCell' | 'labelCell' | 'valueCell'>;
24
24
  export declare function getChartsTooltipUtilityClass(slot: string): string;
25
25
  export declare const chartsTooltipClasses: ChartsTooltipClasses;
26
- export declare const useUtilityClasses: (classes?: Partial<ChartsTooltipClasses>) => Record<"mark" | "table" | "root" | "cell" | "row" | "markCell" | "labelCell" | "valueCell" | "paper" | "axisValueCell", string>;
26
+ export declare const useUtilityClasses: (classes?: Partial<ChartsTooltipClasses>) => Record<"root" | "mark" | "table" | "cell" | "row" | "markCell" | "labelCell" | "valueCell" | "paper" | "axisValueCell", string>;
@@ -7,8 +7,8 @@ Object.defineProperty(exports, "__esModule", {
7
7
  value: true
8
8
  });
9
9
  exports.ChartsXAxis = ChartsXAxis;
10
- var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
11
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
+ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
12
12
  var React = _interopRequireWildcard(require("react"));
13
13
  var _propTypes = _interopRequireDefault(require("prop-types"));
14
14
  var _useSlotProps = _interopRequireDefault(require("@mui/utils/useSlotProps"));
@@ -43,61 +43,68 @@ const useUtilityClasses = ownerState => {
43
43
  };
44
44
  return (0, _composeClasses.default)(slots, _axisClasses.getAxisUtilityClass, classes);
45
45
  };
46
- function addLabelDimension(xTicks, {
46
+
47
+ /* Returns a set of indices of the tick labels that should be visible. */
48
+ function getVisibleLabels(xTicks, {
47
49
  tickLabelStyle: style,
48
50
  tickLabelInterval,
51
+ tickLabelMinGap,
49
52
  reverse,
50
- isMounted
53
+ isMounted,
54
+ isPointInside
51
55
  }) {
52
- const withDimension = xTicks.map(tick => {
56
+ const getTickLabelSize = tick => {
53
57
  if (!isMounted || tick.formattedValue === undefined) {
54
- return (0, _extends2.default)({}, tick, {
58
+ return {
55
59
  width: 0,
56
60
  height: 0
57
- });
61
+ };
58
62
  }
59
63
  const tickSizes = (0, _getWordsByLines.getWordsByLines)({
60
64
  style,
61
65
  needsComputation: true,
62
66
  text: tick.formattedValue
63
67
  });
64
- return (0, _extends2.default)({}, tick, {
68
+ return {
65
69
  width: Math.max(...tickSizes.map(size => size.width)),
66
70
  height: Math.max(tickSizes.length * tickSizes[0].height)
67
- });
68
- });
71
+ };
72
+ };
69
73
  if (typeof tickLabelInterval === 'function') {
70
- return withDimension.map((item, index) => (0, _extends2.default)({}, item, {
71
- skipLabel: !tickLabelInterval(item.value, index)
72
- }));
74
+ return new Set(xTicks.filter((item, index) => tickLabelInterval(item.value, index)));
73
75
  }
74
76
 
75
77
  // Filter label to avoid overlap
76
- let currentTextLimit = 0;
77
78
  let previousTextLimit = 0;
78
79
  const direction = reverse ? -1 : 1;
79
- return withDimension.map((item, labelIndex) => {
80
+ return new Set(xTicks.filter((item, labelIndex) => {
80
81
  const {
81
- width,
82
82
  offset,
83
- labelOffset,
84
- height
83
+ labelOffset
85
84
  } = item;
86
- const distance = (0, _geometry.getMinXTranslation)(width, height, style?.angle);
87
85
  const textPosition = offset + labelOffset;
88
- const gapRatio = 1.2; // Ratio applied to the minimal distance to add some margin.
86
+ if (labelIndex > 0 && direction * textPosition < direction * (previousTextLimit + tickLabelMinGap)) {
87
+ return false;
88
+ }
89
+ if (!isPointInside(textPosition)) {
90
+ return false;
91
+ }
89
92
 
90
- currentTextLimit = textPosition - direction * (gapRatio * distance) / 2;
91
- if (labelIndex > 0 && direction * currentTextLimit < direction * previousTextLimit) {
93
+ /* Measuring text width is expensive, so we need to delay it as much as possible to improve performance. */
94
+ const {
95
+ width,
96
+ height
97
+ } = getTickLabelSize(item);
98
+ const distance = (0, _geometry.getMinXTranslation)(width, height, style?.angle);
99
+ const currentTextLimit = textPosition - direction * distance / 2;
100
+ if (labelIndex > 0 && direction * currentTextLimit < direction * (previousTextLimit + tickLabelMinGap)) {
92
101
  // Except for the first label, we skip all label that overlap with the last accepted.
93
102
  // Notice that the early return prevents `previousTextLimit` from being updated.
94
- return (0, _extends2.default)({}, item, {
95
- skipLabel: true
96
- });
103
+ return false;
97
104
  }
98
- previousTextLimit = textPosition + direction * (gapRatio * distance) / 2;
99
- return item;
100
- });
105
+ previousTextLimit = textPosition + direction * distance / 2;
106
+ return true;
107
+ }));
101
108
  }
102
109
  const XAxisRoot = (0, _styles.styled)(_AxisSharedComponents.AxisRoot, {
103
110
  name: 'MuiChartsXAxis',
@@ -105,10 +112,10 @@ const XAxisRoot = (0, _styles.styled)(_AxisSharedComponents.AxisRoot, {
105
112
  overridesResolver: (props, styles) => styles.root
106
113
  })({});
107
114
  const defaultProps = {
108
- position: 'bottom',
109
115
  disableLine: false,
110
116
  disableTicks: false,
111
- tickSize: 6
117
+ tickSize: 6,
118
+ tickLabelMinGap: 4
112
119
  };
113
120
 
114
121
  /**
@@ -153,12 +160,12 @@ function ChartsXAxis(inProps) {
153
160
  tickLabelInterval,
154
161
  tickPlacement,
155
162
  tickLabelPlacement,
156
- sx
163
+ tickLabelMinGap,
164
+ sx,
165
+ offset
157
166
  } = defaultizedProps;
158
167
  const theme = (0, _styles.useTheme)();
159
- const classes = useUtilityClasses((0, _extends2.default)({}, defaultizedProps, {
160
- theme
161
- }));
168
+ const classes = useUtilityClasses(defaultizedProps);
162
169
  const {
163
170
  left,
164
171
  top,
@@ -178,7 +185,7 @@ function ChartsXAxis(inProps) {
178
185
  elementType: TickLabel,
179
186
  externalSlotProps: slotProps?.axisTickLabel,
180
187
  additionalProps: {
181
- style: (0, _extends2.default)({
188
+ style: (0, _extends2.default)({}, theme.typography.caption, {
182
189
  fontSize: 12,
183
190
  textAnchor: 'middle',
184
191
  dominantBaseline: position === 'bottom' ? 'hanging' : 'auto'
@@ -195,11 +202,18 @@ function ChartsXAxis(inProps) {
195
202
  tickPlacement,
196
203
  tickLabelPlacement
197
204
  });
198
- const xTicksWithDimension = addLabelDimension(xTicks, {
205
+ const visibleLabels = getVisibleLabels(xTicks, {
199
206
  tickLabelStyle: axisTickLabelProps.style,
200
207
  tickLabelInterval,
208
+ tickLabelMinGap,
201
209
  reverse,
202
- isMounted
210
+ isMounted,
211
+ isPointInside: x => instance.isPointInside({
212
+ x,
213
+ y: -1
214
+ }, {
215
+ direction: 'x'
216
+ })
203
217
  });
204
218
  const labelRefPoint = {
205
219
  x: left + width / 2,
@@ -222,44 +236,40 @@ function ChartsXAxis(inProps) {
222
236
  // Skip axis rendering if no data is available
223
237
  // - The domain is an empty array for band/point scales.
224
238
  // - The domains contains Infinity for continuous scales.
225
- if (ordinalAxis && domain.length === 0 || !ordinalAxis && domain.some(_isInfinity.isInfinity)) {
239
+ // - The position is set to 'none'.
240
+ if (ordinalAxis && domain.length === 0 || !ordinalAxis && domain.some(_isInfinity.isInfinity) || position === 'none') {
226
241
  return null;
227
242
  }
228
243
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(XAxisRoot, {
229
- transform: `translate(0, ${position === 'bottom' ? top + height : top})`,
244
+ transform: `translate(0, ${position === 'bottom' ? top + height + offset : top - offset})`,
230
245
  className: classes.root,
231
246
  sx: sx,
232
247
  children: [!disableLine && /*#__PURE__*/(0, _jsxRuntime.jsx)(Line, (0, _extends2.default)({
233
248
  x1: left,
234
249
  x2: left + width,
235
250
  className: classes.line
236
- }, slotProps?.axisLine)), xTicksWithDimension.map(({
237
- formattedValue,
238
- offset,
239
- labelOffset,
240
- skipLabel
241
- }, index) => {
251
+ }, slotProps?.axisLine)), xTicks.map((item, index) => {
252
+ const {
253
+ formattedValue,
254
+ offset: tickOffset,
255
+ labelOffset
256
+ } = item;
242
257
  const xTickLabel = labelOffset ?? 0;
243
258
  const yTickLabel = positionSign * (tickSize + 3);
244
259
  const showTick = instance.isPointInside({
245
- x: offset,
246
- y: -1
247
- }, {
248
- direction: 'x'
249
- });
250
- const showTickLabel = instance.isPointInside({
251
- x: offset + xTickLabel,
260
+ x: tickOffset,
252
261
  y: -1
253
262
  }, {
254
263
  direction: 'x'
255
264
  });
265
+ const showTickLabel = visibleLabels.has(item);
256
266
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("g", {
257
- transform: `translate(${offset}, 0)`,
267
+ transform: `translate(${tickOffset}, 0)`,
258
268
  className: classes.tickContainer,
259
269
  children: [!disableTicks && showTick && /*#__PURE__*/(0, _jsxRuntime.jsx)(Tick, (0, _extends2.default)({
260
270
  y2: positionSign * tickSize,
261
271
  className: classes.tick
262
- }, slotProps?.axisTick)), formattedValue !== undefined && !skipLabel && showTickLabel && /*#__PURE__*/(0, _jsxRuntime.jsx)(TickLabel, (0, _extends2.default)({
272
+ }, slotProps?.axisTick)), formattedValue !== undefined && showTickLabel && /*#__PURE__*/(0, _jsxRuntime.jsx)(TickLabel, (0, _extends2.default)({
263
273
  x: xTickLabel,
264
274
  y: yTickLabel
265
275
  }, axisTickLabelProps, {
@@ -279,6 +289,7 @@ process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
279
289
  // | These PropTypes are generated from the TypeScript type definitions |
280
290
  // | To update them edit the TypeScript types and run "pnpm proptypes" |
281
291
  // ----------------------------------------------------------------------
292
+ axis: _propTypes.default.oneOf(['x']),
282
293
  /**
283
294
  * The id of the axis to render.
284
295
  * If undefined, it will be the first defined axis.
@@ -311,10 +322,6 @@ process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
311
322
  * The style applied to the axis label.
312
323
  */
313
324
  labelStyle: _propTypes.default.object,
314
- /**
315
- * Position of the axis.
316
- */
317
- position: _propTypes.default.oneOf(['bottom', 'top']),
318
325
  /**
319
326
  * The props used for each component slot.
320
327
  * @default {}
@@ -348,6 +355,12 @@ process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
348
355
  * @default 'auto'
349
356
  */
350
357
  tickLabelInterval: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.func]),
358
+ /**
359
+ * The minimum gap in pixels between two tick labels.
360
+ * If two tick labels are closer than this minimum gap, one of them will be hidden.
361
+ * @default 4
362
+ */
363
+ tickLabelMinGap: _propTypes.default.number,
351
364
  /**
352
365
  * The placement of ticks label. Can be the middle of the band, or the tick position.
353
366
  * Only used if scale is 'band'.