@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,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 };
@@ -6,7 +6,7 @@ import { ResponsiveChartContainer } from '../ResponsiveChartContainer';
6
6
  import { ChartsAxis } from '../ChartsAxis';
7
7
  import { ChartsTooltip } from '../ChartsTooltip';
8
8
  import { ChartsLegend } from '../ChartsLegend';
9
- import { ChartsOverlay } from '../ChartsOverlay/ChartsOverlay';
9
+ import { ChartsOverlay } from '../ChartsOverlay';
10
10
  import { ChartsAxisHighlight } from '../ChartsAxisHighlight';
11
11
  import { ChartsVoronoiHandler } from '../ChartsVoronoiHandler/ChartsVoronoiHandler';
12
12
  import { ChartsGrid } from '../ChartsGrid';
@@ -27,6 +27,7 @@ const SPARKLINE_DEFAULT_MARGIN = {
27
27
  const SparkLineChart = /*#__PURE__*/React.forwardRef(function SparkLineChart(props, ref) {
28
28
  const {
29
29
  xAxis,
30
+ yAxis,
30
31
  width,
31
32
  height,
32
33
  margin = SPARKLINE_DEFAULT_MARGIN,
@@ -73,6 +74,9 @@ const SparkLineChart = /*#__PURE__*/React.forwardRef(function SparkLineChart(pro
73
74
  }, (_, index) => index),
74
75
  hideTooltip: xAxis === undefined
75
76
  }, xAxis)],
77
+ yAxis: [_extends({
78
+ id: DEFAULT_X_AXIS_KEY
79
+ }, yAxis)],
76
80
  colors: colors,
77
81
  sx: sx,
78
82
  disableAxisListener: (!showTooltip || tooltip?.trigger !== 'axis') && axisHighlight?.x === 'none' && axisHighlight?.y === 'none',
@@ -233,7 +237,7 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
233
237
  width: PropTypes.number,
234
238
  /**
235
239
  * The xAxis configuration.
236
- * Notice it is a single configuration object, not an array of configuration.
240
+ * Notice it is a single [[AxisConfig]] object, not an array of configuration.
237
241
  */
238
242
  xAxis: PropTypes.shape({
239
243
  axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
@@ -282,6 +286,58 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
282
286
  tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
283
287
  tickSize: PropTypes.number,
284
288
  valueFormatter: PropTypes.func
289
+ }),
290
+ /**
291
+ * The yAxis configuration.
292
+ * Notice it is a single [[AxisConfig]] object, not an array of configuration.
293
+ */
294
+ yAxis: PropTypes.shape({
295
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
296
+ classes: PropTypes.object,
297
+ colorMap: PropTypes.oneOfType([PropTypes.shape({
298
+ colors: PropTypes.arrayOf(PropTypes.string).isRequired,
299
+ type: PropTypes.oneOf(['ordinal']).isRequired,
300
+ unknownColor: PropTypes.string,
301
+ values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
302
+ }), PropTypes.shape({
303
+ color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
304
+ max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
305
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
306
+ type: PropTypes.oneOf(['continuous']).isRequired
307
+ }), PropTypes.shape({
308
+ colors: PropTypes.arrayOf(PropTypes.string).isRequired,
309
+ thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
310
+ type: PropTypes.oneOf(['piecewise']).isRequired
311
+ })]),
312
+ data: PropTypes.array,
313
+ dataKey: PropTypes.string,
314
+ disableLine: PropTypes.bool,
315
+ disableTicks: PropTypes.bool,
316
+ fill: PropTypes.string,
317
+ hideTooltip: PropTypes.bool,
318
+ id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
319
+ label: PropTypes.string,
320
+ labelFontSize: PropTypes.number,
321
+ labelStyle: PropTypes.object,
322
+ max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
323
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
324
+ position: PropTypes.oneOf(['left', 'right']),
325
+ reverse: PropTypes.bool,
326
+ scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
327
+ slotProps: PropTypes.object,
328
+ slots: PropTypes.object,
329
+ stroke: PropTypes.string,
330
+ tickFontSize: PropTypes.number,
331
+ tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
332
+ tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
333
+ tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
334
+ tickLabelStyle: PropTypes.object,
335
+ tickMaxStep: PropTypes.number,
336
+ tickMinStep: PropTypes.number,
337
+ tickNumber: PropTypes.number,
338
+ tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
339
+ tickSize: PropTypes.number,
340
+ valueFormatter: PropTypes.func
285
341
  })
286
342
  } : void 0;
