@mui/x-charts 7.6.2 → 7.7.0

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 (92) hide show
  1. package/BarChart/BarChart.d.ts +1 -1
  2. package/CHANGELOG.md +81 -0
  3. package/ChartContainer/ChartContainer.d.ts +3 -3
  4. package/ChartContainer/ChartContainer.js +59 -22
  5. package/ChartsOverlay/index.d.ts +1 -0
  6. package/ChartsReferenceLine/ChartsXReferenceLine.js +3 -5
  7. package/ChartsReferenceLine/ChartsYReferenceLine.js +3 -5
  8. package/ChartsText/ChartsText.js +1 -3
  9. package/ChartsTooltip/ChartsAxisTooltipContent.js +6 -12
  10. package/ChartsTooltip/ChartsItemTooltipContent.js +6 -16
  11. package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +3 -3
  12. package/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
  13. package/LineChart/LineChart.d.ts +2 -2
  14. package/LineChart/LineChart.js +1 -1
  15. package/PieChart/PieChart.d.ts +2 -2
  16. package/PieChart/PieChart.js +1 -1
  17. package/ResponsiveChartContainer/ResizableContainer.d.ts +10 -0
  18. package/ResponsiveChartContainer/ResizableContainer.js +32 -0
  19. package/ResponsiveChartContainer/ResponsiveChartContainer.js +25 -22
  20. package/ScatterChart/ScatterChart.d.ts +1 -1
  21. package/ScatterChart/ScatterChart.js +1 -1
  22. package/SparkLineChart/SparkLineChart.d.ts +8 -3
  23. package/SparkLineChart/SparkLineChart.js +57 -1
  24. package/context/CartesianContextProvider.d.ts +8 -0
  25. package/context/CartesianContextProvider.js +5 -18
  26. package/context/ColorProvider.d.ts +12 -0
  27. package/context/ColorProvider.js +25 -0
  28. package/esm/ChartContainer/ChartContainer.js +60 -23
  29. package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +3 -5
  30. package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +3 -5
  31. package/esm/ChartsText/ChartsText.js +1 -3
  32. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +6 -12
  33. package/esm/ChartsTooltip/ChartsItemTooltipContent.js +6 -16
  34. package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +3 -3
  35. package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
  36. package/esm/LineChart/LineChart.js +1 -1
  37. package/esm/PieChart/PieChart.js +1 -1
  38. package/esm/ResponsiveChartContainer/ResizableContainer.js +26 -0
  39. package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +24 -21
  40. package/esm/ScatterChart/ScatterChart.js +1 -1
  41. package/esm/SparkLineChart/SparkLineChart.js +57 -1
  42. package/esm/context/CartesianContextProvider.js +5 -18
  43. package/esm/context/ColorProvider.js +16 -0
  44. package/esm/hooks/index.js +1 -0
  45. package/esm/hooks/useColor.js +9 -0
  46. package/esm/hooks/useColorScale.js +27 -0
  47. package/esm/hooks/useReducedMotion.js +7 -0
  48. package/esm/internals/index.js +27 -1
  49. package/esm/internals/warning.js +13 -0
  50. package/hooks/index.d.ts +1 -0
  51. package/hooks/index.js +12 -0
  52. package/hooks/useColor.d.ts +4 -0
  53. package/hooks/useColor.js +17 -0
  54. package/hooks/useColorScale.d.ts +4 -0
  55. package/hooks/useColorScale.js +37 -0
  56. package/hooks/useReducedMotion.js +7 -0
  57. package/index.js +1 -1
  58. package/internals/defaultizeColor.d.ts +8 -8
  59. package/internals/index.d.ts +16 -0
  60. package/internals/index.js +187 -0
  61. package/internals/warning.d.ts +1 -0
  62. package/internals/warning.js +19 -0
  63. package/models/axis.d.ts +1 -2
  64. package/modern/ChartContainer/ChartContainer.js +60 -23
  65. package/modern/ChartsReferenceLine/ChartsXReferenceLine.js +3 -5
  66. package/modern/ChartsReferenceLine/ChartsYReferenceLine.js +3 -5
  67. package/modern/ChartsText/ChartsText.js +1 -3
  68. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +6 -12
  69. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +6 -16
  70. package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +3 -3
  71. package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
  72. package/modern/LineChart/LineChart.js +1 -1
  73. package/modern/PieChart/PieChart.js +1 -1
  74. package/modern/ResponsiveChartContainer/ResizableContainer.js +26 -0
  75. package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +24 -21
  76. package/modern/ScatterChart/ScatterChart.js +1 -1
  77. package/modern/SparkLineChart/SparkLineChart.js +57 -1
  78. package/modern/context/CartesianContextProvider.js +5 -18
  79. package/modern/context/ColorProvider.js +16 -0
  80. package/modern/hooks/index.js +1 -0
  81. package/modern/hooks/useColor.js +9 -0
  82. package/modern/hooks/useColorScale.js +27 -0
  83. package/modern/hooks/useReducedMotion.js +7 -0
  84. package/modern/index.js +1 -1
  85. package/modern/internals/index.js +27 -1
  86. package/modern/internals/warning.js +13 -0
  87. package/package.json +2 -2
  88. package/themeAugmentation/components.d.ts +12 -12
  89. package/esm/internals/colorGetter.js +0 -22
  90. package/internals/colorGetter.d.ts +0 -7
  91. package/internals/colorGetter.js +0 -29
  92. package/modern/internals/colorGetter.js +0 -22
