@mui/x-charts 7.11.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 (121) hide show
  1. package/BarChart/BarElement.d.ts +2 -1
  2. package/BarChart/BarLabel/BarLabelItem.d.ts +2 -1
  3. package/BarChart/BarPlot.js +8 -8
  4. package/BarChart/checkScaleErrors.d.ts +4 -4
  5. package/BarChart/checkScaleErrors.js +11 -11
  6. package/BarChart/extremums.js +4 -1
  7. package/BarChart/formatter.js +2 -2
  8. package/CHANGELOG.md +84 -0
  9. package/ChartsAxis/ChartsAxis.js +4 -4
  10. package/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
  11. package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +3 -1
  12. package/ChartsOverlay/ChartsOverlay.d.ts +3 -2
  13. package/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  14. package/ChartsReferenceLine/ChartsXReferenceLine.js +1 -2
  15. package/ChartsReferenceLine/ChartsYReferenceLine.js +1 -2
  16. package/ChartsTooltip/ChartsAxisTooltipContent.js +7 -3
  17. package/ChartsTooltip/ChartsItemTooltipContent.js +4 -4
  18. package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +4 -2
  19. package/LineChart/AreaElement.d.ts +2 -1
  20. package/LineChart/AreaPlot.js +10 -6
  21. package/LineChart/LineChart.js +4 -1
  22. package/LineChart/LineElement.d.ts +2 -1
  23. package/LineChart/LineHighlightPlot.d.ts +2 -1
  24. package/LineChart/LineHighlightPlot.js +9 -5
  25. package/LineChart/LinePlot.js +10 -6
  26. package/LineChart/MarkPlot.js +9 -5
  27. package/LineChart/extremums.js +4 -1
  28. package/LineChart/formatter.js +2 -2
  29. package/PieChart/PieArc.js +1 -0
  30. package/ResponsiveChartContainer/useChartContainerDimensions.js +2 -2
  31. package/ScatterChart/ScatterChart.js +4 -1
  32. package/ScatterChart/ScatterPlot.js +6 -3
  33. package/ScatterChart/extremums.js +8 -2
  34. package/context/CartesianProvider/CartesianContext.d.ts +1 -1
  35. package/context/CartesianProvider/normalizeAxis.js +1 -1
  36. package/context/DrawingProvider.d.ts +2 -1
  37. package/context/DrawingProvider.js +7 -1
  38. package/context/SeriesContextProvider.js +1 -1
  39. package/context/ZAxisContextProvider.d.ts +1 -1
  40. package/context/ZAxisContextProvider.js +1 -1
  41. package/esm/BarChart/BarPlot.js +8 -8
  42. package/esm/BarChart/checkScaleErrors.js +11 -11
  43. package/esm/BarChart/extremums.js +4 -1
  44. package/esm/BarChart/formatter.js +2 -2
  45. package/esm/ChartsAxis/ChartsAxis.js +4 -4
  46. package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
  47. package/esm/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +3 -1
  48. package/esm/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  49. package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +2 -3
  50. package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +2 -3
  51. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +7 -3
  52. package/esm/ChartsTooltip/ChartsItemTooltipContent.js +4 -4
  53. package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +4 -2
  54. package/esm/LineChart/AreaPlot.js +10 -6
  55. package/esm/LineChart/LineChart.js +4 -1
  56. package/esm/LineChart/LineHighlightPlot.js +9 -5
  57. package/esm/LineChart/LinePlot.js +10 -6
  58. package/esm/LineChart/MarkPlot.js +9 -5
  59. package/esm/LineChart/extremums.js +4 -1
  60. package/esm/LineChart/formatter.js +2 -2
  61. package/esm/PieChart/PieArc.js +1 -0
  62. package/esm/ResponsiveChartContainer/useChartContainerDimensions.js +2 -2
  63. package/esm/ScatterChart/ScatterChart.js +4 -1
  64. package/esm/ScatterChart/ScatterPlot.js +6 -3
  65. package/esm/ScatterChart/extremums.js +8 -2
  66. package/esm/context/CartesianProvider/normalizeAxis.js +1 -1
  67. package/esm/context/DrawingProvider.js +7 -1
  68. package/esm/context/SeriesContextProvider.js +1 -1
  69. package/esm/context/ZAxisContextProvider.js +1 -1
  70. package/esm/hooks/useAxisEvents.js +12 -8
  71. package/esm/internals/SlotComponentPropsFromProps.js +1 -0
  72. package/esm/internals/geometry.js +1 -1
  73. package/esm/internals/getPercentageValue.js +1 -1
  74. package/esm/internals/warning.js +19 -11
  75. package/hooks/useAxisEvents.js +12 -8
  76. package/index.js +1 -1
  77. package/internals/SlotComponentPropsFromProps.d.ts +1 -0
  78. package/internals/SlotComponentPropsFromProps.js +5 -0
  79. package/internals/defaultizeColor.d.ts +7 -0
  80. package/internals/geometry.js +1 -1
  81. package/internals/getPercentageValue.js +1 -1
  82. package/internals/warning.d.ts +2 -1
  83. package/internals/warning.js +21 -12
  84. package/models/seriesType/common.d.ts +10 -0
  85. package/models/seriesType/scatter.d.ts +5 -0
  86. package/modern/BarChart/BarPlot.js +8 -8
  87. package/modern/BarChart/checkScaleErrors.js +11 -11
  88. package/modern/BarChart/extremums.js +4 -1
  89. package/modern/BarChart/formatter.js +2 -2
  90. package/modern/ChartsAxis/ChartsAxis.js +4 -4
  91. package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
  92. package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +3 -1
  93. package/modern/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  94. package/modern/ChartsReferenceLine/ChartsXReferenceLine.js +2 -3
  95. package/modern/ChartsReferenceLine/ChartsYReferenceLine.js +2 -3
  96. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +7 -3
  97. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +4 -4
  98. package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +4 -2
  99. package/modern/LineChart/AreaPlot.js +10 -6
  100. package/modern/LineChart/LineChart.js +4 -1
  101. package/modern/LineChart/LineHighlightPlot.js +9 -5
  102. package/modern/LineChart/LinePlot.js +10 -6
  103. package/modern/LineChart/MarkPlot.js +9 -5
  104. package/modern/LineChart/extremums.js +4 -1
  105. package/modern/LineChart/formatter.js +2 -2
  106. package/modern/PieChart/PieArc.js +1 -0
  107. package/modern/ResponsiveChartContainer/useChartContainerDimensions.js +2 -2
  108. package/modern/ScatterChart/ScatterChart.js +4 -1
  109. package/modern/ScatterChart/ScatterPlot.js +6 -3
  110. package/modern/ScatterChart/extremums.js +8 -2
  111. package/modern/context/CartesianProvider/normalizeAxis.js +1 -1
  112. package/modern/context/DrawingProvider.js +7 -1
  113. package/modern/context/SeriesContextProvider.js +1 -1
  114. package/modern/context/ZAxisContextProvider.js +1 -1
  115. package/modern/hooks/useAxisEvents.js +12 -8
  116. package/modern/index.js +1 -1
  117. package/modern/internals/SlotComponentPropsFromProps.js +1 -0
  118. package/modern/internals/geometry.js +1 -1
  119. package/modern/internals/getPercentageValue.js +1 -1
  120. package/modern/internals/warning.js +19 -11
  121. package/package.json +3 -3
