@mui/x-charts 7.12.0 → 7.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/BarChart/BarPlot.js +2 -2
  2. package/BarChart/extremums.d.ts +1 -1
  3. package/BarChart/formatter.d.ts +2 -2
  4. package/BarChart/getColor.d.ts +3 -3
  5. package/BarChart/getColor.js +4 -3
  6. package/BarChart/legend.d.ts +1 -1
  7. package/BarChart/plugin.d.ts +2 -2
  8. package/CHANGELOG.md +70 -2
  9. package/ChartContainer/ChartContainer.d.ts +3 -14
  10. package/ChartContainer/ChartContainer.js +4 -4
  11. package/ChartContainer/useChartContainerProps.d.ts +6 -5
  12. package/ChartContainer/useChartContainerProps.js +14 -17
  13. package/ChartContainer/useDefaultizeAxis.d.ts +1 -1
  14. package/ChartsTooltip/ChartsAxisTooltipContent.js +2 -2
  15. package/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
  16. package/LineChart/extremums.d.ts +1 -1
  17. package/LineChart/formatter.d.ts +2 -2
  18. package/LineChart/getColor.d.ts +3 -3
  19. package/LineChart/getColor.js +4 -3
  20. package/LineChart/legend.d.ts +1 -1
  21. package/LineChart/plugin.d.ts +2 -2
  22. package/PieChart/formatter.d.ts +2 -2
  23. package/PieChart/getColor.d.ts +3 -2
  24. package/PieChart/getColor.js +4 -3
  25. package/PieChart/legend.d.ts +1 -1
  26. package/PieChart/plugin.d.ts +2 -2
  27. package/ResponsiveChartContainer/useResponsiveChartContainerProps.d.ts +1 -2
  28. package/ScatterChart/extremums.d.ts +1 -1
  29. package/ScatterChart/formatter.d.ts +2 -2
  30. package/ScatterChart/getColor.d.ts +3 -4
  31. package/ScatterChart/getColor.js +4 -3
  32. package/ScatterChart/legend.d.ts +1 -1
  33. package/ScatterChart/plugin.d.ts +2 -2
  34. package/context/CartesianProvider/CartesianProvider.d.ts +0 -9
  35. package/context/CartesianProvider/CartesianProvider.js +4 -2
  36. package/context/CartesianProvider/computeValue.d.ts +2 -1
  37. package/context/CartesianProvider/defaultizeAxis.d.ts +1 -1
  38. package/context/CartesianProvider/getAxisExtremum.d.ts +2 -2
  39. package/context/PluginProvider/ColorProcessor.types.d.ts +8 -0
  40. package/context/PluginProvider/ExtremumGetter.types.d.ts +14 -0
  41. package/context/PluginProvider/ExtremumGetter.types.js +5 -0
  42. package/context/PluginProvider/Plugin.types.d.ts +25 -0
  43. package/context/PluginProvider/Plugin.types.js +5 -0
  44. package/context/PluginProvider/PluginContext.d.ts +4 -0
  45. package/{hooks/useColor.js → context/PluginProvider/PluginContext.js} +11 -7
  46. package/context/PluginProvider/PluginProvider.d.ts +4 -0
  47. package/context/{ColorProvider.js → PluginProvider/PluginProvider.js} +12 -11
  48. package/context/PluginProvider/SeriesFormatter.types.d.ts +21 -0
  49. package/context/PluginProvider/SeriesFormatter.types.js +5 -0
  50. package/context/PluginProvider/index.d.ts +10 -0
  51. package/context/PluginProvider/index.js +115 -0
  52. package/context/PluginProvider/mergePlugins.d.ts +36 -0
  53. package/context/PluginProvider/mergePlugins.js +37 -0
  54. package/context/PluginProvider/useColorProcessor.d.ts +4 -0
  55. package/context/PluginProvider/useColorProcessor.js +23 -0
  56. package/context/PluginProvider/useSeriesFormatter.d.ts +4 -0
  57. package/context/PluginProvider/useSeriesFormatter.js +23 -0
  58. package/context/PluginProvider/useXExtremumGetter.d.ts +4 -0
  59. package/context/PluginProvider/useXExtremumGetter.js +23 -0
  60. package/context/PluginProvider/useYExtremumGetter.d.ts +4 -0
  61. package/context/PluginProvider/useYExtremumGetter.js +23 -0
  62. package/context/SeriesProvider/Series.types.d.ts +4 -10
  63. package/context/SeriesProvider/SeriesProvider.js +2 -1
  64. package/context/SeriesProvider/index.d.ts +1 -1
  65. package/context/SeriesProvider/processSeries.d.ts +2 -1
  66. package/esm/BarChart/BarPlot.js +1 -2
  67. package/esm/BarChart/getColor.js +3 -2
  68. package/esm/ChartContainer/ChartContainer.js +4 -4
  69. package/esm/ChartContainer/useChartContainerProps.js +12 -17
  70. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
  71. package/esm/ChartsTooltip/ChartsItemTooltipContent.js +1 -1
  72. package/esm/LineChart/getColor.js +3 -2
  73. package/esm/PieChart/getColor.js +3 -2
  74. package/esm/ScatterChart/getColor.js +3 -2
  75. package/esm/context/CartesianProvider/CartesianProvider.js +4 -2
  76. package/esm/context/PluginProvider/Plugin.types.js +1 -0
  77. package/esm/context/PluginProvider/PluginContext.js +13 -0
  78. package/esm/context/PluginProvider/PluginProvider.js +19 -0
  79. package/esm/context/PluginProvider/SeriesFormatter.types.js +1 -0
  80. package/esm/context/PluginProvider/index.js +10 -0
  81. package/esm/context/PluginProvider/mergePlugins.js +30 -0
  82. package/esm/context/PluginProvider/useColorProcessor.js +15 -0
  83. package/esm/context/PluginProvider/useSeriesFormatter.js +15 -0
  84. package/esm/context/PluginProvider/useXExtremumGetter.js +15 -0
  85. package/esm/context/PluginProvider/useYExtremumGetter.js +15 -0
  86. package/esm/context/SeriesProvider/SeriesProvider.js +2 -1
  87. package/esm/internals/index.js +1 -1
  88. package/esm/models/index.js +0 -1
  89. package/index.js +1 -1
  90. package/internals/colorScale.d.ts +1 -1
  91. package/internals/index.d.ts +1 -1
  92. package/internals/index.js +12 -12
  93. package/models/index.d.ts +0 -1
  94. package/models/index.js +0 -11
  95. package/models/seriesType/config.d.ts +0 -26
  96. package/modern/BarChart/BarPlot.js +1 -2
  97. package/modern/BarChart/getColor.js +3 -2
  98. package/modern/ChartContainer/ChartContainer.js +4 -4
  99. package/modern/ChartContainer/useChartContainerProps.js +12 -17
  100. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
  101. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +1 -1
  102. package/modern/LineChart/getColor.js +3 -2
  103. package/modern/PieChart/getColor.js +3 -2
  104. package/modern/ScatterChart/getColor.js +3 -2
  105. package/modern/context/CartesianProvider/CartesianProvider.js +4 -2
  106. package/modern/context/PluginProvider/ColorProcessor.types.js +1 -0
  107. package/modern/context/PluginProvider/ExtremumGetter.types.js +1 -0
  108. package/modern/context/PluginProvider/Plugin.types.js +1 -0
  109. package/modern/context/PluginProvider/PluginContext.js +13 -0
  110. package/modern/context/PluginProvider/PluginProvider.js +19 -0
  111. package/modern/context/PluginProvider/SeriesFormatter.types.js +1 -0
  112. package/modern/context/PluginProvider/index.js +10 -0
  113. package/modern/context/PluginProvider/mergePlugins.js +30 -0
  114. package/modern/context/PluginProvider/useColorProcessor.js +15 -0
  115. package/modern/context/PluginProvider/useSeriesFormatter.js +15 -0
  116. package/modern/context/PluginProvider/useXExtremumGetter.js +15 -0
  117. package/modern/context/PluginProvider/useYExtremumGetter.js +15 -0
  118. package/modern/context/SeriesProvider/SeriesProvider.js +2 -1
  119. package/modern/index.js +1 -1
  120. package/modern/internals/index.js +1 -1
  121. package/modern/models/index.js +0 -1
  122. package/package.json +2 -2
  123. package/ChartContainer/defaultPlugins.d.ts +0 -2
  124. package/ChartContainer/defaultPlugins.js +0 -11
  125. package/ChartContainer/useChartContainerHooks.d.ts +0 -11
  126. package/ChartContainer/useChartContainerHooks.js +0 -34
  127. package/ChartContainer/usePluginsMerge.d.ts +0 -9
  128. package/ChartContainer/usePluginsMerge.js +0 -39
  129. package/context/ColorProvider.d.ts +0 -12
  130. package/esm/ChartContainer/defaultPlugins.js +0 -5
  131. package/esm/ChartContainer/useChartContainerHooks.js +0 -24
  132. package/esm/ChartContainer/usePluginsMerge.js +0 -31
  133. package/esm/context/ColorProvider.js +0 -16
  134. package/esm/hooks/useColor.js +0 -9
  135. package/hooks/useColor.d.ts +0 -4
  136. package/models/plugin.d.ts +0 -19
  137. package/modern/ChartContainer/defaultPlugins.js +0 -5
  138. package/modern/ChartContainer/useChartContainerHooks.js +0 -24
  139. package/modern/ChartContainer/usePluginsMerge.js +0 -31
  140. package/modern/context/ColorProvider.js +0 -16
  141. package/modern/hooks/useColor.js +0 -9
  142. /package/{models/plugin.js → context/PluginProvider/ColorProcessor.types.js} +0 -0
  143. /package/esm/{models/plugin.js → context/PluginProvider/ColorProcessor.types.js} +0 -0
  144. /package/{modern/models/plugin.js → esm/context/PluginProvider/ExtremumGetter.types.js} +0 -0