@@ -3,9 +3,76 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ var _exportNames = {
7
+ useReducedMotion: true,
8
+ useSeries: true
9
+ };
10
+ Object.defineProperty(exports, "useReducedMotion", {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _useReducedMotion.useReducedMotion;
14
+ }
15
+ });
16
+ Object.defineProperty(exports, "useSeries", {
17
+ enumerable: true,
18
+ get: function () {
19
+ return _useSeries.useSeries;
20
+ }
21
+ });
22
+ var _ChartsAxesGradients = require("./components/ChartsAxesGradients");
23
+ Object.keys(_ChartsAxesGradients).forEach(function (key) {
24
+ if (key === "default" || key === "__esModule") return;
25
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
26
+ if (key in exports && exports[key] === _ChartsAxesGradients[key]) return;
27
+ Object.defineProperty(exports, key, {
28
+ enumerable: true,
29
+ get: function () {
30
+ return _ChartsAxesGradients[key];
31
+ }
32
+ });
33
+ });
34
+ var _useChartContainerDimensions = require("../ResponsiveChartContainer/useChartContainerDimensions");
35
+ Object.keys(_useChartContainerDimensions).forEach(function (key) {
36
+ if (key === "default" || key === "__esModule") return;
37
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
38
+ if (key in exports && exports[key] === _useChartContainerDimensions[key]) return;
39
+ Object.defineProperty(exports, key, {
40
+ enumerable: true,
41
+ get: function () {
42
+ return _useChartContainerDimensions[key];
43
+ }
44
+ });
45
+ });
46
+ var _ResizableContainer = require("../ResponsiveChartContainer/ResizableContainer");
47
+ Object.keys(_ResizableContainer).forEach(function (key) {
48
+ if (key === "default" || key === "__esModule") return;
49
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
50
+ if (key in exports && exports[key] === _ResizableContainer[key]) return;
51
+ Object.defineProperty(exports, key, {
52
+ enumerable: true,
53
+ get: function () {
54
+ return _ResizableContainer[key];
55
+ }
56
+ });
57
+ });
58
+ var _useReducedMotion = require("../hooks/useReducedMotion");
59
+ var _useSeries = require("../hooks/useSeries");
60
+ var _defaultizeValueFormatter = require("./defaultizeValueFormatter");
61
+ Object.keys(_defaultizeValueFormatter).forEach(function (key) {
62
+ if (key === "default" || key === "__esModule") return;
63
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
64
+ if (key in exports && exports[key] === _defaultizeValueFormatter[key]) return;
65
+ Object.defineProperty(exports, key, {
66
+ enumerable: true,
67
+ get: function () {
68
+ return _defaultizeValueFormatter[key];
69
+ }
70
+ });
71
+ });
6
72
  var _configInit = require("./configInit");