@@ -38,7 +38,7 @@ const formatter = (params, dataset) => {
38
38
  }
39
39
  });
40
40
  } else if (dataset === undefined && process.env.NODE_ENV !== 'production') {
41
- 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'));
41
+ 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'));
42
42
  }
43
43
  });
44
44
  const completedSeries = {};
@@ -63,7 +63,7 @@ const formatter = (params, dataset) => {
63
63
  if (typeof value !== 'number') {
64
64
  if (process.env.NODE_ENV !== 'production' && !warnedOnce && value !== null) {
65
65
  warnedOnce = true;
66
- 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.']);
66
+ 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.']);
67
67
  }
68
68
  return null;
69
69
  }
@@ -84,6 +84,7 @@ function PieArc(props) {
84
84
  innerRadius: iR,
85
85
  outerRadius: oR
86
86
  })),
87
+ visibility: (0, _web.to)([startAngle, endAngle], (sA, eA) => sA === eA ? 'hidden' : 'visible'),
87
88
  onClick: onClick,
88
89
  cursor: onClick ? 'pointer' : 'unset',
89
90
  ownerState: ownerState,
@@ -63,11 +63,11 @@ const useChartContainerDimensions = (inWidth, inHeight) => {
63
63
  }, [computeSize, inHeight, inWidth]);
64
64
  if (process.env.NODE_ENV !== 'production') {
65
65
  if (displayError.current && inWidth === undefined && width === 0) {
66
- console.error(`MUI X Charts: ChartContainer does not have \`width\` prop, and its container has no \`width\` defined.`);
66
+ console.error(`MUI X: ChartContainer does not have \`width\` prop, and its container has no \`width\` defined.`);
67
67
  displayError.current = false;
68
68
  }
69
69
  if (displayError.current && inHeight === undefined && height === 0) {
70
- console.error(`MUI X Charts: ChartContainer does not have \`height\` prop, and its container has no \`height\` defined.`);
70
+ console.error(`MUI X: ChartContainer does not have \`height\` prop, and its container has no \`height\` defined.`);
71
71
  displayError.current = false;
72
72
  }
73
73
  }