287
343
  export { SparkLineChart };
@@ -1,9 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import { scaleBand, scalePoint } from 'd3-scale';
4
- import { getExtremumX as getBarExtremumX, getExtremumY as getBarExtremumY } from '../BarChart/extremums';
5
- import { getExtremumX as getScatterExtremumX, getExtremumY as getScatterExtremumY } from '../ScatterChart/extremums';
6
- import { getExtremumX as getLineExtremumX, getExtremumY as getLineExtremumY } from '../LineChart/extremums';
7
4
  import { isBandScaleConfig, isPointScaleConfig } from '../models/axis';
8
5
  import { getScale } from '../internals/getScale';
9
6
  import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from '../constants';
@@ -14,18 +11,6 @@ import { useSeries } from '../hooks/useSeries';
14
11
  import { jsx as _jsx } from "react/jsx-runtime";
15
12
  const DEFAULT_CATEGORY_GAP_RATIO = 0.2;
16
13
  const DEFAULT_BAR_GAP_RATIO = 0.1;
17
-
18
- // TODO: those might be better placed in a distinct file
19
- const xExtremumGetters = {
20
- bar: getBarExtremumX,
21
- scatter: getScatterExtremumX,
22
- line: getLineExtremumX
23
- };
24
- const yExtremumGetters = {
25
- bar: getBarExtremumY,
26
- scatter: getScatterExtremumY,
27
- line: getLineExtremumY
28
- };
29
14
  export const CartesianContext = /*#__PURE__*/React.createContext({
30
15
  xAxis: {},
31
16
  yAxis: {},
@@ -40,6 +25,8 @@ function CartesianContextProvider(props) {
40
25
  xAxis: inXAxis,
41
26
  yAxis: inYAxis,
42
27
  dataset,
28
+ xExtremumGetters,
29
+ yExtremumGetters,
43
30
  children
44
31
  } = props;
45
32
  const formattedSeries = useSeries();
@@ -72,11 +59,11 @@ function CartesianContextProvider(props) {
72
59
  const axisExtremumCallback = (acc, chartType, axis, getters, isDefaultAxis) => {
73
60
  const getter = getters[chartType];
74
61
  const series = formattedSeries[chartType]?.series ?? {};
75
- const [minChartTypeData, maxChartTypeData] = getter({
62
+ const [minChartTypeData, maxChartTypeData] = getter?.({
76
63
  series,
77
64
  axis,
78
65
  isDefaultAxis
79
- });
66
+ }) ?? [null, null];
80
67
  const [minData, maxData] = acc;
81
68
  if (minData === null || maxData === null) {
82
69
  return [minChartTypeData, maxChartTypeData];
@@ -213,7 +200,7 @@ function CartesianContextProvider(props) {
213
200
  id
214
201
  }) => id)
215
202
  };
216
- }, [drawingArea.height, drawingArea.left, drawingArea.top, drawingArea.width, formattedSeries, xAxis, yAxis]);
203
+ }, [drawingArea.height, drawingArea.left, drawingArea.top, drawingArea.width, formattedSeries, xAxis, xExtremumGetters, yAxis, yExtremumGetters]);
217
204
 
218
205
  // @ts-ignore