7
73
  Object.keys(_configInit).forEach(function (key) {
8
74
  if (key === "default" || key === "__esModule") return;
75
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
9
76
  if (key in exports && exports[key] === _configInit[key]) return;
10
77
  Object.defineProperty(exports, key, {
11
78
  enumerable: true,
@@ -13,4 +80,124 @@ Object.keys(_configInit).forEach(function (key) {
13
80
  return _configInit[key];
14
81
  }
15
82
  });
83
+ });
84
+ var _CartesianContextProvider = require("../context/CartesianContextProvider");
85
+ Object.keys(_CartesianContextProvider).forEach(function (key) {
86
+ if (key === "default" || key === "__esModule") return;
87
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
88
+ if (key in exports && exports[key] === _CartesianContextProvider[key]) return;
89
+ Object.defineProperty(exports, key, {
90
+ enumerable: true,
91
+ get: function () {
92
+ return _CartesianContextProvider[key];
93
+ }
94
+ });
95
+ });
96
+ var _DrawingProvider = require("../context/DrawingProvider");
97
+ Object.keys(_DrawingProvider).forEach(function (key) {
98
+ if (key === "default" || key === "__esModule") return;
99
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
100
+ if (key in exports && exports[key] === _DrawingProvider[key]) return;
101
+ Object.defineProperty(exports, key, {
102
+ enumerable: true,
103
+ get: function () {
104
+ return _DrawingProvider[key];
105
+ }
106
+ });
107
+ });
108
+ var _InteractionProvider = require("../context/InteractionProvider");
109
+ Object.keys(_InteractionProvider).forEach(function (key) {
110
+ if (key === "default" || key === "__esModule") return;
111
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
112
+ if (key in exports && exports[key] === _InteractionProvider[key]) return;
113
+ Object.defineProperty(exports, key, {
114
+ enumerable: true,
115
+ get: function () {
116
+ return _InteractionProvider[key];
117
+ }
118
+ });
119
+ });
120
+ var _SeriesContextProvider = require("../context/SeriesContextProvider");
121
+ Object.keys(_SeriesContextProvider).forEach(function (key) {
122
+ if (key === "default" || key === "__esModule") return;
123
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
124
+ if (key in exports && exports[key] === _SeriesContextProvider[key]) return;
125
+ Object.defineProperty(exports, key, {
126
+ enumerable: true,
127
+ get: function () {
128
+ return _SeriesContextProvider[key];
129
+ }
130
+ });
131
+ });
132
+ var _ZAxisContextProvider = require("../context/ZAxisContextProvider");
133
+ Object.keys(_ZAxisContextProvider).forEach(function (key) {
134
+ if (key === "default" || key === "__esModule") return;
135
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
136
+ if (key in exports && exports[key] === _ZAxisContextProvider[key]) return;
137
+ Object.defineProperty(exports, key, {
138
+ enumerable: true,
139
+ get: function () {
140
+ return _ZAxisContextProvider[key];
141
+ }
142
+ });
143
+ });
144
+ var _config = require("../models/seriesType/config");
145
+ Object.keys(_config).forEach(function (key) {
146
+ if (key === "default" || key === "__esModule") return;
147
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
148
+ if (key in exports && exports[key] === _config[key]) return;
149
+ Object.defineProperty(exports, key, {
150
+ enumerable: true,
151
+ get: function () {
152
+ return _config[key];
153
+ }
154
+ });
155
+ });
156
+ var _common = require("../models/seriesType/common");
157
+ Object.keys(_common).forEach(function (key) {
158
+ if (key === "default" || key === "__esModule") return;
159
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
160
+ if (key in exports && exports[key] === _common[key]) return;
161
+ Object.defineProperty(exports, key, {
162
+ enumerable: true,
163
+ get: function () {
164
+ return _common[key];
165
+ }
166
+ });
167
+ });
168
+ var _helpers = require("../models/helpers");
169
+ Object.keys(_helpers).forEach(function (key) {
170
+ if (key === "default" || key === "__esModule") return;
171
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
172
+ if (key in exports && exports[key] === _helpers[key]) return;
173
+ Object.defineProperty(exports, key, {
174
+ enumerable: true,
175
+ get: function () {
176
+ return _helpers[key];
177
+ }
178
+ });
179
+ });
180
+ var _zAxis = require("../models/z-axis");
181
+ Object.keys(_zAxis).forEach(function (key) {
182
+ if (key === "default" || key === "__esModule") return;
183
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
184
+ if (key in exports && exports[key] === _zAxis[key]) return;
185
+ Object.defineProperty(exports, key, {
186
+ enumerable: true,
187
+ get: function () {
188
+ return _zAxis[key];
189
+ }
190
+ });
191
+ });
192
+ var _axis = require("../models/axis");
193
+ Object.keys(_axis).forEach(function (key) {
194
+ if (key === "default" || key === "__esModule") return;
195
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
196
+ if (key in exports && exports[key] === _axis[key]) return;
197
+ Object.defineProperty(exports, key, {
198
+ enumerable: true,
199
+ get: function () {
200
+ return _axis[key];
201
+ }
202
+ });
16
203
  });
@@ -0,0 +1 @@
1
+ export declare function buildWarning(message: (...args: any) => string, gravity?: 'warning' | 'error'): (...args: any) => void;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.buildWarning = buildWarning;
7
+ function buildWarning(message, gravity = 'warning') {
8
+ let alreadyWarned = false;
9
+ return (...args) => {
10
+ if (!alreadyWarned) {
11
+ alreadyWarned = true;
12
+ if (gravity === 'error') {
13
+ console.error(message(...args));
14
+ } else {
15
+ console.warn(message(...args));
16
+ }
17
+ }
18
+ };
19
+ }
package/models/axis.d.ts CHANGED
@@ -182,7 +182,7 @@ export interface AxisScaleConfig {
182
182
  colorMap?: ContinuousColorConfig | PiecewiseColorConfig;
183
183
  };
184
184
  }