@@ -50,7 +50,10 @@ const ScatterChart = exports.ScatterChart = /*#__PURE__*/React.forwardRef(functi
50
50
  ref: ref
51
51
  }, chartContainerProps, {
52
52
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ZAxisContextProvider.ZAxisContextProvider, (0, _extends2.default)({}, zAxisProps, {
53
- children: [!props.disableVoronoi && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsVoronoiHandler.ChartsVoronoiHandler, (0, _extends2.default)({}, voronoiHandlerProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxis.ChartsAxis, (0, _extends2.default)({}, chartsAxisProps)), props.grid && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsGrid.ChartsGrid, (0, _extends2.default)({}, gridProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScatterPlot.ScatterPlot, (0, _extends2.default)({}, scatterPlotProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsOverlay.ChartsOverlay, (0, _extends2.default)({}, overlayProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsLegend.ChartsLegend, (0, _extends2.default)({}, legendProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxisHighlight.ChartsAxisHighlight, (0, _extends2.default)({}, axisHighlightProps)), !props.loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsTooltip.ChartsTooltip, (0, _extends2.default)({}, tooltipProps)), children]
53
+ children: [!props.disableVoronoi && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsVoronoiHandler.ChartsVoronoiHandler, (0, _extends2.default)({}, voronoiHandlerProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxis.ChartsAxis, (0, _extends2.default)({}, chartsAxisProps)), props.grid && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsGrid.ChartsGrid, (0, _extends2.default)({}, gridProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {
54
+ "data-drawing-container": true,
55
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScatterPlot.ScatterPlot, (0, _extends2.default)({}, scatterPlotProps))
56
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsOverlay.ChartsOverlay, (0, _extends2.default)({}, overlayProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsLegend.ChartsLegend, (0, _extends2.default)({}, legendProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxisHighlight.ChartsAxisHighlight, (0, _extends2.default)({}, axisHighlightProps)), !props.loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsTooltip.ChartsTooltip, (0, _extends2.default)({}, tooltipProps)), children]
54
57
  }))
55
58
  }));
56
59
  });
@@ -62,12 +62,15 @@ function ScatterPlot(props) {
62
62
  xAxisKey,
63
63
  yAxisKey,
64
64
  zAxisKey,
65
+ xAxisId,
66
+ yAxisId,
67
+ zAxisId,
65
68
  markerSize,
66
69
  color
67
70
  } = series[seriesId];
