@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
@@ -13,7 +13,7 @@ var _ResponsiveChartContainer = require("../ResponsiveChartContainer");
13
13
  var _ChartsAxis = require("../ChartsAxis");
14
14
  var _ChartsTooltip = require("../ChartsTooltip");
15
15
  var _ChartsLegend = require("../ChartsLegend");
16
- var _ChartsOverlay = require("../ChartsOverlay/ChartsOverlay");
16
+ var _ChartsOverlay = require("../ChartsOverlay");
17
17
  var _ChartsAxisHighlight = require("../ChartsAxisHighlight");
18
18
  var _ChartsVoronoiHandler = require("../ChartsVoronoiHandler/ChartsVoronoiHandler");
19
19
  var _ChartsGrid = require("../ChartsGrid");
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import { ResponsiveChartContainerProps } from '../ResponsiveChartContainer';
3
3
  import { ChartsTooltipProps, ChartsTooltipSlotProps, ChartsTooltipSlots } from '../ChartsTooltip';
4
4
  import { ChartsAxisHighlightProps } from '../ChartsAxisHighlight';
5
- import { AxisConfig, ChartsXAxisProps, ScaleName } from '../models/axis';
5
+ import { AxisConfig, ChartsXAxisProps, ChartsYAxisProps, ScaleName } from '../models/axis';
6
6
  import { MakeOptional } from '../models/helpers';
7
7
  import { LineSeriesType } from '../models/seriesType/line';
8
8
  import { CardinalDirections } from '../models/layout';
@@ -15,12 +15,17 @@ export interface SparkLineChartSlots extends AreaPlotSlots, LinePlotSlots, MarkP
15
15
  }
16
16
  export interface SparkLineChartSlotProps extends AreaPlotSlotProps, LinePlotSlotProps, MarkPlotSlotProps, LineHighlightPlotSlotProps, BarPlotSlotProps, ChartsTooltipSlotProps {
17
17
  }
