@mui/x-charts 7.10.0 → 7.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (299) hide show
  1. package/BarChart/BarChart.js +2 -2
  2. package/BarChart/BarElement.d.ts +2 -1
  3. package/BarChart/BarLabel/BarLabelItem.d.ts +2 -1
  4. package/BarChart/BarPlot.js +8 -8
  5. package/BarChart/checkScaleErrors.d.ts +4 -4
  6. package/BarChart/checkScaleErrors.js +11 -11
  7. package/BarChart/extremums.js +4 -1
  8. package/BarChart/formatter.js +2 -2
  9. package/BarChart/useBarChartProps.js +38 -33
  10. package/CHANGELOG.md +169 -0
  11. package/ChartContainer/ChartContainer.d.ts +28 -2
  12. package/ChartContainer/ChartContainer.js +25 -66
  13. package/ChartContainer/useChartContainerHooks.d.ts +1 -1
  14. package/ChartContainer/useChartContainerHooks.js +2 -2
  15. package/ChartContainer/useChartContainerProps.d.ts +86 -0
  16. package/ChartContainer/useChartContainerProps.js +95 -0
  17. package/ChartContainer/useDefaultizeAxis.d.ts +36 -0
  18. package/ChartContainer/useDefaultizeAxis.js +29 -0
  19. package/ChartsAxis/ChartsAxis.js +4 -4
  20. package/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
  21. package/ChartsLegend/ChartsLegend.d.ts +3 -12
  22. package/ChartsLegend/ContinuousColorLegend.d.ts +65 -0
  23. package/ChartsLegend/ContinuousColorLegend.js +398 -0
  24. package/ChartsLegend/DefaultChartsLegend.d.ts +7 -50
  25. package/ChartsLegend/DefaultChartsLegend.js +13 -198
  26. package/ChartsLegend/LegendPerItem.d.ts +61 -0
  27. package/ChartsLegend/LegendPerItem.js +151 -0
  28. package/ChartsLegend/PiecewiseColorLegend.d.ts +26 -0
  29. package/ChartsLegend/PiecewiseColorLegend.js +169 -0
  30. package/ChartsLegend/chartsLegend.types.d.ts +31 -0
  31. package/ChartsLegend/chartsLegend.types.js +5 -0
  32. package/ChartsLegend/index.d.ts +2 -0
  33. package/ChartsLegend/index.js +22 -0
  34. package/ChartsLegend/legend.types.d.ts +62 -0
  35. package/ChartsLegend/legend.types.js +5 -0
  36. package/ChartsLegend/legendItemsPlacement.d.ts +3 -0
  37. package/ChartsLegend/legendItemsPlacement.js +79 -0
  38. package/ChartsLegend/useAxis.d.ts +7 -0
  39. package/ChartsLegend/useAxis.js +47 -0
  40. package/ChartsLegend/utils.d.ts +1 -8
  41. package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +3 -1
  42. package/ChartsOverlay/ChartsOverlay.d.ts +3 -2
  43. package/ChartsReferenceLine/ChartsReferenceLine.d.ts +1 -1
  44. package/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  45. package/ChartsReferenceLine/ChartsXReferenceLine.js +1 -2
  46. package/ChartsReferenceLine/ChartsYReferenceLine.js +1 -2
  47. package/ChartsSurface.js +3 -1
  48. package/ChartsTooltip/ChartsAxisTooltipContent.js +7 -3
  49. package/ChartsTooltip/ChartsItemTooltipContent.js +4 -4
  50. package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +30 -20
  51. package/ChartsXAxis/ChartsXAxis.js +1 -1
  52. package/ChartsYAxis/ChartsYAxis.js +15 -3
  53. package/Gauge/Gauge.d.ts +1 -4
  54. package/Gauge/Gauge.js +9 -6
  55. package/Gauge/GaugeContainer.js +8 -4
  56. package/Gauge/GaugeProvider.js +9 -9
  57. package/LineChart/AnimatedArea.js +2 -2
  58. package/LineChart/AnimatedLine.js +2 -2
  59. package/LineChart/AreaElement.d.ts +2 -1
  60. package/LineChart/AreaPlot.js +10 -6
  61. package/LineChart/LineChart.js +5 -2
  62. package/LineChart/LineElement.d.ts +2 -1
  63. package/LineChart/LineHighlightPlot.d.ts +2 -1
  64. package/LineChart/LineHighlightPlot.js +17 -5
  65. package/LineChart/LinePlot.js +10 -6
  66. package/LineChart/MarkElement.js +2 -2
  67. package/LineChart/MarkPlot.js +13 -25
  68. package/LineChart/extremums.js +4 -1
  69. package/LineChart/formatter.js +2 -2
  70. package/LineChart/useLineChartProps.js +38 -33
  71. package/PieChart/PieArc.js +1 -0
  72. package/PieChart/PieChart.d.ts +1 -4
  73. package/PieChart/PieChart.js +40 -34
  74. package/PieChart/PiePlot.js +6 -6
  75. package/PieChart/getPieCoordinates.js +3 -3
  76. package/ResponsiveChartContainer/ResponsiveChartContainer.js +8 -20
  77. package/ResponsiveChartContainer/useChartContainerDimensions.d.ts +5 -1
  78. package/ResponsiveChartContainer/useChartContainerDimensions.js +8 -4
  79. package/ResponsiveChartContainer/useResponsiveChartContainerProps.d.ts +20 -0
  80. package/ResponsiveChartContainer/useResponsiveChartContainerProps.js +73 -0
  81. package/ScatterChart/Scatter.js +6 -9
  82. package/ScatterChart/ScatterChart.js +4 -1
  83. package/ScatterChart/ScatterPlot.js +6 -3
  84. package/ScatterChart/extremums.js +8 -2
  85. package/ScatterChart/useScatterChartProps.js +35 -30
  86. package/SparkLineChart/SparkLineChart.js +27 -22
  87. package/context/CartesianProvider/CartesianContext.d.ts +1 -1
  88. package/context/CartesianProvider/CartesianProvider.d.ts +2 -3
  89. package/context/CartesianProvider/CartesianProvider.js +18 -7
  90. package/context/CartesianProvider/computeValue.d.ts +32 -9
  91. package/context/CartesianProvider/computeValue.js +20 -16
  92. package/context/CartesianProvider/defaultizeAxis.d.ts +36 -0
  93. package/context/CartesianProvider/defaultizeAxis.js +21 -0
  94. package/context/CartesianProvider/index.d.ts +0 -1
  95. package/context/CartesianProvider/index.js +1 -3
  96. package/context/CartesianProvider/normalizeAxis.d.ts +1 -1
  97. package/context/CartesianProvider/normalizeAxis.js +2 -2
  98. package/context/DrawingProvider.d.ts +12 -0
  99. package/context/DrawingProvider.js +15 -2
  100. package/context/HighlightedProvider/HighlightedProvider.js +2 -2
  101. package/context/SeriesContextProvider.js +1 -1
  102. package/context/ZAxisContextProvider.d.ts +1 -1
  103. package/context/ZAxisContextProvider.js +1 -1
  104. package/esm/BarChart/BarChart.js +2 -2
  105. package/esm/BarChart/BarPlot.js +8 -8
  106. package/esm/BarChart/checkScaleErrors.js +11 -11
  107. package/esm/BarChart/extremums.js +4 -1
  108. package/esm/BarChart/formatter.js +2 -2
  109. package/esm/BarChart/useBarChartProps.js +38 -33
  110. package/esm/ChartContainer/ChartContainer.js +25 -66
  111. package/esm/ChartContainer/useChartContainerHooks.js +2 -2
  112. package/esm/ChartContainer/useChartContainerProps.js +87 -0
  113. package/esm/ChartContainer/useDefaultizeAxis.js +19 -0
  114. package/esm/ChartsAxis/ChartsAxis.js +4 -4
  115. package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
  116. package/esm/ChartsLegend/ContinuousColorLegend.js +390 -0
  117. package/esm/ChartsLegend/DefaultChartsLegend.js +14 -198
  118. package/esm/ChartsLegend/LegendPerItem.js +141 -0
  119. package/esm/ChartsLegend/PiecewiseColorLegend.js +161 -0
  120. package/esm/ChartsLegend/chartsLegend.types.js +1 -0
  121. package/esm/ChartsLegend/index.js +2 -0
  122. package/esm/ChartsLegend/legend.types.js +1 -0
  123. package/esm/ChartsLegend/legendItemsPlacement.js +72 -0
  124. package/esm/ChartsLegend/useAxis.js +39 -0
  125. package/esm/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +3 -1
  126. package/esm/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  127. package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +2 -3
  128. package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +2 -3
  129. package/esm/ChartsSurface.js +3 -1
  130. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +7 -3
  131. package/esm/ChartsTooltip/ChartsItemTooltipContent.js +4 -4
  132. package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +30 -20
  133. package/esm/ChartsXAxis/ChartsXAxis.js +1 -1
  134. package/esm/ChartsYAxis/ChartsYAxis.js +15 -3
  135. package/esm/Gauge/Gauge.js +8 -5
  136. package/esm/Gauge/GaugeContainer.js +8 -4
  137. package/esm/Gauge/GaugeProvider.js +1 -1
  138. package/esm/LineChart/AnimatedArea.js +1 -1
  139. package/esm/LineChart/AnimatedLine.js +1 -1
  140. package/esm/LineChart/AreaPlot.js +10 -6
  141. package/esm/LineChart/LineChart.js +5 -2
  142. package/esm/LineChart/LineHighlightPlot.js +17 -5
  143. package/esm/LineChart/LinePlot.js +10 -6
  144. package/esm/LineChart/MarkElement.js +1 -1
  145. package/esm/LineChart/MarkPlot.js +12 -24
  146. package/esm/LineChart/extremums.js +4 -1
  147. package/esm/LineChart/formatter.js +2 -2
  148. package/esm/LineChart/useLineChartProps.js +38 -33
  149. package/esm/PieChart/PieArc.js +1 -0
  150. package/esm/PieChart/PieChart.js +39 -33
  151. package/esm/PieChart/PiePlot.js +1 -1
  152. package/esm/PieChart/getPieCoordinates.js +1 -1
  153. package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +8 -20
  154. package/esm/ResponsiveChartContainer/useChartContainerDimensions.js +8 -4
  155. package/esm/ResponsiveChartContainer/useResponsiveChartContainerProps.js +65 -0
  156. package/esm/ScatterChart/Scatter.js +6 -9
  157. package/esm/ScatterChart/ScatterChart.js +4 -1
  158. package/esm/ScatterChart/ScatterPlot.js +6 -3
  159. package/esm/ScatterChart/extremums.js +8 -2
  160. package/esm/ScatterChart/useScatterChartProps.js +35 -30
  161. package/esm/SparkLineChart/SparkLineChart.js +27 -22
  162. package/esm/context/CartesianProvider/CartesianProvider.js +18 -7
  163. package/esm/context/CartesianProvider/computeValue.js +20 -16
  164. package/esm/context/CartesianProvider/defaultizeAxis.js +13 -0
  165. package/esm/context/CartesianProvider/index.js +1 -3
  166. package/esm/context/CartesianProvider/normalizeAxis.js +2 -2
  167. package/esm/context/DrawingProvider.js +15 -2
  168. package/esm/context/HighlightedProvider/HighlightedProvider.js +2 -2
  169. package/esm/context/SeriesContextProvider.js +1 -1
  170. package/esm/context/ZAxisContextProvider.js +1 -1
  171. package/esm/hooks/useAxisEvents.js +14 -17
  172. package/esm/hooks/useDrawingArea.js +5 -3
  173. package/esm/hooks/useReducedMotion.js +4 -2
  174. package/esm/internals/SlotComponentPropsFromProps.js +1 -0
  175. package/esm/internals/cleanId.js +6 -0
  176. package/esm/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +3 -2
  177. package/esm/internals/geometry.js +1 -1
  178. package/esm/internals/{utils.js → getPercentageValue.js} +1 -13
  179. package/esm/internals/getSymbol.js +5 -0
  180. package/esm/internals/index.js +3 -1
  181. package/esm/internals/isDefined.js +3 -0
  182. package/esm/internals/notNull.js +3 -0
  183. package/esm/internals/ts-generic.js +1 -0
  184. package/esm/internals/warning.js +19 -11
  185. package/hooks/useAxisEvents.js +14 -17
  186. package/hooks/useDrawingArea.js +5 -3
  187. package/hooks/useReducedMotion.js +4 -2
  188. package/index.js +1 -1
  189. package/internals/SlotComponentPropsFromProps.d.ts +1 -0
  190. package/internals/SlotComponentPropsFromProps.js +5 -0
  191. package/internals/cleanId.d.ts +4 -0
  192. package/internals/cleanId.js +12 -0
  193. package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.d.ts +6 -0
  194. package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +3 -2
  195. package/internals/defaultizeColor.d.ts +7 -0
  196. package/internals/geometry.js +1 -1
  197. package/internals/getPercentageValue.d.ts +7 -0
  198. package/internals/{utils.js → getPercentageValue.js} +1 -15
  199. package/internals/getSymbol.d.ts +2 -0
  200. package/internals/getSymbol.js +11 -0
  201. package/internals/index.d.ts +3 -1
  202. package/internals/index.js +25 -5
  203. package/internals/isDefined.d.ts +1 -0
  204. package/internals/isDefined.js +9 -0
  205. package/internals/notNull.d.ts +1 -0
  206. package/internals/notNull.js +9 -0
  207. package/internals/ts-generic.d.ts +5 -0
  208. package/internals/ts-generic.js +5 -0
  209. package/internals/warning.d.ts +2 -1
  210. package/internals/warning.js +21 -12
  211. package/models/axis.d.ts +5 -2
  212. package/models/helpers.d.ts +1 -0
  213. package/models/seriesType/common.d.ts +10 -0
  214. package/models/seriesType/config.d.ts +2 -16
  215. package/models/seriesType/scatter.d.ts +5 -0
  216. package/modern/BarChart/BarChart.js +2 -2
  217. package/modern/BarChart/BarPlot.js +8 -8
  218. package/modern/BarChart/checkScaleErrors.js +11 -11
  219. package/modern/BarChart/extremums.js +4 -1
  220. package/modern/BarChart/formatter.js +2 -2
  221. package/modern/BarChart/useBarChartProps.js +38 -33
  222. package/modern/ChartContainer/ChartContainer.js +25 -66
  223. package/modern/ChartContainer/useChartContainerHooks.js +2 -2
  224. package/modern/ChartContainer/useChartContainerProps.js +87 -0
  225. package/modern/ChartContainer/useDefaultizeAxis.js +19 -0
  226. package/modern/ChartsAxis/ChartsAxis.js +4 -4
  227. package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
  228. package/modern/ChartsLegend/ContinuousColorLegend.js +390 -0
  229. package/modern/ChartsLegend/DefaultChartsLegend.js +14 -198
  230. package/modern/ChartsLegend/LegendPerItem.js +141 -0
  231. package/modern/ChartsLegend/PiecewiseColorLegend.js +161 -0
  232. package/modern/ChartsLegend/chartsLegend.types.js +1 -0
  233. package/modern/ChartsLegend/index.js +2 -0
  234. package/modern/ChartsLegend/legend.types.js +1 -0
  235. package/modern/ChartsLegend/legendItemsPlacement.js +72 -0
  236. package/modern/ChartsLegend/useAxis.js +39 -0
  237. package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +3 -1
  238. package/modern/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  239. package/modern/ChartsReferenceLine/ChartsXReferenceLine.js +2 -3
  240. package/modern/ChartsReferenceLine/ChartsYReferenceLine.js +2 -3
  241. package/modern/ChartsSurface.js +3 -1
  242. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +7 -3
  243. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +4 -4
  244. package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +30 -20
  245. package/modern/ChartsXAxis/ChartsXAxis.js +1 -1
  246. package/modern/ChartsYAxis/ChartsYAxis.js +15 -3
  247. package/modern/Gauge/Gauge.js +8 -5
  248. package/modern/Gauge/GaugeContainer.js +8 -4
  249. package/modern/Gauge/GaugeProvider.js +1 -1
  250. package/modern/LineChart/AnimatedArea.js +1 -1
  251. package/modern/LineChart/AnimatedLine.js +1 -1
  252. package/modern/LineChart/AreaPlot.js +10 -6
  253. package/modern/LineChart/LineChart.js +5 -2
  254. package/modern/LineChart/LineHighlightPlot.js +17 -5
  255. package/modern/LineChart/LinePlot.js +10 -6
  256. package/modern/LineChart/MarkElement.js +1 -1
  257. package/modern/LineChart/MarkPlot.js +12 -24
  258. package/modern/LineChart/extremums.js +4 -1
  259. package/modern/LineChart/formatter.js +2 -2
  260. package/modern/LineChart/useLineChartProps.js +38 -33
  261. package/modern/PieChart/PieArc.js +1 -0
  262. package/modern/PieChart/PieChart.js +39 -33
  263. package/modern/PieChart/PiePlot.js +1 -1
  264. package/modern/PieChart/getPieCoordinates.js +1 -1
  265. package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +8 -20
  266. package/modern/ResponsiveChartContainer/useChartContainerDimensions.js +8 -4
  267. package/modern/ResponsiveChartContainer/useResponsiveChartContainerProps.js +65 -0
  268. package/modern/ScatterChart/Scatter.js +6 -9
  269. package/modern/ScatterChart/ScatterChart.js +4 -1
  270. package/modern/ScatterChart/ScatterPlot.js +6 -3
  271. package/modern/ScatterChart/extremums.js +8 -2
  272. package/modern/ScatterChart/useScatterChartProps.js +35 -30
  273. package/modern/SparkLineChart/SparkLineChart.js +27 -22
  274. package/modern/context/CartesianProvider/CartesianProvider.js +18 -7
  275. package/modern/context/CartesianProvider/computeValue.js +20 -16
  276. package/modern/context/CartesianProvider/defaultizeAxis.js +13 -0
  277. package/modern/context/CartesianProvider/index.js +1 -3
  278. package/modern/context/CartesianProvider/normalizeAxis.js +2 -2
  279. package/modern/context/DrawingProvider.js +15 -2
  280. package/modern/context/HighlightedProvider/HighlightedProvider.js +2 -2
  281. package/modern/context/SeriesContextProvider.js +1 -1
  282. package/modern/context/ZAxisContextProvider.js +1 -1
  283. package/modern/hooks/useAxisEvents.js +14 -17
  284. package/modern/hooks/useDrawingArea.js +5 -3
  285. package/modern/hooks/useReducedMotion.js +4 -2
  286. package/modern/index.js +1 -1
  287. package/modern/internals/SlotComponentPropsFromProps.js +1 -0
  288. package/modern/internals/cleanId.js +6 -0
  289. package/modern/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +3 -2
  290. package/modern/internals/geometry.js +1 -1
  291. package/modern/internals/{utils.js → getPercentageValue.js} +1 -13
  292. package/modern/internals/getSymbol.js +5 -0
  293. package/modern/internals/index.js +3 -1
  294. package/modern/internals/isDefined.js +3 -0
  295. package/modern/internals/notNull.js +3 -0
  296. package/modern/internals/ts-generic.js +1 -0
  297. package/modern/internals/warning.js +19 -11
  298. package/package.json +4 -4
  299. package/internals/utils.d.ts +0 -18