68
- const colorGetter = (0, _getColor.default)(series[seriesId], xAxis[xAxisKey ?? defaultXAxisId], yAxis[yAxisKey ?? defaultYAxisId], zAxis[zAxisKey ?? defaultZAxisId]);
69
- const xScale = xAxis[xAxisKey ?? defaultXAxisId].scale;
70
- const yScale = yAxis[yAxisKey ?? defaultYAxisId].scale;
71
+ const colorGetter = (0, _getColor.default)(series[seriesId], xAxis[xAxisId ?? xAxisKey ?? defaultXAxisId], yAxis[yAxisId ?? yAxisKey ?? defaultYAxisId], zAxis[zAxisId ?? zAxisKey ?? defaultZAxisId]);
72
+ const xScale = xAxis[xAxisId ?? xAxisKey ?? defaultXAxisId].scale;
73
+ const yScale = yAxis[yAxisId ?? yAxisKey ?? defaultYAxisId].scale;
71
74
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(ScatterItems, (0, _extends2.default)({
72
75
  xScale: xScale,
73
76
  yScale: yScale,
@@ -19,7 +19,10 @@ const getExtremumX = params => {
19
19
  axis,
20
20
  isDefaultAxis
21
21
  } = params;
22
- return Object.keys(series).filter(seriesId => series[seriesId].xAxisKey === axis.id || series[seriesId].xAxisKey === undefined && isDefaultAxis).reduce((acc, seriesId) => {
22
+ return Object.keys(series).filter(seriesId => {
23
+ const axisId = series[seriesId].xAxisId ?? series[seriesId].xAxisKey;
24
+ return axisId === axis.id || axisId === undefined && isDefaultAxis;
25
+ }).reduce((acc, seriesId) => {
23
26
  const seriesMinMax = series[seriesId].data.reduce((accSeries, {
24
27
  x
25
28
  }) => {
@@ -36,7 +39,10 @@ const getExtremumY = params => {
36
39
  axis,
37
40
  isDefaultAxis
38
41
  } = params;
39
- return Object.keys(series).filter(seriesId => series[seriesId].yAxisKey === axis.id || series[seriesId].yAxisKey === undefined && isDefaultAxis).reduce((acc, seriesId) => {
42
+ return Object.keys(series).filter(seriesId => {
43
+ const axisId = series[seriesId].yAxisId ?? series[seriesId].yAxisKey;
44
+ return axisId === axis.id || axisId === undefined && isDefaultAxis;
45
+ }).reduce((acc, seriesId) => {
40
46
  const seriesMinMax = series[seriesId].data.reduce((accSeries, {
41
47
  y
42
48
  }) => {
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import { Initializable } from '../context.types';
3
3
  import { AxisDefaultized, ScaleName, ChartsXAxisProps, ChartsYAxisProps, AxisId } from '../../models/axis';
4
4
  export type DefaultizedAxisConfig<AxisProps> = {
5
- [axisKey: AxisId]: AxisDefaultized<ScaleName, any, AxisProps>;
5
+ [axisId: AxisId]: AxisDefaultized<ScaleName, any, AxisProps>;
6
6
  };
7
7
  export type CartesianContextState = {
8
8
  /**
@@ -13,7 +13,7 @@ const normalizeAxis = (axis, dataset, axisName) => {
13
13
  return axisConfig;
14
14
  }
15
15
  if (dataset === undefined) {
16
- throw Error(`MUI X Charts: ${axisName}-axis uses \`dataKey\` but no \`dataset\` is provided.`);
16
+ throw Error(`MUI X: ${axisName}-axis uses \`dataKey\` but no \`dataset\` is provided.`);
17
17
  }
18
18
  return (0, _extends2.default)({}, axisConfig, {
19
19
  data: dataset.map(d => d[dataKey])
@@ -38,12 +38,13 @@ export type DrawingArea = {
38
38
  * @param {Object} point The point to check.
39
39
  * @param {number} point.x The x coordinate of the point.
40
40
  * @param {number} point.y The y coordinate of the point.
41
+ * @param {Element} targetElement The target element if relevant.
41
42
  * @returns {boolean} `true` if the point is inside the drawing area, `false` otherwise.
42
43
  */
43
44
  isPointInside: (point: {
44
45
  x: number;
45
46
  y: number;
46
- }) => boolean;
47
+ }, targetElement?: Element) => boolean;
47
48
  };
48
49
  export declare const DrawingContext: React.Context<DrawingArea & {
49
50
  /**
@@ -53,7 +53,13 @@ function DrawingProvider(props) {
53
53
  const isPointInside = React.useCallback(({
54
54
  x,
55
55
  y
56
- }) => x >= drawingArea.left && x <= drawingArea.left + drawingArea.width && y >= drawingArea.top && y <= drawingArea.top + drawingArea.height, [drawingArea]);
56
+ }, targetElement) => {
57
+ // For element allowed to overflow, wrapping them in <g data-drawing-container /> make them fully part of the drawing area.
58
+ if (targetElement && targetElement.closest('[data-drawing-container]')) {
59
+ return true;
60
+ }
61
+ return x >= drawingArea.left && x <= drawingArea.left + drawingArea.width && y >= drawingArea.top && y <= drawingArea.top + drawingArea.height;
62
+ }, [drawingArea]);
57
63
  const value = React.useMemo(() => (0, _extends2.default)({
58
64
  chartId: chartId ?? ''
59
65
  }, drawingArea, {
@@ -44,7 +44,7 @@ const preprocessSeries = (series, colors, seriesFormatters, dataset) => {
44
44
  };
45
45
  }
46
46
  if (seriesGroups[type]?.series[id] !== undefined) {
47
- throw new Error(`MUI X Charts: series' id "${id}" is not unique.`);
47
+ throw new Error(`MUI X: series' id "${id}" is not unique.`);
48
48
  }
49
49
  seriesGroups[type].series[id] = (0, _extends2.default)({
50
50
  id
@@ -14,7 +14,7 @@ export type ZAxisContextProviderProps = {
14
14
  children: React.ReactNode;
15
15
  };
16
16
  type DefaultizedZAxisConfig = {
17
- [axisKey: string]: ZAxisDefaultized;
17
+ [axisId: string]: ZAxisDefaultized;
18
18
  };
19
19
  export declare const ZAxisContext: React.Context<{
20
20
  /**
@@ -32,7 +32,7 @@ function ZAxisContextProvider(props) {
32
32
  return axisConfig;
33
33
  }
34
34
  if (dataset === undefined) {
35
- throw Error('MUI X Charts: z-axis uses `dataKey` but no `dataset` is provided.');
35
+ throw Error('MUI X: z-axis uses `dataKey` but no `dataset` is provided.');
36
36
  }
37
37
  return (0, _extends2.default)({}, axisConfig, {
38
38
  data: dataset.map(d => d[dataKey])
@@ -66,16 +66,16 @@ const useAggregatedData = () => {
66
66
  ids: groupIds
67
67
  }, groupIndex) => {
68
68
  return groupIds.flatMap(seriesId => {
69
- const xAxisKey = series[seriesId].xAxisKey ?? defaultXAxisId;
70
- const yAxisKey = series[seriesId].yAxisKey ?? defaultYAxisId;
71
- const xAxisConfig = xAxis[xAxisKey];
72
- const yAxisConfig = yAxis[yAxisKey];
69
+ const xAxisId = series[seriesId].xAxisId ?? series[seriesId].xAxisKey ?? defaultXAxisId;
70
+ const yAxisId = series[seriesId].yAxisId ?? series[seriesId].yAxisKey ?? defaultYAxisId;
71
+ const xAxisConfig = xAxis[xAxisId];
72
+ const yAxisConfig = yAxis[yAxisId];
73
73
  const verticalLayout = series[seriesId].layout === 'vertical';
74
- checkScaleErrors(verticalLayout, seriesId, xAxisKey, xAxis, yAxisKey, yAxis);
74
+ checkScaleErrors(verticalLayout, seriesId, xAxisId, xAxis, yAxisId, yAxis);
75
75
  const baseScaleConfig = verticalLayout ? xAxisConfig : yAxisConfig;
76
76
  const xScale = xAxisConfig.scale;
77
77
  const yScale = yAxisConfig.scale;
78
- const colorGetter = getColor(series[seriesId], xAxis[xAxisKey], yAxis[yAxisKey]);
78
+ const colorGetter = getColor(series[seriesId], xAxis[xAxisId], yAxis[yAxisId]);
79
79
  const bandWidth = baseScaleConfig.scale.bandwidth();
80
80
  const {
81
81
  barWidth,
@@ -98,8 +98,8 @@ const useAggregatedData = () => {
98
98
  seriesId,
99
99
  dataIndex,
100
100
  layout: series[seriesId].layout,
101
- x: verticalLayout ? xScale(xAxis[xAxisKey].data?.[dataIndex]) + barOffset : minValueCoord,
102
- y: verticalLayout ? minValueCoord : yScale(yAxis[yAxisKey].data?.[dataIndex]) + barOffset,
101
+ x: verticalLayout ? xScale(xAxis[xAxisId].data?.[dataIndex]) + barOffset : minValueCoord,
102
+ y: verticalLayout ? minValueCoord : yScale(yAxis[yAxisId].data?.[dataIndex]) + barOffset,
103
103
  xOrigin: xScale(0),
104
104
  yOrigin: yScale(0),
105
105
  height: verticalLayout ? maxValueCoord - minValueCoord : barWidth,
@@ -1,27 +1,27 @@
1
1
  import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from '../constants';
2
2
  import { isBandScaleConfig, isPointScaleConfig } from '../models/axis';
3
- const getAxisMessage = (axisDirection, axisKey) => {
3
+ const getAxisMessage = (axisDirection, axisId) => {
4
4
  const axisName = `${axisDirection}-axis`;
5
- const axisKeyName = `${axisDirection}Axis`;
5
+ const axisIdName = `${axisDirection}Axis`;
6
6
  const axisDefaultKey = axisDirection === 'x' ? DEFAULT_X_AXIS_KEY : DEFAULT_Y_AXIS_KEY;
7
- return axisKey === axisDefaultKey ? `The first \`${axisKeyName}\`` : `The ${axisName} with id "${axisKey}"`;
7
+ return axisId === axisDefaultKey ? `The first \`${axisIdName}\`` : `The ${axisName} with id "${axisId}"`;
8
8
  };
9
- export function checkScaleErrors(verticalLayout, seriesId, xAxisKey, xAxis, yAxisKey, yAxis) {
10
- const xAxisConfig = xAxis[xAxisKey];
11
- const yAxisConfig = yAxis[yAxisKey];
9
+ export function checkScaleErrors(verticalLayout, seriesId, xAxisId, xAxis, yAxisId, yAxis) {
10
+ const xAxisConfig = xAxis[xAxisId];
11
+ const yAxisConfig = yAxis[yAxisId];
12
12
  const discreteAxisConfig = verticalLayout ? xAxisConfig : yAxisConfig;
13
13
  const continuousAxisConfig = verticalLayout ? yAxisConfig : xAxisConfig;
14
- const discreteAxisKey = verticalLayout ? xAxisKey : yAxisKey;
15
- const continuousAxisKey = verticalLayout ? yAxisKey : xAxisKey;
14
+ const discreteAxisId = verticalLayout ? xAxisId : yAxisId;
15
+ const continuousAxisId = verticalLayout ? yAxisId : xAxisId;
16
16
  const discreteAxisDirection = verticalLayout ? 'x' : 'y';
17
17
  const continuousAxisDirection = verticalLayout ? 'y' : 'x';
18
18
  if (!isBandScaleConfig(discreteAxisConfig)) {
19
- throw new Error(`MUI X Charts: ${getAxisMessage(discreteAxisDirection, discreteAxisKey)} should be of type "band" to display the bar series of id "${seriesId}".`);
19
+ throw new Error(`MUI X: ${getAxisMessage(discreteAxisDirection, discreteAxisId)} should be of type "band" to display the bar series of id "${seriesId}".`);
20
20
  }
21
21
  if (discreteAxisConfig.data === undefined) {
22
- throw new Error(`MUI X Charts: ${getAxisMessage(discreteAxisDirection, discreteAxisKey)} should have data property.`);
22
+ throw new Error(`MUI X: ${getAxisMessage(discreteAxisDirection, discreteAxisId)} should have data property.`);
23
23
  }
24
24
  if (isBandScaleConfig(continuousAxisConfig) || isPointScaleConfig(continuousAxisConfig)) {
25
- throw new Error(`MUI X Charts: ${getAxisMessage(continuousAxisDirection, continuousAxisKey)} should be a continuous type to display the bar series of id "${seriesId}".`);
25
+ throw new Error(`MUI X: ${getAxisMessage(continuousAxisDirection, continuousAxisId)} should be a continuous type to display the bar series of id "${seriesId}".`);
26
26
  }
27
27
  }
@@ -12,7 +12,10 @@ const getValueExtremum = params => {
12
12
  axis,
13
13
  isDefaultAxis
14
14
  } = params;
15
- return Object.keys(series).filter(seriesId => series[seriesId].yAxisKey === axis.id || isDefaultAxis && series[seriesId].yAxisKey === undefined).reduce((acc, seriesId) => {
15
+ return Object.keys(series).filter(seriesId => {
16
+ const yAxisId = series[seriesId].yAxisId ?? series[seriesId].yAxisKey;
17
+ return yAxisId === axis.id || isDefaultAxis && yAxisId === undefined;
18
+ }).reduce((acc, seriesId) => {
16
19
  const [seriesMin, seriesMax] = series[seriesId].stackedData?.reduce((seriesAcc, values) => [Math.min(...values, ...(seriesAcc[0] === null ? [] : [seriesAcc[0]])), Math.max(...values, ...(seriesAcc[1] === null ? [] : [seriesAcc[1]]))], series[seriesId].stackedData[0]) ?? [null, null];
17
20
  return [acc[0] === null ? seriesMin : Math.min(seriesMin, acc[0]), acc[1] === null ? seriesMax : Math.max(seriesMax, acc[1])];
18
21
  }, [null, null]);
@@ -25,7 +25,7 @@ const formatter = (params, dataset) => {
25
25
  }
26
26
  });
27
27
  } else if (dataset === undefined) {
28
- throw new Error([`MUI X Charts: bar series with id='${id}' has no data.`, 'Either provide a data property to the series or use the dataset prop.'].join('\n'));
28
+ throw new Error([`MUI X: bar series with id='${id}' has no data.`, 'Either provide a data property to the series or use the dataset prop.'].join('\n'));
29
29
  }
30
30
  });
31
31
  const completedSeries = {};
@@ -52,7 +52,7 @@ const formatter = (params, dataset) => {
52
52
  if (typeof value !== 'number') {
53
53
  if (process.env.NODE_ENV !== 'production' && !warnOnce && value !== null) {
54
54
  warnOnce = true;
55
- console.error([`MUI X charts: your dataset key "${dataKey}" is used for plotting bars, but contains nonnumerical elements.`, 'Bar plots only support numbers and null values.']);
55
+ console.error([`MUI X charts: your dataset key "${dataKey}" is used for plotting bars, but contains nonnumerical elements.`, 'Bar plots only support numbers and null values.'].join('\n'));
56
56
  }
57
57
  return 0;
58
58
  }
@@ -57,16 +57,16 @@ function ChartsAxis(props) {
57
57
  const topId = getAxisId(topAxis, xAxisIds[0]);
58
58
  const rightId = getAxisId(rightAxis, yAxisIds[0]);
59
59
  if (topId !== null && !xAxis[topId]) {
60
- throw Error([`MUI X Charts: id used for top axis "${topId}" is not defined.`, `Available ids are: ${xAxisIds.join(', ')}.`].join('\n'));
60
+ throw Error([`MUI X: id used for top axis "${topId}" is not defined.`, `Available ids are: ${xAxisIds.join(', ')}.`].join('\n'));
61
61
  }
62
62
  if (leftId !== null && !yAxis[leftId]) {
63
- throw Error([`MUI X Charts: id used for left axis "${leftId}" is not defined.`, `Available ids are: ${yAxisIds.join(', ')}.`].join('\n'));
63
+ throw Error([`MUI X: id used for left axis "${leftId}" is not defined.`, `Available ids are: ${yAxisIds.join(', ')}.`].join('\n'));
64
64
  }
65
65
  if (rightId !== null && !yAxis[rightId]) {
66
- throw Error([`MUI X Charts: id used for right axis "${rightId}" is not defined.`, `Available ids are: ${yAxisIds.join(', ')}.`].join('\n'));
66
+ throw Error([`MUI X: id used for right axis "${rightId}" is not defined.`, `Available ids are: ${yAxisIds.join(', ')}.`].join('\n'));
67
67
  }
68
68
  if (bottomId !== null && !xAxis[bottomId]) {
69
- throw Error([`MUI X Charts: id used for bottom axis "${bottomId}" is not defined.`, `Available ids are: ${xAxisIds.join(', ')}.`].join('\n'));
69
+ throw Error([`MUI X: id used for bottom axis "${bottomId}" is not defined.`, `Available ids are: ${xAxisIds.join(', ')}.`].join('\n'));
70
70
  }
71
71
  const topAxisProps = mergeProps(topAxis, slots, slotProps);
72
72
  const bottomAxisProps = mergeProps(bottomAxis, slots, slotProps);
@@ -74,7 +74,7 @@ function ChartsAxisHighlight(props) {
74
74
  const isXError = isBandScaleX && xScale(axisX.value) === undefined;
75
75
  const isYError = isBandScaleY && yScale(axisY.value) === undefined;
76
76
  if (isXError || isYError) {
77
- console.error([`MUI X Charts: The position value provided for the axis is not valid for the current scale.`, `This probably means something is wrong with the data passed to the chart.`, `The ChartsAxisHighlight component will not be displayed.`].join('\n'));
77
+ console.error([`MUI X: The position value provided for the axis is not valid for the current scale.`, `This probably means something is wrong with the data passed to the chart.`, `The ChartsAxisHighlight component will not be displayed.`].join('\n'));
78
78
  }
79
79
  }
80
80
  return /*#__PURE__*/_jsxs(React.Fragment, {
@@ -37,7 +37,9 @@ function ChartsOnAxisClickHandler(props) {
37
37
  Object.keys(series).filter(seriesType => ['bar', 'line'].includes(seriesType)).forEach(seriesType => {
38
38
  series[seriesType]?.seriesOrder.forEach(seriesId => {
39
39
  const seriesItem = series[seriesType].series[seriesId];
40
- const axisKey = isXaxis ? seriesItem.xAxisKey : seriesItem.yAxisKey;
40
+ const providedXAxisId = seriesItem.xAxisId ?? seriesItem.xAxisKey;
41
+ const providedYAxisId = seriesItem.yAxisId ?? seriesItem.yAxisKey;
42
+ const axisKey = isXaxis ? providedXAxisId : providedYAxisId;
41
43
  if (axisKey === undefined || axisKey === USED_AXIS_ID) {
42
44
  seriesValues[seriesId] = seriesItem.data[dataIndex];
43
45
  }
@@ -10,10 +10,10 @@ function ChartsReferenceLine(props) {
10
10
  y
11
11
  } = props;
12
12
  if (x !== undefined && y !== undefined) {
13
- throw new Error('MUI X Charts: The ChartsReferenceLine cannot have both `x` and `y` props set.');
13
+ throw new Error('MUI X: The ChartsReferenceLine cannot have both `x` and `y` props set.');
14
14
  }
15
15
  if (x === undefined && y === undefined) {
16
- throw new Error('MUI X Charts: The ChartsReferenceLine should have a value in `x` or `y` prop.');
16
+ throw new Error('MUI X: The ChartsReferenceLine should have a value in `x` or `y` prop.');
17
17
  }
18
18
  if (x !== undefined) {
19
19
  return /*#__PURE__*/_jsx(ChartsXReferenceLine, _extends({}, props));
@@ -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
  }
@@ -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,
@@ -63,11 +63,13 @@ function ChartsVoronoiHandler(props) {
63
63
  seriesOrder.forEach(seriesId => {
64
64
  const {
65
65
  data,
66
+ xAxisId,
67
+ yAxisId,
66
68
  xAxisKey,
67
69
  yAxisKey
68
70
  } = series[seriesId];
69
- const xScale = xAxis[xAxisKey ?? defaultXAxisId].scale;
70
- const yScale = yAxis[yAxisKey ?? defaultYAxisId].scale;
71
+ const xScale = xAxis[xAxisId ?? xAxisKey ?? defaultXAxisId].scale;
72
+ const yScale = yAxis[yAxisId ?? yAxisKey ?? defaultYAxisId].scale;
71
73
  const getXPosition = getValueToPositionMapper(xScale);
72
74
  const getYPosition = getValueToPositionMapper(yScale);
73
75
  const seriesPoints = data.flatMap(({
@@ -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 => {
@@ -49,7 +49,10 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, 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
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(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]
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 = {
@@ -60,20 +60,24 @@ function LineHighlightPlot(props) {
60
60
  }) => {
61
61
  return groupIds.flatMap(seriesId => {
62
62
  const {
63
+ xAxisId: xAxisIdProp,
64
+ yAxisId: yAxisIdProp,
63
65
  xAxisKey = defaultXAxisId,
64
66
  yAxisKey = defaultYAxisId,
65
67
  stackedData,
66
68
  data,
67
69
  disableHighlight
68
70
  } = series[seriesId];
71
+ const xAxisId = xAxisIdProp ?? xAxisKey;
72
+ const yAxisId = yAxisIdProp ?? yAxisKey;
69
73
  if (disableHighlight || data[highlightedIndex] == null) {
70
74
  return null;
71
75
  }
72
- const xScale = getValueToPositionMapper(xAxis[xAxisKey].scale);
73
- const yScale = yAxis[yAxisKey].scale;
74
- const xData = xAxis[xAxisKey].data;
76
+ const xScale = getValueToPositionMapper(xAxis[xAxisId].scale);
77
+ const yScale = yAxis[yAxisId].scale;
78
+ const xData = xAxis[xAxisId].data;
75
79
  if (xData === undefined) {
76
- 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.`);
77
81
  }
78
82
  const x = xScale(xData[highlightedIndex]);
79
83
  const y = yScale(stackedData[highlightedIndex][1]); // This should not be undefined since y should not be a band scale
@@ -84,7 +88,7 @@ function LineHighlightPlot(props) {
84
88
  })) {
85
89
  return null;
86
90
  }
87
- const colorGetter = getColor(series[seriesId], xAxis[xAxisKey], yAxis[yAxisKey]);
91
+ const colorGetter = getColor(series[seriesId], xAxis[xAxisId], yAxis[yAxisId]);
88
92
  return /*#__PURE__*/_jsx(Element, _extends({
89
93
  id: seriesId,
90
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]));
@@ -57,6 +57,8 @@ function MarkPlot(props) {
57
57
  }) => {
58
58
  return groupIds.map(seriesId => {
59
59
  const {
60
+ xAxisId: xAxisIdProp,
61
+ yAxisId: yAxisIdProp,
60
62
  xAxisKey = defaultXAxisId,
61
63
  yAxisKey = defaultYAxisId,
62
64
  stackedData,
@@ -66,15 +68,17 @@ function MarkPlot(props) {
66
68
  if (showMark === false) {
67
69
  return null;
68
70
  }
69
- const xScale = getValueToPositionMapper(xAxis[xAxisKey].scale);
70
- const yScale = yAxis[yAxisKey].scale;
71
- const xData = xAxis[xAxisKey].data;
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;
72
76
  if (xData === undefined) {
73
- 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.`);
74
78
  }
75
79
  const clipId = cleanId(`${chartId}-${seriesId}-line-clip`); // We assume that if displaying line mark, the line will also be rendered
76
80
 
77
- const colorGetter = getColor(series[seriesId], xAxis[xAxisKey], yAxis[yAxisKey]);
81
+ const colorGetter = getColor(series[seriesId], xAxis[xAxisId], yAxis[yAxisId]);
78
82
  return /*#__PURE__*/_jsx("g", {
79
83
  clipPath: `url(#${clipId})`,
80
84
  children: xData?.map((x, index) => {