18
- export interface SparkLineChartProps extends Omit<ResponsiveChartContainerProps, 'series' | 'xAxis' | 'yAxis' | 'margin' | 'plugins'> {
18
+ export interface SparkLineChartProps extends Omit<ResponsiveChartContainerProps, 'series' | 'xAxis' | 'yAxis' | 'zAxis' | 'margin' | 'plugins'> {
19
19
  /**
20
20
  * The xAxis configuration.
21
- * Notice it is a single configuration object, not an array of configuration.
21
+ * Notice it is a single [[AxisConfig]] object, not an array of configuration.
22
22
  */
23
23
  xAxis?: MakeOptional<AxisConfig<ScaleName, any, ChartsXAxisProps>, 'id'>;
24
+ /**
25
+ * The yAxis configuration.
26
+ * Notice it is a single [[AxisConfig]] object, not an array of configuration.
27
+ */
28
+ yAxis?: MakeOptional<AxisConfig<ScaleName, any, ChartsYAxisProps>, 'id'>;
24
29
  tooltip?: ChartsTooltipProps;
25
30
  axisHighlight?: ChartsAxisHighlightProps;
26
31
  /**
@@ -36,6 +36,7 @@ const SPARKLINE_DEFAULT_MARGIN = {
36
36
  const SparkLineChart = exports.SparkLineChart = /*#__PURE__*/React.forwardRef(function SparkLineChart(props, ref) {
37
37
  const {
38
38
  xAxis,
39
+ yAxis,
39
40
  width,
40
41
  height,
41
42
  margin = SPARKLINE_DEFAULT_MARGIN,
@@ -82,6 +83,9 @@ const SparkLineChart = exports.SparkLineChart = /*#__PURE__*/React.forwardRef(fu
82
83
  }, (_, index) => index),
83
84
  hideTooltip: xAxis === undefined
84
85
  }, xAxis)],
86
+ yAxis: [(0, _extends2.default)({
87
+ id: _constants.DEFAULT_X_AXIS_KEY
88
+ }, yAxis)],
85
89
  colors: colors,
86
90
  sx: sx,
87
91
  disableAxisListener: (!showTooltip || tooltip?.trigger !== 'axis') && axisHighlight?.x === 'none' && axisHighlight?.y === 'none',
@@ -242,7 +246,7 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
242
246
  width: _propTypes.default.number,
243
247
  /**
244
248
  * The xAxis configuration.
245
- * Notice it is a single configuration object, not an array of configuration.
249
+ * Notice it is a single [[AxisConfig]] object, not an array of configuration.
246
250
  */
247
251
  xAxis: _propTypes.default.shape({
248
252
  axisId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
@@ -291,5 +295,57 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
291
295
  tickPlacement: _propTypes.default.oneOf(['end', 'extremities', 'middle', 'start']),
292
296
  tickSize: _propTypes.default.number,
293
297
  valueFormatter: _propTypes.default.func
298
+ }),
299
+ /**
300
+ * The yAxis configuration.
301
+ * Notice it is a single [[AxisConfig]] object, not an array of configuration.
302
+ */
303
+ yAxis: _propTypes.default.shape({
304
+ axisId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
305
+ classes: _propTypes.default.object,
306
+ colorMap: _propTypes.default.oneOfType([_propTypes.default.shape({
307
+ colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
308
+ type: _propTypes.default.oneOf(['ordinal']).isRequired,
309
+ unknownColor: _propTypes.default.string,
310
+ values: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number, _propTypes.default.string]).isRequired)
311
+ }), _propTypes.default.shape({
312
+ color: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.string.isRequired), _propTypes.default.func]).isRequired,
313
+ max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
314
+ min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
315
+ type: _propTypes.default.oneOf(['continuous']).isRequired
316
+ }), _propTypes.default.shape({
317
+ colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
318
+ thresholds: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]).isRequired).isRequired,
319
+ type: _propTypes.default.oneOf(['piecewise']).isRequired
320
+ })]),
321
+ data: _propTypes.default.array,
322
+ dataKey: _propTypes.default.string,
323
+ disableLine: _propTypes.default.bool,
324
+ disableTicks: _propTypes.default.bool,
325
+ fill: _propTypes.default.string,
326
+ hideTooltip: _propTypes.default.bool,
327
+ id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
328
+ label: _propTypes.default.string,
329
+ labelFontSize: _propTypes.default.number,
330
+ labelStyle: _propTypes.default.object,
331
+ max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
332
+ min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
333
+ position: _propTypes.default.oneOf(['left', 'right']),
334
+ reverse: _propTypes.default.bool,
335
+ scaleType: _propTypes.default.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
336
+ slotProps: _propTypes.default.object,
337
+ slots: _propTypes.default.object,
338
+ stroke: _propTypes.default.string,
339
+ tickFontSize: _propTypes.default.number,
340
+ tickInterval: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.array, _propTypes.default.func]),
341
+ tickLabelInterval: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.func]),
342
+ tickLabelPlacement: _propTypes.default.oneOf(['middle', 'tick']),
343
+ tickLabelStyle: _propTypes.default.object,
344
+ tickMaxStep: _propTypes.default.number,
345
+ tickMinStep: _propTypes.default.number,
346
+ tickNumber: _propTypes.default.number,
347
+ tickPlacement: _propTypes.default.oneOf(['end', 'extremities', 'middle', 'start']),
348
+ tickSize: _propTypes.default.number,
349
+ valueFormatter: _propTypes.default.func
294
350
  })
295
351
  } : void 0;
@@ -22,6 +22,14 @@ export type CartesianContextProviderProps = {
22
22
  * An array of objects that can be used to populate series and axes data using their `dataKey` property.
23
23
  */
24
24
  dataset?: DatasetType;
25
+ /**
26
+ * An object with x-axis extremum getters per series type.
27
+ */
28
+ xExtremumGetters: ExtremumGettersConfig;
29
+ /**
30
+ * An object with y-axis extremum getters per series type.
31
+ */
32
+ yExtremumGetters: ExtremumGettersConfig;
25
33
  children: React.ReactNode;
26
34
  };