185
- interface AxisScaleComputedConfig {
185
+ export interface AxisScaleComputedConfig {
186
186
  band: {
187
187
  colorScale?: ScaleOrdinal<string | number | Date, string, string | null> | ScaleOrdinal<number, string, string | null> | ScaleSequential<string, string | null> | ScaleThreshold<number | Date, string | null>;
188
188
  };
@@ -267,4 +267,3 @@ export declare function isBandScaleConfig(scaleConfig: AxisConfig<ScaleName>): s
267
267
  export declare function isPointScaleConfig(scaleConfig: AxisConfig<ScaleName>): scaleConfig is AxisConfig<'point'> & {
268
268
  scaleType: 'point';
269
269
  };
270
- export {};
@@ -4,11 +4,12 @@ import useForkRef from '@mui/utils/useForkRef';
4
4
  import { DrawingProvider } from '../context/DrawingProvider';
5
5
  import { SeriesContextProvider } from '../context/SeriesContextProvider';
6
6
  import { InteractionProvider } from '../context/InteractionProvider';
7
+ import { ColorProvider } from '../context/ColorProvider';
7
8
  import { useReducedMotion } from '../hooks/useReducedMotion';
8
9
  import { ChartsSurface } from '../ChartsSurface';
9
10
  import { CartesianContextProvider } from '../context/CartesianContextProvider';
10
11
  import { ChartsAxesGradients } from '../internals/components/ChartsAxesGradients';
11
- import { HighlightedProvider } from '../context';
12
+ import { HighlightedProvider, ZAxisContextProvider } from '../context';
12
13
  import { usePluginsMerge } from './usePluginsMerge';
13
14
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
15
  const ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContainer(props, ref) {
@@ -19,6 +20,7 @@ const ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContainer(pro
19
20
  margin,
20
21
  xAxis,
21
22
  yAxis,
23
+ zAxis,
22
24
  colors,
23
25
  dataset,
24
26
  sx,
@@ -33,7 +35,10 @@ const ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContainer(pro
33
35
  const svgRef = React.useRef(null);
34
36
  const handleRef = useForkRef(ref, svgRef);
35
37
  const {
36
- seriesFormatters
38
+ xExtremumGetters,
39
+ yExtremumGetters,
40
+ seriesFormatters,
41
+ colorProcessors
37
42
  } = usePluginsMerge(plugins);
38
43
  useReducedMotion(); // a11y reduce motion (see: https://react-spring.dev/docs/utilities/use-reduced-motion)
39
44
 
@@ -42,28 +47,37 @@ const ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContainer(pro
42
47
  height: height,
43
48
  margin: margin,
44
49
  svgRef: svgRef,
45
- children: /*#__PURE__*/_jsx(SeriesContextProvider, {
46
- series: series,
47
- colors: colors,
48
- dataset: dataset,
49
- seriesFormatters: seriesFormatters,
50
- children: /*#__PURE__*/_jsx(CartesianContextProvider, {
51
- xAxis: xAxis,
52
- yAxis: yAxis,
50
+ children: /*#__PURE__*/_jsx(ColorProvider, {
51
+ colorProcessors: colorProcessors,
52
+ children: /*#__PURE__*/_jsx(SeriesContextProvider, {
53
+ series: series,
54
+ colors: colors,
53
55
  dataset: dataset,
54
- children: /*#__PURE__*/_jsx(InteractionProvider, {
55
- children: /*#__PURE__*/_jsx(HighlightedProvider, {
56
- highlightedItem: highlightedItem,
57
- onHighlightChange: onHighlightChange,
58
- children: /*#__PURE__*/_jsxs(ChartsSurface, {
59
- width: width,
60
- height: height,
61
- ref: handleRef,
62
- sx: sx,
63
- title: title,
64
- desc: desc,
65
- disableAxisListener: disableAxisListener,
66
- children: [/*#__PURE__*/_jsx(ChartsAxesGradients, {}), children]
56
+ seriesFormatters: seriesFormatters,
57
+ children: /*#__PURE__*/_jsx(CartesianContextProvider, {
58
+ xAxis: xAxis,
59
+ yAxis: yAxis,
60
+ dataset: dataset,
61
+ xExtremumGetters: xExtremumGetters,
62
+ yExtremumGetters: yExtremumGetters,
63
+ children: /*#__PURE__*/_jsx(ZAxisContextProvider, {
64
+ zAxis: zAxis,
65
+ dataset: dataset,
66
+ children: /*#__PURE__*/_jsx(InteractionProvider, {
67
+ children: /*#__PURE__*/_jsx(HighlightedProvider, {
68
+ highlightedItem: highlightedItem,
69
+ onHighlightChange: onHighlightChange,
70
+ children: /*#__PURE__*/_jsxs(ChartsSurface, {
71
+ width: width,
72
+ height: height,
73
+ ref: handleRef,
74
+ sx: sx,
75
+ title: title,
76
+ desc: desc,
77
+ disableAxisListener: disableAxisListener,
78
+ children: [/*#__PURE__*/_jsx(ChartsAxesGradients, {}), children]
79
+ })
80
+ })
67
81
  })
68
82
  })
69
83
  })
@@ -251,6 +265,29 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
251
265
  tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
252
266
  tickSize: PropTypes.number,
253
267
  valueFormatter: PropTypes.func
268
+ })),
269
+ /**
270
+ * The configuration of the z-axes.
271
+ */
272
+ zAxis: PropTypes.arrayOf(PropTypes.shape({
273
+ colorMap: PropTypes.oneOfType([PropTypes.shape({
274
+ colors: PropTypes.arrayOf(PropTypes.string).isRequired,
275
+ type: PropTypes.oneOf(['ordinal']).isRequired,
276
+ unknownColor: PropTypes.string,
277
+ values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
278
+ }), PropTypes.shape({
279
+ color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
280
+ max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
281
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
282
+ type: PropTypes.oneOf(['continuous']).isRequired
283
+ }), PropTypes.shape({
284
+ colors: PropTypes.arrayOf(PropTypes.string).isRequired,
285
+ thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
286
+ type: PropTypes.oneOf(['piecewise']).isRequired
287
+ })]),
288
+ data: PropTypes.array,
289
+ dataKey: PropTypes.string,
290
+ id: PropTypes.string
254
291
  }))
255
292
  } : void 0;
256
293
  export { ChartContainer };
@@ -5,6 +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
9
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
10
  const getTextParams = ({
10
11
  top,
@@ -46,7 +47,7 @@ export function getXReferenceLineClasses(classes) {
46
47
  label: ['label']
47
48
  }, getReferenceLineUtilityClass, classes);
48
49
  }
49
- let warnedOnce = false;
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');
50
51
  function ChartsXReferenceLine(props) {
51
52
  const {
52
53
  x,
@@ -66,10 +67,7 @@ function ChartsXReferenceLine(props) {
66
67
  const xPosition = xAxisScale(x);
67
68
  if (xPosition === undefined) {
68
69
  if (process.env.NODE_ENV !== 'production') {
69
- if (!warnedOnce) {
70
- warnedOnce = true;
71
- console.error(`MUI X Charts: the value ${x} does not exist in the data of x axis with id ${axisId}.`);
72
- }
70
+ valueError(x, axisId);
73
71
  }
74
72
  return null;
75
73
  }
@@ -5,6 +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
9
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
10
  const getTextParams = ({
10
11
  left,
@@ -39,7 +40,6 @@ const getTextParams = ({
39
40
  };
40
41
  }
41
42
  };
42
- let warnedOnce = false;
43
43
  export function getYReferenceLineClasses(classes) {
44
44
  return composeClasses({
45
45
  root: ['root', 'horizontal'],
@@ -47,6 +47,7 @@ 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');
50
51
  function ChartsYReferenceLine(props) {
51
52
  const {
52
53
  y,
@@ -66,10 +67,7 @@ function ChartsYReferenceLine(props) {
66
67
  const yPosition = yAxisScale(y);
67
68
  if (yPosition === undefined) {
68
69
  if (process.env.NODE_ENV !== 'production') {
69
- if (!warnedOnce) {
70
- warnedOnce = true;
71
- console.error(`MUI X Charts: the value ${y} does not exist in the data of y axis with id ${axisId}.`);
72
- }
70
+ valueError(y, axisId);
73
71
  }
74
72
  return null;
75
73
  }
@@ -49,10 +49,8 @@ function ChartsText(props) {
49
49
  if (angle) {
50
50
  transforms.push(`rotate(${angle}, ${x}, ${y})`);
51
51
  }
52
- if (transforms.length) {
53
- textProps.transform = transforms.join(' ');
54
- }
55
52
  return /*#__PURE__*/_jsx("text", _extends({}, textProps, {
53
+ transform: transforms.length > 0 ? transforms.join(' ') : undefined,
56
54
  x: x,
57
55
  y: y,
58
56
  textAnchor: textAnchor,
@@ -4,9 +4,9 @@ import PropTypes from 'prop-types';
4
4
  import { useSlotProps } from '@mui/base/utils';
5
5
  import { CartesianContext } from '../context/CartesianContextProvider';
6
6
  import { DefaultChartsAxisTooltipContent } from './DefaultChartsAxisTooltipContent';
7
- import { isCartesianSeriesType } from '../internals/isCartesian';
8
- import colorGetter from '../internals/colorGetter';
9
7
  import { ZAxisContext } from '../context/ZAxisContextProvider';
8
+ import { useColorProcessor } from '../hooks/useColor';
9
+ import { isCartesianSeriesType } from '../internals/isCartesian';
10
10
  import { useSeries } from '../hooks/useSeries';
11
11
  import { jsx as _jsx } from "react/jsx-runtime";
12
12
  function ChartsAxisTooltipContent(props) {
@@ -31,6 +31,7 @@ function ChartsAxisTooltipContent(props) {
31
31
  zAxis
32
32
  } = React.useContext(ZAxisContext);
33
33
  const series = useSeries();
34
+ const colorProcessors = useColorProcessor();
34
35
  const USED_AXIS_ID = isXaxis ? xAxisIds[0] : yAxisIds[0];
35
36
  const relevantSeries = React.useMemo(() => {
36
37
  const rep = [];
@@ -40,15 +41,8 @@ function ChartsAxisTooltipContent(props) {
40
41
  const axisKey = isXaxis ? item.xAxisKey : item.yAxisKey;
41
42
  if (axisKey === undefined || axisKey === USED_AXIS_ID) {
42
43
  const seriesToAdd = series[seriesType].series[seriesId];
43
- let getColor;
44
- switch (seriesToAdd.type) {
45
- case 'scatter':
46
- getColor = colorGetter(seriesToAdd, xAxis[seriesToAdd.xAxisKey ?? xAxisIds[0]], yAxis[seriesToAdd.yAxisKey ?? yAxisIds[0]], zAxis[seriesToAdd.zAxisKey ?? zAxisIds[0]]);
47
- break;
48
- default:
49
- getColor = colorGetter(seriesToAdd, xAxis[seriesToAdd.xAxisKey ?? xAxisIds[0]], yAxis[seriesToAdd.yAxisKey ?? yAxisIds[0]]);
50
- break;
51
- }
44
+ const zAxisKey = seriesToAdd.zAxisKey ?? zAxisIds[0];
45
+ const getColor = colorProcessors[seriesType]?.(seriesToAdd, xAxis[seriesToAdd.xAxisKey ?? xAxisIds[0]], yAxis[seriesToAdd.yAxisKey ?? yAxisIds[0]], zAxisKey && zAxis[zAxisKey]) ?? (() => '');
52
46
  rep.push(_extends({}, seriesToAdd, {
53
47
  getColor
54
48
  }));
@@ -56,7 +50,7 @@ function ChartsAxisTooltipContent(props) {
56
50
  });
57
51
  });
58
52
  return rep;
59
- }, [USED_AXIS_ID, isXaxis, series, xAxis, xAxisIds, yAxis, yAxisIds, zAxis, zAxisIds]);
53
+ }, [USED_AXIS_ID, colorProcessors, isXaxis, series, xAxis, xAxisIds, yAxis, yAxisIds, zAxis, zAxisIds]);
60
54
  const relevantAxis = React.useMemo(() => {
61
55
  return isXaxis ? xAxis[USED_AXIS_ID] : yAxis[USED_AXIS_ID];
62
56
  }, [USED_AXIS_ID, isXaxis, xAxis, yAxis]);
@@ -4,8 +4,8 @@ import PropTypes from 'prop-types';
4
4
  import { useSlotProps } from '@mui/base/utils';
5
5
  import { DefaultChartsItemTooltipContent } from './DefaultChartsItemTooltipContent';
6
6
  import { CartesianContext } from '../context/CartesianContextProvider';
7
- import colorGetter from '../internals/colorGetter';
8
7
  import { ZAxisContext } from '../context/ZAxisContextProvider';
8
+ import { useColorProcessor } from '../hooks/useColor';
9
9
  import { useSeries } from '../hooks/useSeries';
10
10
  import { jsx as _jsx } from "react/jsx-runtime";
11
11
  function ChartsItemTooltipContent(props) {
@@ -27,21 +27,11 @@ function ChartsItemTooltipContent(props) {
27
27
  zAxis,
28
28
  zAxisIds
29
29
  } = React.useContext(ZAxisContext);
30
- const defaultXAxisId = xAxisIds[0];
31
- const defaultYAxisId = yAxisIds[0];
32
- const defaultZAxisId = zAxisIds[0];
33
- let getColor;
34
- switch (series.type) {
35
- case 'pie':
36
- getColor = colorGetter(series);
37
- break;
38
- case 'scatter':
39
- getColor = colorGetter(series, xAxis[series.xAxisKey ?? defaultXAxisId], yAxis[series.yAxisKey ?? defaultYAxisId], zAxis[series.zAxisKey ?? defaultZAxisId]);
40
- break;
41
- default:
42
- getColor = colorGetter(series, xAxis[series.xAxisKey ?? defaultXAxisId], yAxis[series.yAxisKey ?? defaultYAxisId]);
43
- break;
44
- }
30
+ const colorProcessors = useColorProcessor();
31
+ const xAxisKey = series.xAxisKey ?? xAxisIds[0];
32
+ const yAxisKey = series.yAxisKey ?? yAxisIds[0];
33
+ const zAxisKey = series.zAxisKey ?? zAxisIds[0];
34
+ const getColor = colorProcessors[series.type]?.(series, xAxisKey && xAxis[xAxisKey], yAxisKey && yAxis[yAxisKey], zAxisKey && zAxis[zAxisKey]) ?? (() => '');
45
35
  const Content = content ?? DefaultChartsItemTooltipContent;
46
36
  const chartTooltipContentProps = useSlotProps({
47
37
  elementType: Content,
@@ -38,7 +38,6 @@ function DefaultChartsAxisTooltipContent(props) {
38
38
  })
39
39
  }), /*#__PURE__*/_jsx("tbody", {
40
40
  children: series.filter(isCartesianSeries).map(({
41
- color,
42
41
  id,
43
42
  label,
44
43
  valueFormatter,
@@ -53,12 +52,13 @@ function DefaultChartsAxisTooltipContent(props) {
53
52
  return null;
54
53
  }
55
54
  const formattedLabel = getLabel(label, 'tooltip');
55
+ const color = getColor(dataIndex);
56
56
  return /*#__PURE__*/_jsxs(ChartsTooltipRow, {
57
57
  className: classes.row,
58
58
  children: [/*#__PURE__*/_jsx(ChartsTooltipCell, {
59
59
  className: clsx(classes.markCell, classes.cell),
60
- children: /*#__PURE__*/_jsx(ChartsTooltipMark, {
61
- color: getColor(dataIndex) ?? color,
60
+ children: color && /*#__PURE__*/_jsx(ChartsTooltipMark, {
61
+ color: color,
62
62
  className: classes.mark
63
63
  })
64
64
  }), /*#__PURE__*/_jsx(ChartsTooltipCell, {
@@ -23,7 +23,7 @@ function DefaultChartsItemTooltipContent(props) {
23
23
  color: getColor(itemData.dataIndex),
24
24
  displayedLabel: getLabel(series.data[itemData.dataIndex].label, 'tooltip')
25
25
  } : {
26
- color: getColor(itemData.dataIndex) ?? series.color,
26
+ color: getColor(itemData.dataIndex),
27
27
  displayedLabel: getLabel(series.label, 'tooltip')
28
28
  };
29
29
  const value = series.type === 'pie' ? _extends({}, series.data[itemData.dataIndex], {
@@ -15,7 +15,7 @@ import { ChartsClipPath } from '../ChartsClipPath';
15
15
  import { LineHighlightPlot } from './LineHighlightPlot';
16
16
  import { ChartsGrid } from '../ChartsGrid';
17
17
  import { ChartsOnAxisClickHandler } from '../ChartsOnAxisClickHandler';
18
- import { ChartsOverlay } from '../ChartsOverlay/ChartsOverlay';
18
+ import { ChartsOverlay } from '../ChartsOverlay';
19
19
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
20
20
  /**
21
21
  * Demos:
@@ -9,7 +9,7 @@ import { ChartsLegend } from '../ChartsLegend';
9
9
  import { ChartsAxisHighlight } from '../ChartsAxisHighlight';
10
10
  import { PiePlot } from './PiePlot';
11
11
  import { useIsRTL } from '../internals/useIsRTL';
12
- import { ChartsOverlay } from '../ChartsOverlay/ChartsOverlay';
12
+ import { ChartsOverlay } from '../ChartsOverlay';
13
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  const defaultMargin = {
15
15
  top: 5,
@@ -0,0 +1,26 @@
1
+ import { styled } from '@mui/material/styles';
2
+ /**
3
+ * Wrapping div that take the shape of its parent.
4
+ *
5
+ * @ignore - do not document.
6
+ */
7
+ export const ResizableContainer = styled('div', {
8
+ name: 'MuiResponsiveChart',
9
+ slot: 'Container'
10
+ })(({
11
+ ownerState
12
+ }) => ({
13
+ width: ownerState.width ?? '100%',
14
+ height: ownerState.height ?? '100%',
15
+ display: 'flex',
16
+ position: 'relative',
17
+ flexGrow: 1,
18
+ flexDirection: 'column',
19
+ alignItems: 'center',
20
+ justifyContent: 'center',
21
+ overflow: 'hidden',
22
+ '&>svg': {
23
+ width: '100%',
24
+ height: '100%'
25
+ }
26
+ }));
@@ -3,30 +3,10 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
3
3
  const _excluded = ["width", "height"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
- import { styled } from '@mui/material/styles';
7
6
  import { ChartContainer } from '../ChartContainer';
8
7
  import { useChartContainerDimensions } from './useChartContainerDimensions';
8
+ import { ResizableContainer } from './ResizableContainer';
9
9
  import { jsx as _jsx } from "react/jsx-runtime";
10
- const ResizableContainer = styled('div', {
11
- name: 'MuiResponsiveChart',
12
- slot: 'Container'
13
- })(({
14
- ownerState
15
- }) => ({
16
- width: ownerState.width ?? '100%',
17
- height: ownerState.height ?? '100%',
18
- display: 'flex',
19
- position: 'relative',
20
- flexGrow: 1,
21
- flexDirection: 'column',
22
- alignItems: 'center',
23
- justifyContent: 'center',
24
- overflow: 'hidden',
25
- '&>svg': {
26
- width: '100%',
27
- height: '100%'
28
- }
29
- }));
30
10
  const ResponsiveChartContainer = /*#__PURE__*/React.forwardRef(function ResponsiveChartContainer(props, ref) {
31
11
  const {
32
12
  width: inWidth,
@@ -227,6 +207,29 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
227
207
  tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
228
208
  tickSize: PropTypes.number,
229
209
  valueFormatter: PropTypes.func
210
+ })),
211
+ /**
212
+ * The configuration of the z-axes.
213
+ */
214
+ zAxis: PropTypes.arrayOf(PropTypes.shape({
215
+ colorMap: PropTypes.oneOfType([PropTypes.shape({
216
+ colors: PropTypes.arrayOf(PropTypes.string).isRequired,
217
+ type: PropTypes.oneOf(['ordinal']).isRequired,
218
+ unknownColor: PropTypes.string,
219
+ values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
220
+ }), PropTypes.shape({
221
+ color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
222
+ max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
223
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
224
+ type: PropTypes.oneOf(['continuous']).isRequired
225
+ }), PropTypes.shape({
226
+ colors: PropTypes.arrayOf(PropTypes.string).isRequired,
227
+ thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
228
+ type: PropTypes.oneOf(['piecewise']).isRequired
229
+ })]),
230
+ data: PropTypes.array,
231
+ dataKey: PropTypes.string,
232
+ id: PropTypes.string
230
233
  }))
231
234
  } : void 0;
232
235
  export { ResponsiveChartContainer };