219
206
  return /*#__PURE__*/_jsx(CartesianContext.Provider, {
@@ -0,0 +1,16 @@
1
+ import * as React from 'react';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ export const ColorContext = /*#__PURE__*/React.createContext({});
4
+ if (process.env.NODE_ENV !== 'production') {
5
+ ColorContext.displayName = 'ColorContext';
6
+ }
7
+ export function ColorProvider(props) {
8
+ const {
9
+ colorProcessors,
10
+ children
11
+ } = props;
12
+ return /*#__PURE__*/_jsx(ColorContext.Provider, {
13
+ value: colorProcessors,
14
+ children: children
15
+ });
16
+ }
@@ -1,5 +1,6 @@
1
1
  export * from './useDrawingArea';
2
2
  export * from './useChartId';
3
3
  export * from './useScale';
4
+ export * from './useColorScale';
4
5
  export * from './useSvgRef';
5
6
  export { useSeries as unstable_useSeries, usePieSeries as unstable_usePieSeries, useLineSeries as unstable_useLineSeries, useBarSeries as unstable_useBarSeries, useScatterSeries as unstable_useScatterSeries } from './useSeries';
@@ -0,0 +1,9 @@
1
+ import * as React from 'react';
2
+ import { ColorContext } from '../context/ColorProvider';
3
+ export function useColorProcessor(seriesType) {
4
+ const colorProcessors = React.useContext(ColorContext);
5
+ if (!seriesType) {
6
+ return colorProcessors;
7
+ }
8
+ return colorProcessors[seriesType];
9
+ }
@@ -0,0 +1,27 @@
1
+ import * as React from 'react';
2
+ import { CartesianContext } from '../context/CartesianContextProvider';
3
+ import { ZAxisContext } from '../context/ZAxisContextProvider';
4
+ export function useXColorScale(identifier) {
5
+ const {
6
+ xAxis,
7
+ xAxisIds
8
+ } = React.useContext(CartesianContext);
9
+ const id = typeof identifier === 'string' ? identifier : xAxisIds[identifier ?? 0];
10
+ return xAxis[id].colorScale;
11
+ }
12
+ export function useYColorScale(identifier) {
13
+ const {
14
+ yAxis,
15
+ yAxisIds
16
+ } = React.useContext(CartesianContext);
17
+ const id = typeof identifier === 'string' ? identifier : yAxisIds[identifier ?? 0];
18
+ return yAxis[id].colorScale;
19
+ }
20
+ export function useZColorScale(identifier) {
21
+ const {
22
+ zAxis,
23
+ zAxisIds
24
+ } = React.useContext(ZAxisContext);
25
+ const id = typeof identifier === 'string' ? identifier : zAxisIds[identifier ?? 0];
26
+ return zAxis[id]?.colorScale;
27
+ }
@@ -11,6 +11,13 @@ export const useReducedMotion = () => {
11
11
  // Taken from: https://github.com/pmndrs/react-spring/blob/02ec877bbfab0df46da0e4a47d5f68d3e731206a/packages/shared/src/hooks/useReducedMotion.ts#L13
12
12
 
13
13
  useIsomorphicLayoutEffect(() => {
14
+ if (!window.matchMedia) {
15
+ // skip animation in environments where `window.matchMedia` would not be available (i.e. test/jsdom)
16
+ Globals.assign({
17
+ skipAnimation: true
18
+ });
19
+ return () => {};
20
+ }
14
21
  const mql = window.matchMedia('(prefers-reduced-motion)');
15
22
  const handleMediaChange = e => {
16
23
  Globals.assign({
@@ -1 +1,27 @@
1
- export * from './configInit';
1
+ // Components
2
+ export * from './components/ChartsAxesGradients';
3
+ export * from '../ResponsiveChartContainer/useChartContainerDimensions';
4
+ export * from '../ResponsiveChartContainer/ResizableContainer';
5
+
6
+ // hooks
7
+ export { useReducedMotion } from '../hooks/useReducedMotion';
8
+ export { useSeries } from '../hooks/useSeries';
9
+
10
+ // utils
11
+ export * from './defaultizeValueFormatter';
12
+ export * from './configInit';
13
+
14
+ // contexts
15
+
16
+ export * from '../context/CartesianContextProvider';
17
+ export * from '../context/DrawingProvider';
18
+ export * from '../context/InteractionProvider';
19
+ export * from '../context/SeriesContextProvider';
20
+ export * from '../context/ZAxisContextProvider';
21
+
22
+ // series configuration
23
+ export * from '../models/seriesType/config';
24
+ export * from '../models/seriesType/common';
25
+ export * from '../models/helpers';
26
+ export * from '../models/z-axis';
27
+ export * from '../models/axis';
@@ -0,0 +1,13 @@
1
+ export function buildWarning(message, gravity = 'warning') {
2
+ let alreadyWarned = false;
3
+ return (...args) => {
4
+ if (!alreadyWarned) {
5
+ alreadyWarned = true;
6
+ if (gravity === 'error') {
7
+ console.error(message(...args));
8
+ } else {
9
+ console.warn(message(...args));
10
+ }
11
+ }
12
+ };
13
+ }
package/hooks/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './useDrawingArea';
2
2
  export * from './useChartId';
3
3
  export * from './useScale';
4
+ export * from './useColorScale';
4
5
  export * from './useSvgRef';
5
6
  export { useSeries as unstable_useSeries, usePieSeries as unstable_usePieSeries, useLineSeries as unstable_useLineSeries, useBarSeries as unstable_useBarSeries, useScatterSeries as unstable_useScatterSeries, } from './useSeries';
package/hooks/index.js CHANGED
@@ -76,6 +76,18 @@ Object.keys(_useScale).forEach(function (key) {
76
76
  }
77
77
  });
78
78
  });
79
+ var _useColorScale = require("./useColorScale");
80
+ Object.keys(_useColorScale).forEach(function (key) {
81
+ if (key === "default" || key === "__esModule") return;
82
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
83
+ if (key in exports && exports[key] === _useColorScale[key]) return;
84
+ Object.defineProperty(exports, key, {
85
+ enumerable: true,
86
+ get: function () {
87
+ return _useColorScale[key];
88
+ }
89
+ });
90
+ });
79
91
  var _useSvgRef = require("./useSvgRef");
80
92
  Object.keys(_useSvgRef).forEach(function (key) {
81
93
  if (key === "default" || key === "__esModule") return;
@@ -0,0 +1,4 @@
1
+ import { ChartSeriesType } from '../internals';
2
+ import { ColorProcessorsConfig } from '../models/plugin';
3
+ export declare function useColorProcessor<T extends ChartSeriesType>(seriesType: T): ColorProcessorsConfig<ChartSeriesType>;
4
+ export declare function useColorProcessor(): ColorProcessorsConfig<ChartSeriesType>;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useColorProcessor = useColorProcessor;
7
+ var React = _interopRequireWildcard(require("react"));
8
+ var _ColorProvider = require("../context/ColorProvider");
9
+ 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); }
10
+ 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; }
11
+ function useColorProcessor(seriesType) {
12
+ const colorProcessors = React.useContext(_ColorProvider.ColorContext);
13
+ if (!seriesType) {
14
+ return colorProcessors;
15
+ }
16
+ return colorProcessors[seriesType];
17
+ }
@@ -0,0 +1,4 @@
1
+ import { AxisScaleComputedConfig, ScaleName } from '../models/axis';
2
+ export declare function useXColorScale<S extends ScaleName>(identifier?: number | string): AxisScaleComputedConfig[S]['colorScale'] | undefined;
3
+ export declare function useYColorScale<S extends ScaleName>(identifier?: number | string): AxisScaleComputedConfig[S]['colorScale'] | undefined;
4
+ export declare function useZColorScale<S extends ScaleName>(identifier?: number | string): AxisScaleComputedConfig[S]['colorScale'] | undefined;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useXColorScale = useXColorScale;
7
+ exports.useYColorScale = useYColorScale;
8
+ exports.useZColorScale = useZColorScale;
9
+ var React = _interopRequireWildcard(require("react"));
10
+ var _CartesianContextProvider = require("../context/CartesianContextProvider");
11
+ var _ZAxisContextProvider = require("../context/ZAxisContextProvider");
12
+ 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); }
13
+ 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; }
14
+ function useXColorScale(identifier) {
15
+ const {
16
+ xAxis,
17
+ xAxisIds
18
+ } = React.useContext(_CartesianContextProvider.CartesianContext);
19
+ const id = typeof identifier === 'string' ? identifier : xAxisIds[identifier ?? 0];
20
+ return xAxis[id].colorScale;
21
+ }
22
+ function useYColorScale(identifier) {
23
+ const {
24
+ yAxis,
25
+ yAxisIds
26
+ } = React.useContext(_CartesianContextProvider.CartesianContext);
27
+ const id = typeof identifier === 'string' ? identifier : yAxisIds[identifier ?? 0];
28
+ return yAxis[id].colorScale;
29
+ }
30
+ function useZColorScale(identifier) {
31
+ const {
32
+ zAxis,
33
+ zAxisIds
34
+ } = React.useContext(_ZAxisContextProvider.ZAxisContext);
35
+ const id = typeof identifier === 'string' ? identifier : zAxisIds[identifier ?? 0];
36
+ return zAxis[id]?.colorScale;
37
+ }
@@ -16,6 +16,13 @@ const useReducedMotion = () => {
16
16
  // Taken from: https://github.com/pmndrs/react-spring/blob/02ec877bbfab0df46da0e4a47d5f68d3e731206a/packages/shared/src/hooks/useReducedMotion.ts#L13
17
17
 
18
18
  (0, _web.useIsomorphicLayoutEffect)(() => {
19
+ if (!window.matchMedia) {
20
+ // skip animation in environments where `window.matchMedia` would not be available (i.e. test/jsdom)
21
+ _web.Globals.assign({
22
+ skipAnimation: true
23
+ });
24
+ return () => {};
25
+ }
19
26
  const mql = window.matchMedia('(prefers-reduced-motion)');
20
27
  const handleMediaChange = e => {
21
28
  _web.Globals.assign({
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v7.6.2
2
+ * @mui/x-charts v7.7.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -39,9 +39,9 @@ export declare function defaultizeColor(series: AllSeriesType, seriesIndex: numb
39
39
  arcLabelRadius?: number | undefined;
40
40
  color?: string | undefined;
41
41
  } | undefined;
42
- id?: import("../models/seriesType/common").SeriesId | undefined;
42
+ id?: import(".").SeriesId | undefined;
43
43
  color?: string | undefined;
44
- valueFormatter?: import("../models/seriesType/common").SeriesValueFormatter<import("../models/helpers").MakeOptional<import("../models/seriesType").PieValueType, "id">> | undefined;
44
+ valueFormatter?: import(".").SeriesValueFormatter<import(".").MakeOptional<import("../models/seriesType").PieValueType, "id">> | undefined;
45
45
  highlightScope?: Partial<import("..").HighlightScope> | undefined;
46
46
  } | {
47
47
  type: "bar";
@@ -50,9 +50,9 @@ export declare function defaultizeColor(series: AllSeriesType, seriesIndex: numb
50
50
  label?: string | ((location: "tooltip" | "legend") => string) | undefined;
51
51
  layout?: "horizontal" | "vertical" | undefined;
52
52
  stackOffset?: import("..").StackOffsetType | undefined;
53
- id?: import("../models/seriesType/common").SeriesId | undefined;
53
+ id?: import(".").SeriesId | undefined;
54
54
  color: string;
55
- valueFormatter?: import("../models/seriesType/common").SeriesValueFormatter<number | null> | undefined;
55
+ valueFormatter?: import(".").SeriesValueFormatter<number | null> | undefined;
56
56
  highlightScope?: Partial<import("..").HighlightScope> | undefined;
57
57
  xAxisKey?: string | undefined;
58
58
  yAxisKey?: string | undefined;
@@ -70,9 +70,9 @@ export declare function defaultizeColor(series: AllSeriesType, seriesIndex: numb
70
70
  disableHighlight?: boolean | undefined;
71
71
  connectNulls?: boolean | undefined;
72
72
  stackOffset?: import("..").StackOffsetType | undefined;
73
- id?: import("../models/seriesType/common").SeriesId | undefined;
73
+ id?: import(".").SeriesId | undefined;
74
74
  color: string;
75
- valueFormatter?: import("../models/seriesType/common").SeriesValueFormatter<number | null> | undefined;
75
+ valueFormatter?: import(".").SeriesValueFormatter<number | null> | undefined;
76
76
  highlightScope?: Partial<import("..").HighlightScope> | undefined;
77
77
  xAxisKey?: string | undefined;
78
78
  yAxisKey?: string | undefined;
@@ -84,9 +84,9 @@ export declare function defaultizeColor(series: AllSeriesType, seriesIndex: numb
84
84
  label?: string | ((location: "tooltip" | "legend") => string) | undefined;
85
85
  disableHover?: boolean | undefined;
86
86
  zAxisKey?: string | undefined;
87
- id?: import("../models/seriesType/common").SeriesId | undefined;
87
+ id?: import(".").SeriesId | undefined;
88
88
  color: string;
89
- valueFormatter?: import("../models/seriesType/common").SeriesValueFormatter<import("../models/seriesType").ScatterValueType> | undefined;
89
+ valueFormatter?: import(".").SeriesValueFormatter<import("../models/seriesType").ScatterValueType> | undefined;
90
90
  highlightScope?: Partial<import("..").HighlightScope> | undefined;
91
91
  xAxisKey?: string | undefined;
92
92
  yAxisKey?: string | undefined;
@@ -1 +1,17 @@
1
+ export * from './components/ChartsAxesGradients';
2
+ export * from '../ResponsiveChartContainer/useChartContainerDimensions';
3
+ export * from '../ResponsiveChartContainer/ResizableContainer';
4
+ export { useReducedMotion } from '../hooks/useReducedMotion';
5
+ export { useSeries } from '../hooks/useSeries';
6
+ export * from './defaultizeValueFormatter';
1
7
  export * from './configInit';
8
+ export * from '../context/CartesianContextProvider';
9
+ export * from '../context/DrawingProvider';
10
+ export * from '../context/InteractionProvider';
11
+ export * from '../context/SeriesContextProvider';
12
+ export * from '../context/ZAxisContextProvider';
13
+ export * from '../models/seriesType/config';
14
+ export * from '../models/seriesType/common';
15
+ export * from '../models/helpers';
16
+ export * from '../models/z-axis';
17
+ export * from '../models/axis';