27
35
  type DefaultizedAxisConfig<AxisProps> = {
@@ -9,9 +9,6 @@ exports.CartesianContextProvider = CartesianContextProvider;
9
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
10
  var React = _interopRequireWildcard(require("react"));
11
11
  var _d3Scale = require("d3-scale");
12
- var _extremums = require("../BarChart/extremums");
13
- var _extremums2 = require("../ScatterChart/extremums");
14
- var _extremums3 = require("../LineChart/extremums");
15
12
  var _axis = require("../models/axis");
16
13
  var _getScale = require("../internals/getScale");
17
14
  var _constants = require("../constants");
@@ -24,18 +21,6 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
24
21
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
25
22
  const DEFAULT_CATEGORY_GAP_RATIO = 0.2;
26
23
  const DEFAULT_BAR_GAP_RATIO = 0.1;
27
-
28
- // TODO: those might be better placed in a distinct file
29
- const xExtremumGetters = {
30
- bar: _extremums.getExtremumX,
31
- scatter: _extremums2.getExtremumX,
32
- line: _extremums3.getExtremumX
33
- };
34
- const yExtremumGetters = {
35
- bar: _extremums.getExtremumY,
36
- scatter: _extremums2.getExtremumY,
37
- line: _extremums3.getExtremumY
38
- };
39
24
  const CartesianContext = exports.CartesianContext = /*#__PURE__*/React.createContext({
40
25
  xAxis: {},
41
26
  yAxis: {},
@@ -50,6 +35,8 @@ function CartesianContextProvider(props) {
50
35
  xAxis: inXAxis,
51
36
  yAxis: inYAxis,
52
37
  dataset,
38
+ xExtremumGetters,
39
+ yExtremumGetters,
53
40
  children
54
41
  } = props;
55
42
  const formattedSeries = (0, _useSeries.useSeries)();
@@ -82,11 +69,11 @@ function CartesianContextProvider(props) {
82
69
  const axisExtremumCallback = (acc, chartType, axis, getters, isDefaultAxis) => {
83
70
  const getter = getters[chartType];
84
71
  const series = formattedSeries[chartType]?.series ?? {};
85
- const [minChartTypeData, maxChartTypeData] = getter({
72
+ const [minChartTypeData, maxChartTypeData] = getter?.({
86
73
  series,
87
74
  axis,
88
75
  isDefaultAxis
89
- });
76
+ }) ?? [null, null];
90
77
  const [minData, maxData] = acc;
91
78
  if (minData === null || maxData === null) {
92
79
  return [minChartTypeData, maxChartTypeData];
@@ -223,7 +210,7 @@ function CartesianContextProvider(props) {
223
210
  id
224
211
  }) => id)
225
212
  };
226
- }, [drawingArea.height, drawingArea.left, drawingArea.top, drawingArea.width, formattedSeries, xAxis, yAxis]);
213
+ }, [drawingArea.height, drawingArea.left, drawingArea.top, drawingArea.width, formattedSeries, xAxis, xExtremumGetters, yAxis, yExtremumGetters]);
227
214
 
228
215
  // @ts-ignore
229
216
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(CartesianContext.Provider, {
@@ -0,0 +1,12 @@
1
+ import * as React from 'react';
2
+ import { ColorProcessorsConfig } from '../models';
3
+ import { ChartSeriesType } from '../internals';
4
+ export interface ColorProviderProps {
5
+ children: React.ReactNode;
6
+ /**
7
+ * A mapping defining for each series type how to get item colors.
8
+ */
9
+ colorProcessors: ColorProcessorsConfig<ChartSeriesType>;
10
+ }
11
+ export declare const ColorContext: React.Context<ColorProcessorsConfig<keyof import("../internals").ChartsSeriesConfig>>;
12
+ export declare function ColorProvider(props: ColorProviderProps): React.JSX.Element;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ColorContext = void 0;
7
+ exports.ColorProvider = ColorProvider;
8
+ var React = _interopRequireWildcard(require("react"));
9
+ var _jsxRuntime = require("react/jsx-runtime");
10
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
11
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
12
+ const ColorContext = exports.ColorContext = /*#__PURE__*/React.createContext({});
13
+ if (process.env.NODE_ENV !== 'production') {
14
+ ColorContext.displayName = 'ColorContext';
15
+ }
16
+ function ColorProvider(props) {
17
+ const {
18
+ colorProcessors,
19
+ children
20
+ } = props;
21
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(ColorContext.Provider, {
22
+ value: colorProcessors,
23
+ children: children
24
+ });
25
+ }
@@ -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
+ }));