@@ -12,7 +12,7 @@ import { BarClipPath } from './BarClipPath';
12
12
  import { BarLabelPlot } from './BarLabel/BarLabelPlot';
13
13
  import { checkScaleErrors } from './checkScaleErrors';
14
14
  import { useBarSeries } from '../hooks/useSeries';
15
-
15
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
16
16
  /**
17
17
  * Solution of the equations
18
18
  * W = barWidth * N + offset * (N-1)
@@ -22,7 +22,6 @@ import { useBarSeries } from '../hooks/useSeries';
22
22
  * @param gapRatio The ratio of the gap between bars over the bar width.
23
23
  * @returns The bar width and the offset between bars.
24
24
  */
25
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
26
25
  function getBandSize({
27
26
  bandWidth: W,
28
27
  numberOfGroups: N,
@@ -1,4 +1,4 @@
1
- export default function getColor(series, xAxis, yAxis) {
1
+ const getColor = (series, xAxis, yAxis) => {
2
2
  const verticalLayout = series.layout === 'vertical';
3
3
  const bandColorScale = verticalLayout ? xAxis?.colorScale : yAxis?.colorScale;
4
4
  const valueColorScale = verticalLayout ? yAxis?.colorScale : xAxis?.colorScale;
@@ -24,4 +24,5 @@ export default function getColor(series, xAxis, yAxis) {
24
24
  };
25
25
  }
26
26
  return () => series.color;
27
- }
27
+ };
28
+ export default getColor;
@@ -4,26 +4,26 @@ import PropTypes from 'prop-types';
4
4
  import { DrawingProvider } from '../context/DrawingProvider';
5
5
  import { SeriesProvider } from '../context/SeriesProvider';
6
6
  import { InteractionProvider } from '../context/InteractionProvider';
7
- import { ColorProvider } from '../context/ColorProvider';
8
7
  import { ChartsSurface } from '../ChartsSurface';
9
8
  import { CartesianContextProvider } from '../context/CartesianProvider';
10
9
  import { ChartsAxesGradients } from '../internals/components/ChartsAxesGradients';
11
10
  import { HighlightedProvider, ZAxisContextProvider } from '../context';
11
+ import { PluginProvider } from '../context/PluginProvider';
12
12
  import { useChartContainerProps } from './useChartContainerProps';
13
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  const ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContainer(props, ref) {
15
15
  const {
16
16
  children,
17
17
  drawingProviderProps,
18
- colorProviderProps,
19
18
  seriesProviderProps,
20
19
  cartesianContextProps,
21
20
  zAxisContextProps,
22
21
  highlightedProviderProps,
23
- chartsSurfaceProps
22
+ chartsSurfaceProps,
23
+ pluginProviderProps
24
24
  } = useChartContainerProps(props, ref);
25
25
  return /*#__PURE__*/_jsx(DrawingProvider, _extends({}, drawingProviderProps, {
26
- children: /*#__PURE__*/_jsx(ColorProvider, _extends({}, colorProviderProps, {
26
+ children: /*#__PURE__*/_jsx(PluginProvider, _extends({}, pluginProviderProps, {
27
27
  children: /*#__PURE__*/_jsx(SeriesProvider, _extends({}, seriesProviderProps, {
28
28
  children: /*#__PURE__*/_jsx(CartesianContextProvider, _extends({}, cartesianContextProps, {
29
29
  children: /*#__PURE__*/_jsx(ZAxisContextProvider, _extends({}, zAxisContextProps, {
@@ -1,8 +1,10 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
3
  const _excluded = ["width", "height", "series", "margin", "xAxis", "yAxis", "zAxis", "colors", "dataset", "sx", "title", "desc", "disableAxisListener", "highlightedItem", "onHighlightChange", "plugins", "children"];
4
- import { useChartContainerHooks } from './useChartContainerHooks';
4
+ import * as React from 'react';
5
+ import useForkRef from '@mui/utils/useForkRef';
5
6
  import { useDefaultizeAxis } from './useDefaultizeAxis';
7
+ import { useReducedMotion } from '../hooks/useReducedMotion';
6
8
  export const useChartContainerProps = (props, ref) => {
7
9
  const {
8
10
  width,
@@ -24,14 +26,10 @@ export const useChartContainerProps = (props, ref) => {
24
26
  children
25
27
  } = props,
26
28
  other = _objectWithoutPropertiesLoose(props, _excluded);
27
- const {
28
- svgRef,
29
- chartSurfaceRef,
30
- xExtremumGetters,
31
- yExtremumGetters,
32
- seriesFormatters,
33
- colorProcessors
34
- } = useChartContainerHooks(ref, plugins);
29
+ const svgRef = React.useRef(null);
30
+ const chartSurfaceRef = useForkRef(ref, svgRef);
31
+ useReducedMotion(); // a11y reduce motion (see: https://react-spring.dev/docs/utilities/use-reduced-motion)
32
+
35
33
  const [defaultizedXAxis, defaultizedYAxis] = useDefaultizeAxis(xAxis, yAxis);
36
34
  const drawingProviderProps = {
37
35
  width,
@@ -39,21 +37,18 @@ export const useChartContainerProps = (props, ref) => {
39
37
  margin,
40
38
  svgRef
41
39
  };
42
- const colorProviderProps = {
43
- colorProcessors
40
+ const pluginProviderProps = {
41
+ plugins
44
42
  };
45
43
  const seriesProviderProps = {
46
44
  series,
47
45
  colors,
48
- dataset,
49
- seriesFormatters
46
+ dataset
50
47
  };
51
48
  const cartesianContextProps = {
52
49
  xAxis: defaultizedXAxis,
53
50
  yAxis: defaultizedYAxis,
54
- dataset,
55
- xExtremumGetters,
56
- yExtremumGetters
51
+ dataset
57
52
  };
58
53
  const zAxisContextProps = {
59
54
  zAxis,
@@ -75,12 +70,12 @@ export const useChartContainerProps = (props, ref) => {
75
70
  return {
76
71
  children,
77
72
  drawingProviderProps,
78
- colorProviderProps,
79
73
  seriesProviderProps,
80
74
  cartesianContextProps,
81
75
  zAxisContextProps,
82
76
  highlightedProviderProps,
83
77
  chartsSurfaceProps,
78
+ pluginProviderProps,
84
79
  xAxis: defaultizedXAxis,
85
80
  yAxis: defaultizedYAxis
86
81
  };
@@ -4,7 +4,7 @@ import useSlotProps from '@mui/utils/useSlotProps';
4
4
  import { useCartesianContext } from '../context/CartesianProvider';
5
5
  import { DefaultChartsAxisTooltipContent } from './DefaultChartsAxisTooltipContent';
6
6
  import { ZAxisContext } from '../context/ZAxisContextProvider';
7
- import { useColorProcessor } from '../hooks/useColor';
7
+ import { useColorProcessor } from '../context/PluginProvider/useColorProcessor';
8
8
  import { isCartesianSeriesType } from '../internals/isCartesian';
9
9
  import { useSeries } from '../hooks/useSeries';
10
10
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -4,7 +4,7 @@ import useSlotProps from '@mui/utils/useSlotProps';
4
4
  import { DefaultChartsItemTooltipContent } from './DefaultChartsItemTooltipContent';
5
5
  import { useCartesianContext } from '../context/CartesianProvider';
6
6
  import { ZAxisContext } from '../context/ZAxisContextProvider';
7
- import { useColorProcessor } from '../hooks/useColor';
7
+ import { useColorProcessor } from '../context/PluginProvider/useColorProcessor';
8
8
  import { useSeries } from '../hooks/useSeries';
9
9
  import { jsx as _jsx } from "react/jsx-runtime";
10
10
  /**
@@ -1,4 +1,4 @@
1
- export default function getColor(series, xAxis, yAxis) {
1
+ const getColor = (series, xAxis, yAxis) => {
2
2
  const yColorScale = yAxis?.colorScale;
3
3
  const xColorScale = xAxis?.colorScale;
4
4
  if (yColorScale) {
@@ -22,4 +22,5 @@ export default function getColor(series, xAxis, yAxis) {
22
22
  };
23
23
  }
24
24
  return () => series.color;
25
- }
25
+ };
26
+ export default getColor;
@@ -1,5 +1,6 @@
1
- export default function getColor(series) {
1
+ const getColor = series => {
2
2
  return dataIndex => {
3
3
  return series.data[dataIndex].color;
4
4
  };
5
- }
5
+ };
6
+ export default getColor;
@@ -1,4 +1,4 @@
1
- export default function getColor(series, xAxis, yAxis, zAxis) {
1
+ const getColor = (series, xAxis, yAxis, zAxis) => {
2
2
  const zColorScale = zAxis?.colorScale;
3
3
  const yColorScale = yAxis?.colorScale;
4
4
  const xColorScale = xAxis?.colorScale;
@@ -39,4 +39,5 @@ export default function getColor(series, xAxis, yAxis, zAxis) {
39
39
  };
40
40
  }
41
41
  return () => series.color;
42
- }
42
+ };
43
+ export default getColor;
@@ -3,18 +3,20 @@ import { useDrawingArea } from '../../hooks/useDrawingArea';
3
3
  import { useSeries } from '../../hooks/useSeries';
4
4
  import { CartesianContext } from './CartesianContext';
5
5
  import { computeValue } from './computeValue';
6
+ import { useXExtremumGetter } from '../PluginProvider/useXExtremumGetter';
7
+ import { useYExtremumGetter } from '../PluginProvider';
6
8
  import { jsx as _jsx } from "react/jsx-runtime";
7
9
  function CartesianContextProvider(props) {
8
10
  const {
9
11
  xAxis,
10
12
  yAxis,
11
13
  dataset,
12
- xExtremumGetters,
13
- yExtremumGetters,
14
14
  children
15
15
  } = props;
16
16
  const formattedSeries = useSeries();
17
17
  const drawingArea = useDrawingArea();
18
+ const xExtremumGetters = useXExtremumGetter();
19
+ const yExtremumGetters = useYExtremumGetter();
18
20
  const xValues = React.useMemo(() => computeValue({
19
21
  drawingArea,
20
22
  formattedSeries,
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ import * as React from 'react';
2
+ export const PluginContext = /*#__PURE__*/React.createContext({
3
+ isInitialized: false,
4
+ data: {
5
+ colorProcessors: {},
6
+ seriesFormatters: {},
7
+ xExtremumGetters: {},
8
+ yExtremumGetters: {}
9
+ }
10
+ });
11
+ if (process.env.NODE_ENV !== 'production') {
12
+ PluginContext.displayName = 'PluginContext';
13
+ }
@@ -0,0 +1,19 @@
1
+ import * as React from 'react';
2
+ import { PluginContext } from './PluginContext';
3
+ import { mergePlugins } from './mergePlugins';
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ function PluginProvider(props) {
6
+ const {
7
+ children,
8
+ plugins
9
+ } = props;
10
+ const formattedSeries = React.useMemo(() => ({
11
+ isInitialized: true,
12
+ data: mergePlugins(plugins)
13
+ }), [plugins]);
14
+ return /*#__PURE__*/_jsx(PluginContext.Provider, {
15
+ value: formattedSeries,
16
+ children: children
17
+ });
18
+ }
19
+ export { PluginProvider };
@@ -0,0 +1,10 @@
1
+ export * from './PluginProvider';
2
+ export * from './Plugin.types';
3
+ export * from './PluginContext';
4
+ export * from './ColorProcessor.types';
5
+ export * from './SeriesFormatter.types';
6
+ export * from './ExtremumGetter.types';
7
+ export * from './useColorProcessor';
8
+ export * from './useSeriesFormatter';
9
+ export * from './useXExtremumGetter';
10
+ export * from './useYExtremumGetter';
@@ -0,0 +1,30 @@
1
+ import { plugin as barPlugin } from '../../BarChart/plugin';
2
+ import { plugin as scatterPlugin } from '../../ScatterChart/plugin';
3
+ import { plugin as linePlugin } from '../../LineChart/plugin';
4
+ import { plugin as piePlugin } from '../../PieChart/plugin';
5
+ export const defaultPlugins = [barPlugin, scatterPlugin, linePlugin, piePlugin];
6
+ export function mergePlugins(plugins) {
7
+ const defaultizedPlugins = plugins ?? defaultPlugins;
8
+ const seriesFormatters = {};
9
+ const colorProcessors = {};
10
+ const xExtremumGetters = {};
11
+ const yExtremumGetters = {};
12
+ for (let i = 0; i < defaultizedPlugins.length; i += 1) {
13
+ const plugin = defaultizedPlugins[i];
14
+ const seriesType = plugin.seriesType;
15
+ seriesFormatters[seriesType] = plugin.seriesFormatter;
16
+ colorProcessors[seriesType] = plugin.colorProcessor;
17
+ if (plugin.xExtremumGetter) {
18
+ xExtremumGetters[seriesType] = plugin.xExtremumGetter;
19
+ }
20
+ if (plugin.yExtremumGetter) {
21
+ yExtremumGetters[seriesType] = plugin.yExtremumGetter;
22
+ }
23
+ }
24
+ return {
25
+ seriesFormatters,
26
+ colorProcessors,
27
+ xExtremumGetters,
28
+ yExtremumGetters
29
+ };
30
+ }
@@ -0,0 +1,15 @@
1
+ import * as React from 'react';
2
+ import { PluginContext } from './PluginContext';
3
+ export function useColorProcessor(seriesType) {
4
+ const {
5
+ isInitialized,
6
+ data
7
+ } = React.useContext(PluginContext);
8
+ if (!isInitialized) {
9
+ throw new Error(['MUI X: Could not find the plugin context.', 'It looks like you rendered your component outside of a ChartsContainer parent component.'].join('\n'));
10
+ }
11
+ if (!seriesType) {
12
+ return data.colorProcessors;
13
+ }
14
+ return data.colorProcessors[seriesType];
15
+ }
@@ -0,0 +1,15 @@
1
+ import * as React from 'react';
2
+ import { PluginContext } from './PluginContext';
3
+ export function useSeriesFormatter(seriesType) {
4
+ const {
5
+ isInitialized,
6
+ data
7
+ } = React.useContext(PluginContext);
8
+ if (!isInitialized) {
9
+ throw new Error(['MUI X: Could not find the plugin context.', 'It looks like you rendered your component outside of a ChartsContainer parent component.'].join('\n'));
10
+ }
11
+ if (!seriesType) {
12
+ return data.seriesFormatters;
13
+ }
14
+ return data.seriesFormatters[seriesType];
15
+ }
@@ -0,0 +1,15 @@
1
+ import * as React from 'react';
2
+ import { PluginContext } from './PluginContext';
3
+ export function useXExtremumGetter(seriesType) {
4
+ const {
5
+ isInitialized,
6
+ data
7
+ } = React.useContext(PluginContext);
8
+ if (!isInitialized) {
9
+ throw new Error(['MUI X: Could not find the plugin context.', 'It looks like you rendered your component outside of a ChartsContainer parent component.'].join('\n'));
10
+ }
11
+ if (!seriesType) {
12
+ return data.xExtremumGetters;
13
+ }
14
+ return data.xExtremumGetters[seriesType];
15
+ }
@@ -0,0 +1,15 @@
1
+ import * as React from 'react';
2
+ import { PluginContext } from './PluginContext';
3
+ export function useYExtremumGetter(seriesType) {
4
+ const {
5
+ isInitialized,
6
+ data
7
+ } = React.useContext(PluginContext);
8
+ if (!isInitialized) {
9
+ throw new Error(['MUI X: Could not find the plugin context.', 'It looks like you rendered your component outside of a ChartsContainer parent component.'].join('\n'));
10
+ }
11
+ if (!seriesType) {
12
+ return data.yExtremumGetters;
13
+ }
14
+ return data.yExtremumGetters[seriesType];
15
+ }
@@ -3,15 +3,16 @@ import { useTheme } from '@mui/material/styles';
3
3
  import { blueberryTwilightPalette } from '../../colorPalettes';
4
4
  import { SeriesContext } from './SeriesContext';
5
5
  import { preprocessSeries } from './processSeries';
6
+ import { useSeriesFormatter } from '../PluginProvider';
6
7
  import { jsx as _jsx } from "react/jsx-runtime";
7
8
  function SeriesProvider(props) {
8
9
  const {
9
10
  series,
10
11
  dataset,
11
12
  colors = blueberryTwilightPalette,
12
- seriesFormatters,
13
13
  children
14
14
  } = props;
15
+ const seriesFormatters = useSeriesFormatter();
15
16
  const theme = useTheme();
16
17
  const formattedSeries = React.useMemo(() => ({
17
18
  isInitialized: true,
@@ -25,10 +25,10 @@ export * from './isDefined';
25
25
 
26
26
  export * from '../context/CartesianProvider';
27
27
  export * from '../context/DrawingProvider';
28
- export * from '../context/ColorProvider';
29
28
  export * from '../context/InteractionProvider';
30
29
  export * from '../context/SeriesProvider';
31
30
  export * from '../context/ZAxisContextProvider';
31
+ export * from '../context/PluginProvider';
32
32
  // series configuration
33
33
  export * from '../models/seriesType/config';
34
34
  export * from '../models/seriesType/common';
@@ -1,5 +1,4 @@
1
1
  export * from './seriesType';
2
2
  export * from './layout';
3
3
  export * from './stacking';
4
- export * from './plugin';
5
4
  export {};
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v7.12.0
2
+ * @mui/x-charts v7.12.1
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -2,4 +2,4 @@ import { ScaleOrdinal } from '@mui/x-charts-vendor/d3-scale';
2
2
  import { ContinuousColorConfig, PiecewiseColorConfig, OrdinalColorConfig } from '../models/colorMapping';
3
3
  export declare function getSequentialColorScale<Value extends number | Date>(config: ContinuousColorConfig<Value> | PiecewiseColorConfig<Value>): import("@mui/x-charts-vendor/d3-scale").ScaleThreshold<Value, string, never> | import("@mui/x-charts-vendor/d3-scale").ScaleSequential<string, never>;
4
4
  export declare function getOrdinalColorScale<Value extends number | Date | string>(config: OrdinalColorConfig<Value>): ScaleOrdinal<Value, string, null | string> | ScaleOrdinal<number, string, null | string>;
5
- export declare function getColorScale(config: ContinuousColorConfig | PiecewiseColorConfig | OrdinalColorConfig): import("@mui/x-charts-vendor/d3-scale").ScaleSequential<string, never> | ScaleOrdinal<number, string, string | null> | ScaleOrdinal<string | number | Date, string, string | null> | import("@mui/x-charts-vendor/d3-scale").ScaleThreshold<number | Date, string, never>;
5
+ export declare function getColorScale(config: ContinuousColorConfig | PiecewiseColorConfig | OrdinalColorConfig): ScaleOrdinal<string | number | Date, string, string | null> | ScaleOrdinal<number, string, string | null> | import("@mui/x-charts-vendor/d3-scale").ScaleSequential<string, never> | import("@mui/x-charts-vendor/d3-scale").ScaleThreshold<number | Date, string, never>;
@@ -17,10 +17,10 @@ export * from './getSVGPoint';
17
17
  export * from './isDefined';
18
18
  export * from '../context/CartesianProvider';
19
19
  export * from '../context/DrawingProvider';
20
- export * from '../context/ColorProvider';
21
20
  export * from '../context/InteractionProvider';
22
21
  export * from '../context/SeriesProvider';
23
22
  export * from '../context/ZAxisContextProvider';
23
+ export * from '../context/PluginProvider';
24
24
  export type * from '../context/context.types';
25
25
  export * from '../models/seriesType/config';
26
26
  export * from '../models/seriesType/common';
@@ -197,18 +197,6 @@ Object.keys(_DrawingProvider).forEach(function (key) {
197
197
  }
198
198
  });
199
199
  });
200
- var _ColorProvider = require("../context/ColorProvider");
201
- Object.keys(_ColorProvider).forEach(function (key) {
202
- if (key === "default" || key === "__esModule") return;
203
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
204
- if (key in exports && exports[key] === _ColorProvider[key]) return;
205
- Object.defineProperty(exports, key, {
206
- enumerable: true,
207
- get: function () {
208
- return _ColorProvider[key];
209
- }
210
- });
211
- });
212
200
  var _InteractionProvider = require("../context/InteractionProvider");
213
201
  Object.keys(_InteractionProvider).forEach(function (key) {
214
202
  if (key === "default" || key === "__esModule") return;
@@ -245,6 +233,18 @@ Object.keys(_ZAxisContextProvider).forEach(function (key) {
245
233
  }
246
234
  });
247
235
  });
236
+ var _PluginProvider = require("../context/PluginProvider");
237
+ Object.keys(_PluginProvider).forEach(function (key) {
238
+ if (key === "default" || key === "__esModule") return;
239
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
240
+ if (key in exports && exports[key] === _PluginProvider[key]) return;
241
+ Object.defineProperty(exports, key, {
242
+ enumerable: true,
243
+ get: function () {
244
+ return _PluginProvider[key];
245
+ }
246
+ });
247
+ });
248
248
  var _config = require("../models/seriesType/config");
249
249
  Object.keys(_config).forEach(function (key) {
250
250
  if (key === "default" || key === "__esModule") return;
package/models/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  export * from './seriesType';
2
2
  export * from './layout';
3
3
  export * from './stacking';
4
- export * from './plugin';
5
4
  export type { AxisConfig, ChartsYAxisProps, ChartsXAxisProps, ScaleName, ContinuousScaleName, } from './axis';
package/models/index.js CHANGED
@@ -35,15 +35,4 @@ Object.keys(_stacking).forEach(function (key) {
35
35
  return _stacking[key];
36
36
  }
37
37
  });
38
- });
39
- var _plugin = require("./plugin");
40
- Object.keys(_plugin).forEach(function (key) {
41
- if (key === "default" || key === "__esModule") return;
42
- if (key in exports && exports[key] === _plugin[key]) return;
43
- Object.defineProperty(exports, key, {
44
- enumerable: true,
45
- get: function () {
46
- return _plugin[key];
47
- }
48
- });
49
38
  });
@@ -2,11 +2,7 @@ import { ScatterSeriesType, DefaultizedScatterSeriesType, ScatterItemIdentifier
2
2
  import { LineSeriesType, DefaultizedLineSeriesType, LineItemIdentifier } from './line';
3
3
  import { BarItemIdentifier, BarSeriesType, DefaultizedBarSeriesType } from './bar';
4
4
  import { PieSeriesType, DefaultizedPieSeriesType, PieItemIdentifier, PieValueType } from './pie';
5
- import { AxisConfig } from '../axis';
6
5
  import { DefaultizedProps, MakeOptional } from '../helpers';
7
- import { StackingGroupsType } from '../../internals/stackSeries';
8
- import { SeriesId } from './common';
9
- import { LegendItemParams } from '../../ChartsLegend/chartsLegend.types';
10
6
  export interface ChartsSeriesConfig {
11
7
  bar: {
12
8
  /**
@@ -79,29 +75,7 @@ export type ChartSeriesDefaultized<T extends ChartSeriesType> = ChartsSeriesConf
79
75
  stackedData: [number, number][];
80
76
  } : ChartsSeriesConfig[T]['series'];
81
77
  export type ChartItemIdentifier<T extends ChartSeriesType> = ChartsSeriesConfig[T]['itemIdentifier'];
82
- type ExtremumGetterParams<T extends ChartSeriesType> = {
83
- series: Record<SeriesId, ChartSeries<T>>;
84
- axis: AxisConfig;
85
- isDefaultAxis: boolean;
86
- };
87
- export type ExtremumGetterResult = [number, number] | [null, null];
88
- export type ExtremumGetter<T extends ChartSeriesType> = (params: ExtremumGetterParams<T>) => ExtremumGetterResult;
89
- export type FormatterParams<T extends ChartSeriesType> = {
90
- series: Record<SeriesId, ChartsSeriesConfig[T]['seriesInput']>;
91
- seriesOrder: SeriesId[];
92
- };
93
- export type FormatterResult<T extends ChartSeriesType> = {
94
- series: Record<SeriesId, ChartSeriesDefaultized<T>>;
95
- seriesOrder: SeriesId[];
96
- } & (ChartsSeriesConfig[T] extends {
97
- canBeStacked: true;
98
- } ? {
99
- stackingGroups: StackingGroupsType;
100
- } : {});
101
78
  export type DatasetElementType<T> = {
102
79
  [key: string]: T;
103
80
  };
104
81
  export type DatasetType<T = number | string | Date | null | undefined> = DatasetElementType<T>[];
105
- export type Formatter<T extends ChartSeriesType> = (params: FormatterParams<T>, dataset?: DatasetType) => FormatterResult<T>;
106
- export type LegendGetter<T extends ChartSeriesType> = (series: FormatterResult<T>) => LegendItemParams[];
107
- export {};
@@ -12,7 +12,7 @@ import { BarClipPath } from './BarClipPath';
12
12
  import { BarLabelPlot } from './BarLabel/BarLabelPlot';
13
13
  import { checkScaleErrors } from './checkScaleErrors';
14
14
  import { useBarSeries } from '../hooks/useSeries';
15
-
15
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
16
16
  /**
17
17
  * Solution of the equations
18
18
  * W = barWidth * N + offset * (N-1)
@@ -22,7 +22,6 @@ import { useBarSeries } from '../hooks/useSeries';
22
22
  * @param gapRatio The ratio of the gap between bars over the bar width.
23
23
  * @returns The bar width and the offset between bars.
24
24
  */
25
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
26
25
  function getBandSize({
27
26
  bandWidth: W,
28
27
  numberOfGroups: N,
@@ -1,4 +1,4 @@
1
- export default function getColor(series, xAxis, yAxis) {
1
+ const getColor = (series, xAxis, yAxis) => {
2
2
  const verticalLayout = series.layout === 'vertical';
3
3
  const bandColorScale = verticalLayout ? xAxis?.colorScale : yAxis?.colorScale;
4
4
  const valueColorScale = verticalLayout ? yAxis?.colorScale : xAxis?.colorScale;
@@ -24,4 +24,5 @@ export default function getColor(series, xAxis, yAxis) {
24
24
  };
25
25
  }
26
26
  return () => series.color;
27
- }
27
+ };
28
+ export default getColor;
@@ -4,26 +4,26 @@ import PropTypes from 'prop-types';
4
4
  import { DrawingProvider } from '../context/DrawingProvider';
5
5
  import { SeriesProvider } from '../context/SeriesProvider';
6
6
  import { InteractionProvider } from '../context/InteractionProvider';
7
- import { ColorProvider } from '../context/ColorProvider';
8
7
  import { ChartsSurface } from '../ChartsSurface';
9
8
  import { CartesianContextProvider } from '../context/CartesianProvider';
10
9
  import { ChartsAxesGradients } from '../internals/components/ChartsAxesGradients';
11
10
  import { HighlightedProvider, ZAxisContextProvider } from '../context';
11
+ import { PluginProvider } from '../context/PluginProvider';
12
12
  import { useChartContainerProps } from './useChartContainerProps';
13
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  const ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContainer(props, ref) {
15
15
  const {
16
16
  children,
17
17
  drawingProviderProps,
18
- colorProviderProps,
19
18
  seriesProviderProps,
20
19
  cartesianContextProps,
21
20
  zAxisContextProps,
22
21
  highlightedProviderProps,
23
- chartsSurfaceProps
22
+ chartsSurfaceProps,
23
+ pluginProviderProps
24
24
  } = useChartContainerProps(props, ref);
25
25
  return /*#__PURE__*/_jsx(DrawingProvider, _extends({}, drawingProviderProps, {
26
- children: /*#__PURE__*/_jsx(ColorProvider, _extends({}, colorProviderProps, {
26
+ children: /*#__PURE__*/_jsx(PluginProvider, _extends({}, pluginProviderProps, {
27
27
  children: /*#__PURE__*/_jsx(SeriesProvider, _extends({}, seriesProviderProps, {
28
28
  children: /*#__PURE__*/_jsx(CartesianContextProvider, _extends({}, cartesianContextProps, {
29
29
  children: /*#__PURE__*/_jsx(ZAxisContextProvider, _extends({}, zAxisContextProps, {