@@ -5,7 +5,7 @@ import { useDrawingArea, useXScale } from '../hooks';
5
5
  import { ReferenceLineRoot } from './common';
6
6
  import { ChartsText } from '../ChartsText';
7
7
  import { getReferenceLineUtilityClass } from './chartsReferenceLineClasses';
8
- import { buildWarning } from '../internals/warning';
8
+ import { warnOnce } from '../internals/warning';
9
9
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
10
  const getTextParams = ({
11
11
  top,
@@ -47,7 +47,6 @@ export function getXReferenceLineClasses(classes) {
47
47
  label: ['label']
48
48
  }, getReferenceLineUtilityClass, classes);
49
49
  }
50
- const valueError = buildWarning((value, id) => `MUI X Charts: the value ${value} does not exist in the data of x axis with id ${id}.`, 'error');
51
50
  function ChartsXReferenceLine(props) {
52
51
  const {
53
52
  x,
@@ -67,7 +66,7 @@ function ChartsXReferenceLine(props) {
67
66
  const xPosition = xAxisScale(x);
68
67
  if (xPosition === undefined) {
69
68
  if (process.env.NODE_ENV !== 'production') {
70
- valueError(x, axisId);
69
+ warnOnce(`MUI X: the value ${x} does not exist in the data of x axis with id ${axisId}.`, 'error');
71
70
  }
72
71
  return null;
73
72
  }
@@ -5,7 +5,7 @@ import { useDrawingArea, useYScale } from '../hooks';
5
5
  import { ReferenceLineRoot } from './common';
6
6
  import { ChartsText } from '../ChartsText';
7
7
  import { getReferenceLineUtilityClass } from './chartsReferenceLineClasses';
8
- import { buildWarning } from '../internals/warning';
8
+ import { warnOnce } from '../internals/warning';
9
9
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
10
  const getTextParams = ({
11
11
  left,
@@ -47,7 +47,6 @@ export function getYReferenceLineClasses(classes) {
47
47
  label: ['label']
48
48
  }, getReferenceLineUtilityClass, classes);
49
49
  }
50
- const valueError = buildWarning((value, id) => `MUI X Charts: the value ${value} does not exist in the data of y axis with id ${id}.`, 'error');
51
50
  function ChartsYReferenceLine(props) {
52
51
  const {
53
52
  y,
@@ -67,7 +66,7 @@ function ChartsYReferenceLine(props) {
67
66
  const yPosition = yAxisScale(y);
68
67
  if (yPosition === undefined) {
69
68
  if (process.env.NODE_ENV !== 'production') {
70
- valueError(y, axisId);
69
+ warnOnce(`MUI X: the value ${y} does not exist in the data of y axis with id ${axisId}.`, 'error');
71
70
  }
72
71
  return null;
73
72
  }
@@ -21,6 +21,7 @@ const ChartsSurface = /*#__PURE__*/React.forwardRef(function ChartsSurface(props
21
21
  height,
22
22
  viewBox,
23
23
  disableAxisListener = false,
24
+ className,
24
25
  title,
25
26
  desc
26
27
  } = props,
@@ -36,7 +37,8 @@ const ChartsSurface = /*#__PURE__*/React.forwardRef(function ChartsSurface(props
36
37
  width: width,
37
38
  height: height,
38
39
  viewBox: `${svgView.x} ${svgView.y} ${svgView.width} ${svgView.height}`,
39
- ref: ref
40
+ ref: ref,
41
+ className: className
40
42
  }, other, {
41
43
  children: [/*#__PURE__*/_jsx("title", {
42
44
  children: title
@@ -40,11 +40,15 @@ function ChartsAxisTooltipContent(props) {
40
40
  Object.keys(series).filter(isCartesianSeriesType).forEach(seriesType => {
41
41
  series[seriesType].seriesOrder.forEach(seriesId => {
42
42
  const item = series[seriesType].series[seriesId];
43
- const axisKey = isXaxis ? item.xAxisKey : item.yAxisKey;
43
+ const providedXAxisId = item.xAxisId ?? item.xAxisKey;
44
+ const providedYAxisId = item.yAxisId ?? item.yAxisKey;
45
+ const axisKey = isXaxis ? providedXAxisId : providedYAxisId;
44
46
  if (axisKey === undefined || axisKey === USED_AXIS_ID) {
45
47
  const seriesToAdd = series[seriesType].series[seriesId];
46
- const zAxisKey = seriesToAdd.zAxisKey ?? zAxisIds[0];
47
- const getColor = colorProcessors[seriesType]?.(seriesToAdd, xAxis[seriesToAdd.xAxisKey ?? xAxisIds[0]], yAxis[seriesToAdd.yAxisKey ?? yAxisIds[0]], zAxisKey && zAxis[zAxisKey]) ?? (() => '');
48
+ const xAxisId = providedXAxisId ?? xAxisIds[0];
49
+ const yAxisId = providedYAxisId ?? yAxisIds[0];
50
+ const zAxisId = seriesToAdd.zAxisId ?? seriesToAdd.zAxisKey ?? zAxisIds[0];
51
+ const getColor = colorProcessors[seriesType]?.(seriesToAdd, xAxis[xAxisId], yAxis[yAxisId], zAxisId && zAxis[zAxisId]) ?? (() => '');
48
52
  rep.push(_extends({}, seriesToAdd, {
49
53
  getColor
50
54
  }));
@@ -30,10 +30,10 @@ function ChartsItemTooltipContent(props) {
30
30
  zAxisIds
31
31
  } = React.useContext(ZAxisContext);
32
32
  const colorProcessors = useColorProcessor();
33
- const xAxisKey = series.xAxisKey ?? xAxisIds[0];
34
- const yAxisKey = series.yAxisKey ?? yAxisIds[0];
35
- const zAxisKey = series.zAxisKey ?? zAxisIds[0];
36
- const getColor = colorProcessors[series.type]?.(series, xAxisKey && xAxis[xAxisKey], yAxisKey && yAxis[yAxisKey], zAxisKey && zAxis[zAxisKey]) ?? (() => '');
33
+ const xAxisId = series.xAxisId ?? series.xAxisKey ?? xAxisIds[0];
34
+ const yAxisId = series.yAxisId ?? series.yAxisKey ?? yAxisIds[0];
35
+ const zAxisId = series.zAxisId ?? series.zAxisKey ?? zAxisIds[0];
36
+ const getColor = colorProcessors[series.type]?.(series, xAxisId && xAxis[xAxisId], yAxisId && yAxis[yAxisId], zAxisId && zAxis[zAxisId]) ?? (() => '');
37
37
  const Content = content ?? DefaultChartsItemTooltipContent;
38
38
  const chartTooltipContentProps = useSlotProps({
39
39
  elementType: Content,
@@ -16,12 +16,7 @@ function ChartsVoronoiHandler(props) {
16
16
  onItemClick
17
17
  } = props;
18
18
  const svgRef = useSvgRef();
19
- const {
20
- left,
21
- top,
22
- width,
23
- height
24
- } = useDrawingArea();
19
+ const drawingArea = useDrawingArea();
25
20
  const {
26
21
  xAxis,
27
22
  yAxis,
@@ -37,6 +32,7 @@ function ChartsVoronoiHandler(props) {
37
32
  } = useScatterSeries() ?? {};
38
33
  const voronoiRef = React.useRef({});
39
34
  const delauneyRef = React.useRef(undefined);
35
+ const lastFind = React.useRef(undefined);
40
36
  const {
41
37
  setHighlighted,
42
38
  clearHighlighted
@@ -67,17 +63,32 @@ function ChartsVoronoiHandler(props) {
67
63
  seriesOrder.forEach(seriesId => {
68
64
  const {
69
65
  data,
66
+ xAxisId,
67
+ yAxisId,
70
68
  xAxisKey,
71
69
  yAxisKey
72
70
  } = series[seriesId];
73
- const xScale = xAxis[xAxisKey ?? defaultXAxisId].scale;
74
- const yScale = yAxis[yAxisKey ?? defaultYAxisId].scale;
71
+ const xScale = xAxis[xAxisId ?? xAxisKey ?? defaultXAxisId].scale;
72
+ const yScale = yAxis[yAxisId ?? yAxisKey ?? defaultYAxisId].scale;
75
73
  const getXPosition = getValueToPositionMapper(xScale);
76
74
  const getYPosition = getValueToPositionMapper(yScale);
77
75
  const seriesPoints = data.flatMap(({
78
76
  x,
79
77
  y
80
- }) => [getXPosition(x), getYPosition(y)]);
78
+ }) => {
79
+ const pointX = getXPosition(x);
80
+ const pointY = getYPosition(y);
81
+ if (!drawingArea.isPointInside({
82
+ x: pointX,
83
+ y: pointY
84
+ })) {
85
+ // If the point is not displayed we move them to a trash coordinate.
86
+ // This avoids managing index mapping before/after filtering.
87
+ // The trash point is far enough such that any point in the drawing area will be closer to the mouse than the trash coordinate.
88
+ return [-drawingArea.width, -drawingArea.height];
89
+ }
90
+ return [pointX, pointY];
91
+ });
81
92
  voronoiRef.current[seriesId] = {
82
93
  seriesId,
83
94
  startIndex: points.length,
@@ -86,29 +97,28 @@ function ChartsVoronoiHandler(props) {
86
97
  points = points.concat(seriesPoints);
87
98
  });
88
99
  delauneyRef.current = new Delaunay(points);
89
- }, [defaultXAxisId, defaultYAxisId, series, seriesOrder, xAxis, yAxis]);
100
+ lastFind.current = undefined;
101
+ }, [defaultXAxisId, defaultYAxisId, series, seriesOrder, xAxis, yAxis, drawingArea]);
90
102
  React.useEffect(() => {
91
103
  const element = svgRef.current;
92
104
  if (element === null) {
93
105
  return undefined;
94
106
  }
95
-
96
- // TODO: A perf optimisation of voronoi could be to use the last point as the initial point for the next search.
97
107
  function getClosestPoint(event) {
98
108
  // Get mouse coordinate in global SVG space
99
109
  const svgPoint = getSVGPoint(element, event);
100
- const outsideX = svgPoint.x < left || svgPoint.x > left + width;
101
- const outsideY = svgPoint.y < top || svgPoint.y > top + height;
102
- if (outsideX || outsideY) {
110
+ if (!drawingArea.isPointInside(svgPoint)) {
111
+ lastFind.current = undefined;
103
112
  return 'outside-chart';
104
113
  }
105
114
  if (!delauneyRef.current) {
106
115
  return 'no-point-found';
107
116
  }
108
- const closestPointIndex = delauneyRef.current.find(svgPoint.x, svgPoint.y);
117
+ const closestPointIndex = delauneyRef.current.find(svgPoint.x, svgPoint.y, lastFind.current);
109
118
  if (closestPointIndex === undefined) {
110
119
  return 'no-point-found';
111
120
  }
121
+ lastFind.current = closestPointIndex;
112
122
  const closestSeries = Object.values(voronoiRef.current).find(value => {
113
123
  return 2 * closestPointIndex >= value.startIndex && 2 * closestPointIndex < value.endIndex;
114
124
  });
@@ -130,7 +140,7 @@ function ChartsVoronoiHandler(props) {
130
140
  dataIndex
131
141
  };
132
142
  }
133
- const handleMouseOut = () => {
143
+ const handleMouseLeave = () => {
134
144
  dispatch({
135
145
  type: 'exitChart'
136
146
  });
@@ -191,15 +201,15 @@ function ChartsVoronoiHandler(props) {
191
201
  dataIndex
192
202
  });
193
203
  };
194
- element.addEventListener('pointerout', handleMouseOut);
204
+ element.addEventListener('pointerleave', handleMouseLeave);
195
205
  element.addEventListener('pointermove', handleMouseMove);
196
206
  element.addEventListener('click', handleMouseClick);
197
207
  return () => {
198
- element.removeEventListener('pointerout', handleMouseOut);
208
+ element.removeEventListener('pointerleave', handleMouseLeave);
199
209
  element.removeEventListener('pointermove', handleMouseMove);
200
210
  element.removeEventListener('click', handleMouseClick);
201
211
  };
202
- }, [svgRef, dispatch, left, width, top, height, yAxis, xAxis, voronoiMaxRadius, onItemClick, setHighlighted, clearHighlighted]);
212
+ }, [svgRef, dispatch, yAxis, xAxis, voronoiMaxRadius, onItemClick, setHighlighted, clearHighlighted, drawingArea]);
203
213
 
204
214
  // eslint-disable-next-line react/jsx-no-useless-fragment
205
215
  return /*#__PURE__*/_jsx(React.Fragment, {});
@@ -212,7 +212,7 @@ function ChartsXAxis(inProps) {
212
212
  x1: left,
213
213
  x2: left + width,
214
214
  className: classes.line
215
- }, slotProps?.axisLine)), xTicksWithDimension.filter(tick => tick.offset >= left - 1 && tick.offset <= left + width + 1).map(({
215
+ }, slotProps?.axisLine)), xTicksWithDimension.map(({
216
216
  formattedValue,
217
217
  offset,
218
218
  labelOffset,
@@ -136,6 +136,14 @@ function ChartsYAxis(inProps) {
136
136
  },
137
137
  ownerState: {}
138
138
  });
139
+ const lineSlotProps = useSlotProps({
140
+ elementType: Line,
141
+ externalSlotProps: slotProps?.axisLine,
142
+ additionalProps: {
143
+ strokeLinecap: 'square'
144
+ },
145
+ ownerState: {}
146
+ });
139
147
  const domain = yScale.domain();
140
148
  if (domain.length === 0 || domain[0] === domain[1]) {
141
149
  // Skip axis rendering if
@@ -147,10 +155,10 @@ function ChartsYAxis(inProps) {
147
155
  transform: `translate(${position === 'right' ? left + width : left}, 0)`,
148
156
  className: classes.root,
149
157
  children: [!disableLine && /*#__PURE__*/_jsx(Line, _extends({
150
- y1: yScale.range()[0],
151
- y2: yScale.range()[1],
158
+ y1: top,
159
+ y2: top + height,
152
160
  className: classes.line
153
- }, slotProps?.axisLine)), yTicks.map(({
161
+ }, lineSlotProps)), yTicks.map(({
154
162
  formattedValue,
155
163
  offset,
156
164
  labelOffset,
@@ -159,6 +167,10 @@ function ChartsYAxis(inProps) {
159
167
  const xTickLabel = positionSign * (tickSize + 2);
160
168
  const yTickLabel = labelOffset;
161
169
  const skipLabel = typeof tickLabelInterval === 'function' && !tickLabelInterval?.(value, index);
170
+ const showLabel = offset >= top - 1 && offset <= height + top + 1;
171
+ if (!showLabel) {
172
+ return null;
173
+ }
162
174
  return /*#__PURE__*/_jsxs("g", {
163
175
  transform: `translate(0, ${offset})`,
164
176
  className: classes.tickContainer,
@@ -1,9 +1,10 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["text", "children", "classes"];
3
+ const _excluded = ["text", "children", "classes", "className"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import composeClasses from '@mui/utils/composeClasses';
7
+ import clsx from 'clsx';
7
8
  import { GaugeContainer } from './GaugeContainer';
8
9
  import { GaugeValueArc } from './GaugeValueArc';
9
10
  import { GaugeReferenceArc } from './GaugeReferenceArc';
@@ -22,15 +23,17 @@ const useUtilityClasses = props => {
22
23
  };
23
24
  return composeClasses(slots, getGaugeUtilityClass, classes);
24
25
  };
25
- function Gauge(props) {
26
+ const Gauge = /*#__PURE__*/React.forwardRef(function Gauge(props, ref) {
26
27
  const {
27
28
  text,
28
- children
29
+ children,
30
+ className
29
31
  } = props,
30
32
  other = _objectWithoutPropertiesLoose(props, _excluded);
31
33
  const classes = useUtilityClasses(props);
32
34
  return /*#__PURE__*/_jsxs(GaugeContainer, _extends({}, other, {
33
- className: classes.root,
35
+ className: clsx(classes.root, className),
36
+ ref: ref,
34
37
  children: [/*#__PURE__*/_jsx(GaugeReferenceArc, {
35
38
  className: classes.referenceArc
36
39
  }), /*#__PURE__*/_jsx(GaugeValueArc, {
@@ -40,7 +43,7 @@ function Gauge(props) {
40
43
  text: text
41
44
  }), children]
42
45
  }));
43
- }
46
+ });
44
47
  process.env.NODE_ENV !== "production" ? Gauge.propTypes = {
45
48
  // ----------------------------- Warning --------------------------------
46
49
  // | These PropTypes are generated from the TypeScript type definitions |
@@ -3,8 +3,8 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
3
3
  const _excluded = ["width", "height", "margin", "title", "desc", "value", "valueMin", "valueMax", "startAngle", "endAngle", "outerRadius", "innerRadius", "cornerRadius", "cx", "cy", "children"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
- import useForkRef from '@mui/utils/useForkRef';
7
6
  import { styled } from '@mui/material/styles';
7
+ import useForkRef from '@mui/utils/useForkRef';
8
8
  import { useChartContainerDimensions } from '../ResponsiveChartContainer/useChartContainerDimensions';
9
9
  import { ChartsSurface } from '../ChartsSurface';
10
10
  import { DrawingProvider } from '../context/DrawingProvider';
@@ -54,9 +54,13 @@ const GaugeContainer = /*#__PURE__*/React.forwardRef(function GaugeContainer(pro
54
54
  children
55
55
  } = props,
56
56
  other = _objectWithoutPropertiesLoose(props, _excluded);
57
- const [containerRef, width, height] = useChartContainerDimensions(inWidth, inHeight);
57
+ const {
58
+ containerRef,
59
+ width,
60
+ height
61
+ } = useChartContainerDimensions(inWidth, inHeight);
58
62
  const svgRef = React.useRef(null);
59
- const handleRef = useForkRef(ref, svgRef);
63
+ const chartSurfaceRef = useForkRef(ref, svgRef);
60
64
  return /*#__PURE__*/_jsx(ResizableContainer, _extends({
61
65
  ref: containerRef,
62
66
  ownerState: {
@@ -92,7 +96,7 @@ const GaugeContainer = /*#__PURE__*/React.forwardRef(function GaugeContainer(pro
92
96
  children: /*#__PURE__*/_jsx(ChartsSurface, {
93
97
  width: width,
94
98
  height: height,
95
- ref: handleRef,
99
+ ref: chartSurfaceRef,
96
100
  title: title,
97
101
  desc: desc,
98
102
  disableAxisListener: true,
@@ -1,6 +1,6 @@
1
1
  // @ignore - do not document.
2
2
  import * as React from 'react';
3
- import { getPercentageValue } from '../internals/utils';
3
+ import { getPercentageValue } from '../internals/getPercentageValue';
4
4
  import { getArcRatios, getAvailableRadius } from './utils';
5
5
  import { useDrawingArea } from '../hooks/useDrawingArea';
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -7,7 +7,7 @@ import { styled } from '@mui/material/styles';
7
7
  import { color as d3Color } from 'd3-color';
8
8
  import { animated, useSpring } from '@react-spring/web';
9
9
  import { useAnimatedPath } from '../internals/useAnimatedPath';
10
- import { cleanId } from '../internals/utils';
10
+ import { cleanId } from '../internals/cleanId';
11
11
  import { useChartId, useDrawingArea } from '../hooks';
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  export const AreaElementPath = styled(animated.path, {
@@ -7,7 +7,7 @@ import { animated, useSpring } from '@react-spring/web';
7
7
  import { color as d3Color } from 'd3-color';
8
8
  import { styled } from '@mui/material/styles';
9
9
  import { useAnimatedPath } from '../internals/useAnimatedPath';
10
- import { cleanId } from '../internals/utils';
10
+ import { cleanId } from '../internals/cleanId';
11
11
  import { useChartId } from '../hooks/useChartId';
12
12
  import { useDrawingArea } from '../hooks/useDrawingArea';
13
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
@@ -36,22 +36,26 @@ const useAggregatedData = () => {
36
36
  return [...groupIds].reverse() // Revert stacked area for a more pleasant animation
37
37
  .map(seriesId => {
38
38
  const {
39
+ xAxisId: xAxisIdProp,
40
+ yAxisId: yAxisIdProp,
39
41
  xAxisKey = defaultXAxisId,
40
42
  yAxisKey = defaultYAxisId,
41
43
  stackedData,
42
44
  data,
43
45
  connectNulls
44
46
  } = series[seriesId];
45
- const xScale = getValueToPositionMapper(xAxis[xAxisKey].scale);
46
- const yScale = yAxis[yAxisKey].scale;
47
- const xData = xAxis[xAxisKey].data;
48
- const gradientUsed = yAxis[yAxisKey].colorScale && [yAxisKey, 'y'] || xAxis[xAxisKey].colorScale && [xAxisKey, 'x'] || undefined;
47
+ const xAxisId = xAxisIdProp ?? xAxisKey;
48
+ const yAxisId = yAxisIdProp ?? yAxisKey;
49
+ const xScale = getValueToPositionMapper(xAxis[xAxisId].scale);
50
+ const yScale = yAxis[yAxisId].scale;
51
+ const xData = xAxis[xAxisId].data;
52
+ const gradientUsed = yAxis[yAxisId].colorScale && [yAxisId, 'y'] || xAxis[xAxisId].colorScale && [xAxisId, 'x'] || undefined;
49
53
  if (process.env.NODE_ENV !== 'production') {
50
54
  if (xData === undefined) {
51
- throw new Error(`MUI X Charts: ${xAxisKey === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisKey}"`} should have data property to be able to display a line plot.`);
55
+ throw new Error(`MUI X: ${xAxisId === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisId}"`} should have data property to be able to display a line plot.`);
52
56
  }
53
57
  if (xData.length < stackedData.length) {
54
- throw new Error(`MUI X Charts: The data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items).`);
58
+ throw new Error(`MUI X: The data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items).`);
55
59
  }
56
60
  }
57
61
  const areaPath = d3Area().x(d => xScale(d.x)).defined((_, i) => connectNulls || data[i] != null).y0(d => {
@@ -48,8 +48,11 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
48
48
  ref: ref
49
49
  }, chartContainerProps, {
50
50
  children: [props.onAxisClick && /*#__PURE__*/_jsx(ChartsOnAxisClickHandler, _extends({}, axisClickHandlerProps)), props.grid && /*#__PURE__*/_jsx(ChartsGrid, _extends({}, gridProps)), /*#__PURE__*/_jsxs("g", _extends({}, clipPathGroupProps, {
51
- children: [/*#__PURE__*/_jsx(AreaPlot, _extends({}, areaPlotProps)), /*#__PURE__*/_jsx(LinePlot, _extends({}, linePlotProps)), /*#__PURE__*/_jsx(ChartsOverlay, _extends({}, overlayProps))]
52
- })), /*#__PURE__*/_jsx(ChartsAxis, _extends({}, chartsAxisProps)), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlightProps)), /*#__PURE__*/_jsx(MarkPlot, _extends({}, markPlotProps)), /*#__PURE__*/_jsx(LineHighlightPlot, _extends({}, lineHighlightPlotProps)), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legendProps)), !props.loading && /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltipProps)), /*#__PURE__*/_jsx(ChartsClipPath, _extends({}, clipPathProps)), children]
51
+ children: [/*#__PURE__*/_jsx(AreaPlot, _extends({}, areaPlotProps)), /*#__PURE__*/_jsx(LinePlot, _extends({}, linePlotProps)), /*#__PURE__*/_jsx(ChartsOverlay, _extends({}, overlayProps)), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlightProps))]
52
+ })), /*#__PURE__*/_jsx(ChartsAxis, _extends({}, chartsAxisProps)), /*#__PURE__*/_jsx("g", {
53
+ "data-drawing-container": true,
54
+ children: /*#__PURE__*/_jsx(MarkPlot, _extends({}, markPlotProps))
55
+ }), /*#__PURE__*/_jsx(LineHighlightPlot, _extends({}, lineHighlightPlotProps)), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legendProps)), !props.loading && /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltipProps)), /*#__PURE__*/_jsx(ChartsClipPath, _extends({}, clipPathProps)), children]
53
56
  }));
54
57
  });
55
58
  process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
@@ -10,6 +10,7 @@ import { InteractionContext } from '../context/InteractionProvider';
10
10
  import { DEFAULT_X_AXIS_KEY } from '../constants';
11
11
  import getColor from './getColor';
12
12
  import { useLineSeries } from '../hooks/useSeries';
13
+ import { useDrawingArea } from '../hooks/useDrawingArea';
13
14
  import { jsx as _jsx } from "react/jsx-runtime";
14
15
  /**
15
16
  * Demos:
@@ -29,6 +30,7 @@ function LineHighlightPlot(props) {
29
30
  other = _objectWithoutPropertiesLoose(props, _excluded);
30
31
  const seriesData = useLineSeries();
31
32
  const axisData = useCartesianContext();
33
+ const drawingArea = useDrawingArea();
32
34
  const {
33
35
  axis
34
36
  } = React.useContext(InteractionContext);
@@ -58,25 +60,35 @@ function LineHighlightPlot(props) {
58
60
  }) => {
59
61
  return groupIds.flatMap(seriesId => {
60
62
  const {
63
+ xAxisId: xAxisIdProp,
64
+ yAxisId: yAxisIdProp,
61
65
  xAxisKey = defaultXAxisId,
62
66
  yAxisKey = defaultYAxisId,
63
67
  stackedData,
64
68
  data,
65
69
  disableHighlight
66
70
  } = series[seriesId];
71
+ const xAxisId = xAxisIdProp ?? xAxisKey;
72
+ const yAxisId = yAxisIdProp ?? yAxisKey;
67
73
  if (disableHighlight || data[highlightedIndex] == null) {
68
74
  return null;
69
75
  }
70
- const xScale = getValueToPositionMapper(xAxis[xAxisKey].scale);
71
- const yScale = yAxis[yAxisKey].scale;
72
- const xData = xAxis[xAxisKey].data;
76
+ const xScale = getValueToPositionMapper(xAxis[xAxisId].scale);
77
+ const yScale = yAxis[yAxisId].scale;
78
+ const xData = xAxis[xAxisId].data;
73
79
  if (xData === undefined) {
74
- throw new Error(`MUI X Charts: ${xAxisKey === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisKey}"`} should have data property to be able to display a line plot.`);
80
+ throw new Error(`MUI X: ${xAxisId === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisId}"`} should have data property to be able to display a line plot.`);
75
81
  }
76
82
  const x = xScale(xData[highlightedIndex]);
77
83
  const y = yScale(stackedData[highlightedIndex][1]); // This should not be undefined since y should not be a band scale
78
84
 
79
- const colorGetter = getColor(series[seriesId], xAxis[xAxisKey], yAxis[yAxisKey]);
85
+ if (!drawingArea.isPointInside({
86
+ x,
87
+ y
88
+ })) {
89
+ return null;
90
+ }
91
+ const colorGetter = getColor(series[seriesId], xAxis[xAxisId], yAxis[yAxisId]);
80
92
  return /*#__PURE__*/_jsx(Element, _extends({
81
93
  id: seriesId,
82
94
  color: colorGetter(highlightedIndex),
@@ -35,22 +35,26 @@ const useAggregatedData = () => {
35
35
  }) => {
36
36
  return groupIds.flatMap(seriesId => {
37
37
  const {
38
+ xAxisId: xAxisIdProp,
39
+ yAxisId: yAxisIdProp,
38
40
  xAxisKey = defaultXAxisId,
39
41
  yAxisKey = defaultYAxisId,
40
42
  stackedData,
41
43
  data,
42
44
  connectNulls
43
45
  } = series[seriesId];
44
- const xScale = getValueToPositionMapper(xAxis[xAxisKey].scale);
45
- const yScale = yAxis[yAxisKey].scale;
46
- const xData = xAxis[xAxisKey].data;
47
- const gradientUsed = yAxis[yAxisKey].colorScale && [yAxisKey, 'y'] || xAxis[xAxisKey].colorScale && [xAxisKey, 'x'] || undefined;
46
+ const xAxisId = xAxisIdProp ?? xAxisKey;
47
+ const yAxisId = yAxisIdProp ?? yAxisKey;
48
+ const xScale = getValueToPositionMapper(xAxis[xAxisId].scale);
49
+ const yScale = yAxis[yAxisId].scale;
50
+ const xData = xAxis[xAxisId].data;
51
+ const gradientUsed = yAxis[yAxisId].colorScale && [yAxisId, 'y'] || xAxis[xAxisId].colorScale && [xAxisId, 'x'] || undefined;
48
52
  if (process.env.NODE_ENV !== 'production') {
49
53
  if (xData === undefined) {
50
- throw new Error(`MUI X Charts: ${xAxisKey === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisKey}"`} should have data property to be able to display a line plot.`);
54
+ throw new Error(`MUI X: ${xAxisId === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisId}"`} should have data property to be able to display a line plot.`);
51
55
  }
52
56
  if (xData.length < stackedData.length) {
53
- throw new Error(`MUI X Charts: The data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items).`);
57
+ throw new Error(`MUI X: The data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items).`);
54
58
  }
55
59
  }
56
60
  const linePath = d3Line().x(d => xScale(d.x)).defined((_, i) => connectNulls || data[i] != null).y(d => yScale(d.y[1]));
@@ -9,7 +9,7 @@ import { styled } from '@mui/material/styles';
9
9
  import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
10
10
  import { symbol as d3Symbol, symbolsFill as d3SymbolsFill } from 'd3-shape';
11
11
  import { animated, to, useSpring } from '@react-spring/web';
12
- import { getSymbol } from '../internals/utils';
12
+ import { getSymbol } from '../internals/getSymbol';
13
13
  import { InteractionContext } from '../context/InteractionProvider';
14
14
  import { useInteractionItemProps } from '../hooks/useInteractionItemProps';
15
15
  import { useItemHighlighted } from '../context';
@@ -8,7 +8,7 @@ import { MarkElement } from './MarkElement';
8
8
  import { getValueToPositionMapper } from '../hooks/useScale';
9
9
  import { useChartId } from '../hooks/useChartId';
10
10
  import { DEFAULT_X_AXIS_KEY } from '../constants';
11
- import { cleanId } from '../internals/utils';
11
+ import { cleanId } from '../internals/cleanId';
12
12
  import getColor from './getColor';
13
13
  import { useLineSeries } from '../hooks/useSeries';
14
14
  import { useDrawingArea } from '../hooks/useDrawingArea';
@@ -34,10 +34,7 @@ function MarkPlot(props) {
34
34
  const seriesData = useLineSeries();
35
35
  const axisData = useCartesianContext();
36
36
  const chartId = useChartId();
37
- const {
38
- left,
39
- width
40
- } = useDrawingArea();
37
+ const drawingArea = useDrawingArea();
41
38
  const Mark = slots?.mark ?? MarkElement;
42
39
  if (seriesData === undefined) {
43
40
  return null;
@@ -60,6 +57,8 @@ function MarkPlot(props) {
60
57
  }) => {
61
58
  return groupIds.map(seriesId => {
62
59
  const {
60
+ xAxisId: xAxisIdProp,
61
+ yAxisId: yAxisIdProp,
63
62
  xAxisKey = defaultXAxisId,
64
63
  yAxisKey = defaultYAxisId,
65
64
  stackedData,
@@ -69,28 +68,17 @@ function MarkPlot(props) {
69
68
  if (showMark === false) {
70
69
  return null;
71
70
  }
72
- const xScale = getValueToPositionMapper(xAxis[xAxisKey].scale);
73
- const yScale = yAxis[yAxisKey].scale;
74
- const xData = xAxis[xAxisKey].data;
75
- const yRange = yScale.range();
76
- const isInRange = ({
77
- x,
78
- y
79
- }) => {
80
- if (x < left || x > left + width) {
81
- return false;
82
- }
83
- if (y < Math.min(...yRange) || y > Math.max(...yRange)) {
84
- return false;
85
- }
86
- return true;
87
- };
71
+ const xAxisId = xAxisIdProp ?? xAxisKey;
72
+ const yAxisId = yAxisIdProp ?? yAxisKey;
73
+ const xScale = getValueToPositionMapper(xAxis[xAxisId].scale);
74
+ const yScale = yAxis[yAxisId].scale;
75
+ const xData = xAxis[xAxisId].data;
88
76
  if (xData === undefined) {
89
- throw new Error(`MUI X Charts: ${xAxisKey === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisKey}"`} should have data property to be able to display a line plot.`);
77
+ throw new Error(`MUI X: ${xAxisId === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisId}"`} should have data property to be able to display a line plot.`);
90
78
  }
91
79
  const clipId = cleanId(`${chartId}-${seriesId}-line-clip`); // We assume that if displaying line mark, the line will also be rendered
92
80
 
93
- const colorGetter = getColor(series[seriesId], xAxis[xAxisKey], yAxis[yAxisKey]);
81
+ const colorGetter = getColor(series[seriesId], xAxis[xAxisId], yAxis[yAxisId]);
94
82
  return /*#__PURE__*/_jsx("g", {
95
83
  clipPath: `url(#${clipId})`,
96
84
  children: xData?.map((x, index) => {
@@ -113,7 +101,7 @@ function MarkPlot(props) {
113
101
  // Remove missing data point
114
102
  return false;
115
103
  }
116
- if (!isInRange({
104
+ if (!drawingArea.isPointInside({
117
105
  x,
118
106
  y
119
107
  })) {
@@ -24,7 +24,10 @@ export const getExtremumY = params => {
24
24
  axis,
25
25
  isDefaultAxis
26
26
  } = params;
27
- return Object.keys(series).filter(seriesId => series[seriesId].yAxisKey === axis.id || isDefaultAxis && series[seriesId].yAxisKey === undefined).reduce((acc, seriesId) => {
27
+ return Object.keys(series).filter(seriesId => {
28
+ const yAxisId = series[seriesId].yAxisId ?? series[seriesId].yAxisKey;
29
+ return yAxisId === axis.id || isDefaultAxis && yAxisId === undefined;
30
+ }).reduce((acc, seriesId) => {
28
31
  const {
29
32
  area,
30
33
  stackedData
@@ -31,7 +31,7 @@ const formatter = (params, dataset) => {
31
31
  }
32
32
  });
33
33
  } else if (dataset === undefined && process.env.NODE_ENV !== 'production') {
34
- throw new Error([`MUI X Charts: line series with id='${id}' has no data.`, 'Either provide a data property to the series or use the dataset prop.'].join('\n'));
34
+ throw new Error([`MUI X: line series with id='${id}' has no data.`, 'Either provide a data property to the series or use the dataset prop.'].join('\n'));
35
35
  }
36
36
  });
37
37
  const completedSeries = {};
@@ -56,7 +56,7 @@ const formatter = (params, dataset) => {
56
56
  if (typeof value !== 'number') {
57
57
  if (process.env.NODE_ENV !== 'production' && !warnedOnce && value !== null) {
58
58
  warnedOnce = true;
59
- console.error([`MUI-X charts: your dataset key "${dataKey}" is used for plotting line, but contains nonnumerical elements.`, 'Line plots only support numbers and null values.']);
59
+ console.error([`MUI X: Your dataset key "${dataKey}" is used for plotting line, but contains nonnumerical elements.`, 'Line plots only support numbers and null values.']);
60
60
  }
61
61
  return null;
62
62
  }