@mui/x-charts 7.6.0 → 7.6.2

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 (199) hide show
  1. package/BarChart/BarChart.d.ts +1 -1
  2. package/BarChart/BarChart.js +2 -2
  3. package/BarChart/BarPlot.js +2 -2
  4. package/BarChart/formatter.js +2 -2
  5. package/BarChart/getColor.d.ts +1 -1
  6. package/BarChart/getColor.js +4 -4
  7. package/BarChart/plugin.d.ts +2 -0
  8. package/BarChart/plugin.js +17 -0
  9. package/CHANGELOG.md +91 -0
  10. package/ChartContainer/ChartContainer.d.ts +14 -2
  11. package/ChartContainer/ChartContainer.js +13 -2
  12. package/ChartContainer/defaultPlugins.d.ts +2 -0
  13. package/ChartContainer/defaultPlugins.js +11 -0
  14. package/ChartContainer/usePluginsMerge.d.ts +10 -0
  15. package/ChartContainer/usePluginsMerge.js +39 -0
  16. package/ChartsLegend/ChartsLegend.js +2 -2
  17. package/ChartsLegend/utils.js +4 -1
  18. package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +4 -4
  19. package/ChartsTooltip/ChartsAxisTooltipContent.js +4 -4
  20. package/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
  21. package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -1
  22. package/ChartsTooltip/utils.d.ts +1 -7
  23. package/ChartsTooltip/utils.js +2 -10
  24. package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -2
  25. package/ChartsXAxis/ChartsXAxis.js +17 -19
  26. package/ChartsYAxis/ChartsYAxis.js +17 -19
  27. package/LineChart/AreaPlot.js +2 -2
  28. package/LineChart/LineChart.d.ts +1 -1
  29. package/LineChart/LineChart.js +2 -2
  30. package/LineChart/LineHighlightPlot.js +2 -2
  31. package/LineChart/LinePlot.js +2 -2
  32. package/LineChart/MarkPlot.js +2 -2
  33. package/LineChart/formatter.js +2 -2
  34. package/LineChart/getColor.d.ts +1 -1
  35. package/LineChart/getColor.js +2 -2
  36. package/LineChart/plugin.d.ts +2 -0
  37. package/LineChart/plugin.js +17 -0
  38. package/PieChart/PieChart.d.ts +1 -1
  39. package/PieChart/PieChart.js +2 -2
  40. package/PieChart/PiePlot.js +2 -2
  41. package/PieChart/plugin.d.ts +2 -0
  42. package/PieChart/plugin.js +14 -0
  43. package/ResponsiveChartContainer/ResponsiveChartContainer.js +7 -2
  44. package/ScatterChart/ScatterChart.d.ts +1 -1
  45. package/ScatterChart/ScatterChart.js +2 -2
  46. package/ScatterChart/ScatterPlot.js +2 -2
  47. package/ScatterChart/formatter.js +2 -3
  48. package/ScatterChart/getColor.d.ts +1 -1
  49. package/ScatterChart/getColor.js +2 -2
  50. package/ScatterChart/plugin.d.ts +2 -0
  51. package/ScatterChart/plugin.js +17 -0
  52. package/SparkLineChart/SparkLineChart.d.ts +3 -3
  53. package/SparkLineChart/SparkLineChart.js +1 -1
  54. package/context/CartesianContextProvider.d.ts +13 -10
  55. package/context/CartesianContextProvider.js +2 -2
  56. package/context/DrawingProvider.d.ts +3 -1
  57. package/context/DrawingProvider.js +9 -2
  58. package/context/HighlightedProvider/HighlightedContext.d.ts +2 -1
  59. package/context/HighlightedProvider/HighlightedContext.js +8 -5
  60. package/context/HighlightedProvider/HighlightedProvider.js +15 -12
  61. package/context/HighlightedProvider/useHighlighted.js +6 -3
  62. package/context/HighlightedProvider/useItemHighlighted.js +2 -8
  63. package/context/SeriesContextProvider.d.ts +16 -5
  64. package/context/SeriesContextProvider.js +14 -17
  65. package/context/context.types.d.ts +4 -0
  66. package/context/context.types.js +5 -0
  67. package/esm/BarChart/BarChart.js +2 -2
  68. package/esm/BarChart/BarPlot.js +2 -2
  69. package/esm/BarChart/formatter.js +1 -1
  70. package/esm/BarChart/getColor.js +4 -4
  71. package/esm/BarChart/plugin.js +10 -0
  72. package/esm/ChartContainer/ChartContainer.js +13 -2
  73. package/esm/ChartContainer/defaultPlugins.js +5 -0
  74. package/esm/ChartContainer/usePluginsMerge.js +31 -0
  75. package/esm/ChartsLegend/ChartsLegend.js +2 -2
  76. package/esm/ChartsLegend/utils.js +4 -1
  77. package/esm/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +4 -4
  78. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +3 -3
  79. package/esm/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
  80. package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -1
  81. package/esm/ChartsTooltip/utils.js +2 -8
  82. package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -2
  83. package/esm/ChartsXAxis/ChartsXAxis.js +17 -19
  84. package/esm/ChartsYAxis/ChartsYAxis.js +17 -19
  85. package/esm/LineChart/AreaPlot.js +2 -2
  86. package/esm/LineChart/LineChart.js +2 -2
  87. package/esm/LineChart/LineHighlightPlot.js +2 -2
  88. package/esm/LineChart/LinePlot.js +2 -2
  89. package/esm/LineChart/MarkPlot.js +2 -2
  90. package/esm/LineChart/formatter.js +1 -1
  91. package/esm/LineChart/getColor.js +2 -2
  92. package/esm/LineChart/plugin.js +10 -0
  93. package/esm/PieChart/PieChart.js +2 -2
  94. package/esm/PieChart/PiePlot.js +2 -2
  95. package/esm/PieChart/plugin.js +7 -0
  96. package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +7 -2
  97. package/esm/ScatterChart/ScatterChart.js +2 -2
  98. package/esm/ScatterChart/ScatterPlot.js +2 -2
  99. package/esm/ScatterChart/formatter.js +1 -1
  100. package/esm/ScatterChart/getColor.js +2 -2
  101. package/esm/ScatterChart/plugin.js +10 -0
  102. package/esm/SparkLineChart/SparkLineChart.js +1 -1
  103. package/esm/context/CartesianContextProvider.js +2 -2
  104. package/esm/context/DrawingProvider.js +9 -2
  105. package/esm/context/HighlightedProvider/HighlightedContext.js +8 -5
  106. package/esm/context/HighlightedProvider/HighlightedProvider.js +15 -12
  107. package/esm/context/HighlightedProvider/useHighlighted.js +6 -3
  108. package/esm/context/HighlightedProvider/useItemHighlighted.js +2 -6
  109. package/esm/context/SeriesContextProvider.js +14 -17
  110. package/esm/context/context.types.js +1 -0
  111. package/esm/hooks/useInteractionItemProps.js +2 -2
  112. package/esm/hooks/useSeries.js +6 -3
  113. package/esm/hooks/useSvgRef.js +6 -3
  114. package/esm/internals/configInit.js +20 -0
  115. package/esm/internals/defaultizeValueFormatter.js +2 -3
  116. package/esm/internals/index.js +1 -0
  117. package/esm/internals/isCartesian.js +7 -0
  118. package/esm/models/index.js +1 -0
  119. package/esm/models/plugin.js +1 -0
  120. package/esm/models/seriesType/index.js +6 -0
  121. package/hooks/useInteractionItemProps.js +1 -1
  122. package/hooks/useSeries.d.ts +6 -11
  123. package/hooks/useSeries.js +6 -3
  124. package/hooks/useSvgRef.js +6 -3
  125. package/hooks/useTicks.d.ts +4 -2
  126. package/index.js +1 -1
  127. package/internals/configInit.d.ts +9 -0
  128. package/internals/configInit.js +26 -0
  129. package/internals/defaultizeValueFormatter.d.ts +1 -2
  130. package/internals/defaultizeValueFormatter.js +2 -3
  131. package/internals/index.d.ts +1 -0
  132. package/internals/index.js +16 -0
  133. package/internals/isCartesian.d.ts +7 -0
  134. package/internals/isCartesian.js +14 -0
  135. package/internals/package.json +6 -0
  136. package/models/axis.d.ts +3 -3
  137. package/models/index.d.ts +1 -0
  138. package/models/index.js +11 -0
  139. package/models/plugin.d.ts +16 -0
  140. package/models/plugin.js +5 -0
  141. package/models/seriesType/config.d.ts +30 -5
  142. package/models/seriesType/index.d.ts +8 -11
  143. package/models/seriesType/index.js +6 -0
  144. package/modern/BarChart/BarChart.js +2 -2
  145. package/modern/BarChart/BarPlot.js +2 -2
  146. package/modern/BarChart/formatter.js +1 -1
  147. package/modern/BarChart/getColor.js +4 -4
  148. package/modern/BarChart/plugin.js +10 -0
  149. package/modern/ChartContainer/ChartContainer.js +13 -2
  150. package/modern/ChartContainer/defaultPlugins.js +5 -0
  151. package/modern/ChartContainer/usePluginsMerge.js +31 -0
  152. package/modern/ChartsLegend/ChartsLegend.js +2 -2
  153. package/modern/ChartsLegend/utils.js +4 -1
  154. package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +4 -4
  155. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +3 -3
  156. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
  157. package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -1
  158. package/modern/ChartsTooltip/utils.js +2 -8
  159. package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -2
  160. package/modern/ChartsXAxis/ChartsXAxis.js +17 -19
  161. package/modern/ChartsYAxis/ChartsYAxis.js +17 -19
  162. package/modern/LineChart/AreaPlot.js +2 -2
  163. package/modern/LineChart/LineChart.js +2 -2
  164. package/modern/LineChart/LineHighlightPlot.js +2 -2
  165. package/modern/LineChart/LinePlot.js +2 -2
  166. package/modern/LineChart/MarkPlot.js +2 -2
  167. package/modern/LineChart/formatter.js +1 -1
  168. package/modern/LineChart/getColor.js +2 -2
  169. package/modern/LineChart/plugin.js +10 -0
  170. package/modern/PieChart/PieChart.js +2 -2
  171. package/modern/PieChart/PiePlot.js +2 -2
  172. package/modern/PieChart/plugin.js +7 -0
  173. package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +7 -2
  174. package/modern/ScatterChart/ScatterChart.js +2 -2
  175. package/modern/ScatterChart/ScatterPlot.js +2 -2
  176. package/modern/ScatterChart/formatter.js +1 -1
  177. package/modern/ScatterChart/getColor.js +2 -2
  178. package/modern/ScatterChart/plugin.js +10 -0
  179. package/modern/SparkLineChart/SparkLineChart.js +1 -1
  180. package/modern/context/CartesianContextProvider.js +2 -2
  181. package/modern/context/DrawingProvider.js +9 -2
  182. package/modern/context/HighlightedProvider/HighlightedContext.js +8 -5
  183. package/modern/context/HighlightedProvider/HighlightedProvider.js +15 -12
  184. package/modern/context/HighlightedProvider/useHighlighted.js +6 -3
  185. package/modern/context/HighlightedProvider/useItemHighlighted.js +2 -6
  186. package/modern/context/SeriesContextProvider.js +14 -17
  187. package/modern/context/context.types.js +1 -0
  188. package/modern/hooks/useInteractionItemProps.js +2 -2
  189. package/modern/hooks/useSeries.js +6 -3
  190. package/modern/hooks/useSvgRef.js +6 -3
  191. package/modern/index.js +1 -1
  192. package/modern/internals/configInit.js +20 -0
  193. package/modern/internals/defaultizeValueFormatter.js +2 -3
  194. package/modern/internals/index.js +1 -0
  195. package/modern/internals/isCartesian.js +7 -0
  196. package/modern/models/index.js +1 -0
  197. package/modern/models/plugin.js +1 -0
  198. package/modern/models/seriesType/index.js +6 -0
  199. package/package.json +1 -1
@@ -4,11 +4,11 @@ import { Delaunay } from 'd3-delaunay';
4
4
  import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
5
5
  import { InteractionContext } from '../context/InteractionProvider';
6
6
  import { CartesianContext } from '../context/CartesianContextProvider';
7
- import { SeriesContext } from '../context/SeriesContextProvider';
8
7
  import { getValueToPositionMapper } from '../hooks/useScale';
9
8
  import { getSVGPoint } from '../internals/utils';
10
9
  import { useDrawingArea, useSvgRef } from '../hooks';
11
10
  import { useHighlighted } from '../context';
11
+ import { useScatterSeries } from '../hooks/useSeries';
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  function ChartsVoronoiHandler(props) {
14
14
  const {
@@ -34,7 +34,7 @@ function ChartsVoronoiHandler(props) {
34
34
  const {
35
35
  series,
36
36
  seriesOrder
37
- } = React.useContext(SeriesContext).scatter ?? {};
37
+ } = useScatterSeries() ?? {};
38
38
  const voronoiRef = React.useRef({});
39
39
  const delauneyRef = React.useRef(undefined);
40
40
  const {
@@ -104,27 +104,23 @@ const defaultProps = {
104
104
  * - [ChartsXAxis API](https://mui.com/x/api/charts/charts-x-axis/)
105
105
  */
106
106
  function ChartsXAxis(inProps) {
107
- const props = useThemeProps({
108
- props: _extends({}, defaultProps, inProps),
109
- name: 'MuiChartsXAxis'
110
- });
111
107
  const {
112
- xAxisIds
108
+ xAxisIds,
109
+ xAxis
113
110
  } = React.useContext(CartesianContext);
114
- const _React$useContext = React.useContext(CartesianContext),
115
- _ref = props.axisId ?? xAxisIds[0],
111
+ const _xAxis = xAxis[inProps.axisId ?? xAxisIds[0]],
116
112
  {
117
- xAxis: {
118
- [_ref]: {
119
- scale: xScale,
120
- tickNumber,
121
- reverse
122
- }
123
- }
124
- } = _React$useContext,
125
- settings = _objectWithoutPropertiesLoose(_React$useContext.xAxis[_ref], _excluded);
113
+ scale: xScale,
114
+ tickNumber,
115
+ reverse
116
+ } = _xAxis,
117
+ settings = _objectWithoutPropertiesLoose(_xAxis, _excluded);
126
118
  const isMounted = useMounted();
127
- const defaultizedProps = _extends({}, defaultProps, settings, props);
119
+ const themedProps = useThemeProps({
120
+ props: _extends({}, settings, inProps),
121
+ name: 'MuiChartsXAxis'
122
+ });
123
+ const defaultizedProps = _extends({}, defaultProps, themedProps);
128
124
  const {
129
125
  position,
130
126
  disableLine,
@@ -314,10 +310,12 @@ process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
314
310
  */
315
311
  tickFontSize: PropTypes.number,
316
312
  /**
317
- * Defines which ticks are displayed. Its value can be:
313
+ * Defines which ticks are displayed.
314
+ * Its value can be:
318
315
  * - 'auto' In such case the ticks are computed based on axis scale and other parameters.
319
- * - a filtering function of the form `(value, index) => boolean` which is available only if the axis has a data property.
316
+ * - a filtering function of the form `(value, index) => boolean` which is available only if the axis has "point" scale.
320
317
  * - an array containing the values where ticks should be displayed.
318
+ * @see See {@link https://mui.com/x/react-charts/axis/#fixed-tick-positions}
321
319
  * @default 'auto'
322
320
  */
323
321
  tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
@@ -1,5 +1,5 @@
1
- import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
3
  const _excluded = ["scale", "tickNumber"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
@@ -47,25 +47,21 @@ const defaultProps = {
47
47
  * - [ChartsYAxis API](https://mui.com/x/api/charts/charts-y-axis/)
48
48
  */
49
49
  function ChartsYAxis(inProps) {
50
- const props = useThemeProps({
51
- props: _extends({}, defaultProps, inProps),
52
- name: 'MuiChartsYAxis'
53
- });
54
50
  const {
55
- yAxisIds
51
+ yAxisIds,
52
+ yAxis
56
53
  } = React.useContext(CartesianContext);
57
- const _React$useContext = React.useContext(CartesianContext),
58
- _ref = props.axisId ?? yAxisIds[0],
54
+ const _yAxis = yAxis[inProps.axisId ?? yAxisIds[0]],
59
55
  {
60
- yAxis: {
61
- [_ref]: {
62
- scale: yScale,
63
- tickNumber
64
- }
65
- }
66
- } = _React$useContext,
67
- settings = _objectWithoutPropertiesLoose(_React$useContext.yAxis[_ref], _excluded);
68
- const defaultizedProps = _extends({}, defaultProps, settings, props);
56
+ scale: yScale,
57
+ tickNumber
58
+ } = _yAxis,
59
+ settings = _objectWithoutPropertiesLoose(_yAxis, _excluded);
60
+ const themedProps = useThemeProps({
61
+ props: _extends({}, settings, inProps),
62
+ name: 'MuiChartsYAxis'
63
+ });
64
+ const defaultizedProps = _extends({}, defaultProps, themedProps);
69
65
  const {
70
66
  position,
71
67
  disableLine,
@@ -250,10 +246,12 @@ process.env.NODE_ENV !== "production" ? ChartsYAxis.propTypes = {
250
246
  */
251
247
  tickFontSize: PropTypes.number,
252
248
  /**
253
- * Defines which ticks are displayed. Its value can be:
249
+ * Defines which ticks are displayed.
250
+ * Its value can be:
254
251
  * - 'auto' In such case the ticks are computed based on axis scale and other parameters.
255
- * - a filtering function of the form `(value, index) => boolean` which is available only if the axis has a data property.
252
+ * - a filtering function of the form `(value, index) => boolean` which is available only if the axis has "point" scale.
256
253
  * - an array containing the values where ticks should be displayed.
254
+ * @see See {@link https://mui.com/x/react-charts/axis/#fixed-tick-positions}
257
255
  * @default 'auto'
258
256
  */
259
257
  tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
@@ -4,16 +4,16 @@ const _excluded = ["slots", "slotProps", "onItemClick", "skipAnimation"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import { area as d3Area } from 'd3-shape';
7
- import { SeriesContext } from '../context/SeriesContextProvider';
8
7
  import { CartesianContext } from '../context/CartesianContextProvider';
9
8
  import { AreaElement } from './AreaElement';
10
9
  import { getValueToPositionMapper } from '../hooks/useScale';
11
10
  import getCurveFactory from '../internals/getCurve';
12
11
  import { DEFAULT_X_AXIS_KEY } from '../constants';
13
12
  import { useChartGradient } from '../internals/components/ChartsAxesGradients';
13
+ import { useLineSeries } from '../hooks/useSeries';
14
14
  import { jsx as _jsx } from "react/jsx-runtime";
15
15
  const useAggregatedData = () => {
16
- const seriesData = React.useContext(SeriesContext).line;
16
+ const seriesData = useLineSeries();
17
17
  const axisData = React.useContext(CartesianContext);
18
18
  if (seriesData === undefined) {
19
19
  return [];
@@ -348,7 +348,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
348
348
  labelStyle: PropTypes.object,
349
349
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
350
350
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
351
- position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
351
+ position: PropTypes.oneOf(['bottom', 'top']),
352
352
  reverse: PropTypes.bool,
353
353
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
354
354
  slotProps: PropTypes.object,
@@ -401,7 +401,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
401
401
  labelStyle: PropTypes.object,
402
402
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
403
403
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
404
- position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
404
+ position: PropTypes.oneOf(['left', 'right']),
405
405
  reverse: PropTypes.bool,
406
406
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
407
407
  slotProps: PropTypes.object,
@@ -3,13 +3,13 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
3
3
  const _excluded = ["slots", "slotProps"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
- import { SeriesContext } from '../context/SeriesContextProvider';
7
6
  import { CartesianContext } from '../context/CartesianContextProvider';
8
7
  import { LineHighlightElement } from './LineHighlightElement';
9
8
  import { getValueToPositionMapper } from '../hooks/useScale';
10
9
  import { InteractionContext } from '../context/InteractionProvider';
11
10
  import { DEFAULT_X_AXIS_KEY } from '../constants';
12
11
  import getColor from './getColor';
12
+ import { useLineSeries } from '../hooks/useSeries';
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  /**
15
15
  * Demos:
@@ -27,7 +27,7 @@ function LineHighlightPlot(props) {
27
27
  slotProps
28
28
  } = props,
29
29
  other = _objectWithoutPropertiesLoose(props, _excluded);
30
- const seriesData = React.useContext(SeriesContext).line;
30
+ const seriesData = useLineSeries();
31
31
  const axisData = React.useContext(CartesianContext);
32
32
  const {
33
33
  axis
@@ -4,16 +4,16 @@ const _excluded = ["slots", "slotProps", "skipAnimation", "onItemClick"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import { line as d3Line } from 'd3-shape';
7
- import { SeriesContext } from '../context/SeriesContextProvider';
8
7
  import { CartesianContext } from '../context/CartesianContextProvider';
9
8
  import { LineElement } from './LineElement';
10
9
  import { getValueToPositionMapper } from '../hooks/useScale';
11
10
  import getCurveFactory from '../internals/getCurve';
12
11
  import { DEFAULT_X_AXIS_KEY } from '../constants';
13
12
  import { useChartGradient } from '../internals/components/ChartsAxesGradients';
13
+ import { useLineSeries } from '../hooks/useSeries';
14
14
  import { jsx as _jsx } from "react/jsx-runtime";
15
15
  const useAggregatedData = () => {
16
- const seriesData = React.useContext(SeriesContext).line;
16
+ const seriesData = useLineSeries();
17
17
  const axisData = React.useContext(CartesianContext);
18
18
  if (seriesData === undefined) {
19
19
  return [];
@@ -3,7 +3,6 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
3
3
  const _excluded = ["slots", "slotProps", "skipAnimation", "onItemClick"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
- import { SeriesContext } from '../context/SeriesContextProvider';
7
6
  import { CartesianContext } from '../context/CartesianContextProvider';
8
7
  import { MarkElement } from './MarkElement';
9
8
  import { getValueToPositionMapper } from '../hooks/useScale';
@@ -11,6 +10,7 @@ import { useChartId } from '../hooks/useChartId';
11
10
  import { DEFAULT_X_AXIS_KEY } from '../constants';
12
11
  import { cleanId } from '../internals/utils';
13
12
  import getColor from './getColor';
13
+ import { useLineSeries } from '../hooks/useSeries';
14
14
  import { jsx as _jsx } from "react/jsx-runtime";
15
15
  /**
16
16
  * Demos:
@@ -30,7 +30,7 @@ function MarkPlot(props) {
30
30
  onItemClick
31
31
  } = props,
32
32
  other = _objectWithoutPropertiesLoose(props, _excluded);
33
- const seriesData = React.useContext(SeriesContext).line;
33
+ const seriesData = useLineSeries();
34
34
  const axisData = React.useContext(CartesianContext);
35
35
  const chartId = useChartId();
36
36
  const Mark = slots?.mark ?? MarkElement;
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import { stack as d3Stack } from 'd3-shape';
3
3
  import { getStackingGroups } from '../internals/stackSeries';
4
- import defaultizeValueFormatter from '../internals/defaultizeValueFormatter';
4
+ import { defaultizeValueFormatter } from '../internals/defaultizeValueFormatter';
5
5
  let warnedOnce = false;
6
6
 
7
7
  // For now it's a copy past of bar charts formatter, but maybe will diverge later
@@ -1,6 +1,6 @@
1
1
  export default function getColor(series, xAxis, yAxis) {
2
- const yColorScale = yAxis.colorScale;
3
- const xColorScale = xAxis.colorScale;
2
+ const yColorScale = yAxis?.colorScale;
3
+ const xColorScale = xAxis?.colorScale;
4
4
  if (yColorScale) {
5
5
  return dataIndex => {
6
6
  const value = series.data[dataIndex];
@@ -0,0 +1,10 @@
1
+ import { getExtremumX, getExtremumY } from './extremums';
2
+ import formatter from './formatter';
3
+ import getColor from './getColor';
4
+ export const plugin = {
5
+ seriesType: 'line',
6
+ colorProcessor: getColor,
7
+ seriesFormatter: formatter,
8
+ xExtremumGetter: getExtremumX,
9
+ yExtremumGetter: getExtremumY
10
+ };
@@ -307,7 +307,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
307
307
  labelStyle: PropTypes.object,
308
308
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
309
309
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
310
- position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
310
+ position: PropTypes.oneOf(['bottom', 'top']),
311
311
  reverse: PropTypes.bool,
312
312
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
313
313
  slotProps: PropTypes.object,
@@ -360,7 +360,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
360
360
  labelStyle: PropTypes.object,
361
361
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
362
362
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
363
- position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
363
+ position: PropTypes.oneOf(['left', 'right']),
364
364
  reverse: PropTypes.bool,
365
365
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
366
366
  slotProps: PropTypes.object,
@@ -1,11 +1,11 @@
1
1
  import * as React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { SeriesContext } from '../context/SeriesContextProvider';
4
3
  import { DrawingContext } from '../context/DrawingProvider';
5
4
  import { PieArcPlot } from './PieArcPlot';
6
5
  import { PieArcLabelPlot } from './PieArcLabelPlot';
7
6
  import { getPercentageValue } from '../internals/utils';
8
7
  import { getPieCoordinates } from './getPieCoordinates';
8
+ import { usePieSeries } from '../hooks/useSeries';
9
9
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
10
  /**
11
11
  * Demos:
@@ -24,7 +24,7 @@ function PiePlot(props) {
24
24
  slotProps,
25
25
  onItemClick
26
26
  } = props;
27
- const seriesData = React.useContext(SeriesContext).pie;
27
+ const seriesData = usePieSeries();
28
28
  const {
29
29
  left,
30
30
  top,
@@ -0,0 +1,7 @@
1
+ import formatter from './formatter';
2
+ import getColor from './getColor';
3
+ export const plugin = {
4
+ seriesType: 'pie',
5
+ colorProcessor: getColor,
6
+ seriesFormatter: formatter
7
+ };
@@ -99,6 +99,11 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
99
99
  * @param {HighlightItemData | null} highlightedItem The newly highlighted item.
100
100
  */
101
101
  onHighlightChange: PropTypes.func,
102
+ /**
103
+ * An array of plugins defining how to preprocess data.
104
+ * If not provided, the container supports line, bar, scatter and pie charts.
105
+ */
106
+ plugins: PropTypes.arrayOf(PropTypes.object),
102
107
  /**
103
108
  * The array of series to display.
104
109
  * Each type of series has its own specificity.
@@ -152,7 +157,7 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
152
157
  labelStyle: PropTypes.object,
153
158
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
154
159
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
155
- position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
160
+ position: PropTypes.oneOf(['bottom', 'top']),
156
161
  reverse: PropTypes.bool,
157
162
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
158
163
  slotProps: PropTypes.object,
@@ -205,7 +210,7 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
205
210
  labelStyle: PropTypes.object,
206
211
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
207
212
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
208
- position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
213
+ position: PropTypes.oneOf(['left', 'right']),
209
214
  reverse: PropTypes.bool,
210
215
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
211
216
  slotProps: PropTypes.object,
@@ -302,7 +302,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
302
302
  labelStyle: PropTypes.object,
303
303
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
304
304
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
305
- position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
305
+ position: PropTypes.oneOf(['bottom', 'top']),
306
306
  reverse: PropTypes.bool,
307
307
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
308
308
  slotProps: PropTypes.object,
@@ -355,7 +355,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
355
355
  labelStyle: PropTypes.object,
356
356
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
357
357
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
358
- position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
358
+ position: PropTypes.oneOf(['left', 'right']),
359
359
  reverse: PropTypes.bool,
360
360
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
361
361
  slotProps: PropTypes.object,
@@ -2,10 +2,10 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import { Scatter } from './Scatter';
5
- import { SeriesContext } from '../context/SeriesContextProvider';
6
5
  import { CartesianContext } from '../context/CartesianContextProvider';
7
6
  import getColor from './getColor';
8
7
  import { ZAxisContext } from '../context/ZAxisContextProvider';
8
+ import { useScatterSeries } from '../hooks/useSeries';
9
9
  import { jsx as _jsx } from "react/jsx-runtime";
10
10
  /**
11
11
  * Demos:
@@ -23,7 +23,7 @@ function ScatterPlot(props) {
23
23
  slotProps,
24
24
  onItemClick
25
25
  } = props;
26
- const seriesData = React.useContext(SeriesContext).scatter;
26
+ const seriesData = useScatterSeries();
27
27
  const axisData = React.useContext(CartesianContext);
28
28
  const {
29
29
  zAxis,
@@ -1,4 +1,4 @@
1
- import defaultizeValueFormatter from '../internals/defaultizeValueFormatter';
1
+ import { defaultizeValueFormatter } from '../internals/defaultizeValueFormatter';
2
2
  const formatter = ({
3
3
  series,
4
4
  seriesOrder
@@ -1,7 +1,7 @@
1
1
  export default function getColor(series, xAxis, yAxis, zAxis) {
2
2
  const zColorScale = zAxis?.colorScale;
3
- const yColorScale = yAxis.colorScale;
4
- const xColorScale = xAxis.colorScale;
3
+ const yColorScale = yAxis?.colorScale;
4
+ const xColorScale = xAxis?.colorScale;
5
5
  if (zColorScale) {
6
6
  return dataIndex => {
7
7
  if (zAxis?.data?.[dataIndex] !== undefined) {
@@ -0,0 +1,10 @@
1
+ import { getExtremumX, getExtremumY } from './extremums';
2
+ import formatter from './formatter';
3
+ import getColor from './getColor';
4
+ export const plugin = {
5
+ seriesType: 'scatter',
6
+ seriesFormatter: formatter,
7
+ colorProcessor: getColor,
8
+ xExtremumGetter: getExtremumX,
9
+ yExtremumGetter: getExtremumY
10
+ };
@@ -265,7 +265,7 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
265
265
  labelStyle: PropTypes.object,
266
266
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
267
267
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
268
- position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
268
+ position: PropTypes.oneOf(['bottom', 'top']),
269
269
  reverse: PropTypes.bool,
270
270
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
271
271
  slotProps: PropTypes.object,
@@ -6,11 +6,11 @@ import { getExtremumX as getScatterExtremumX, getExtremumY as getScatterExtremum
6
6
  import { getExtremumX as getLineExtremumX, getExtremumY as getLineExtremumY } from '../LineChart/extremums';
7
7
  import { isBandScaleConfig, isPointScaleConfig } from '../models/axis';
8
8
  import { getScale } from '../internals/getScale';
9
- import { SeriesContext } from './SeriesContextProvider';
10
9
  import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from '../constants';
11
10
  import { getTickNumber } from '../hooks/useTicks';
12
11
  import { useDrawingArea } from '../hooks/useDrawingArea';
13
12
  import { getColorScale, getOrdinalColorScale } from '../internals/colorScale';
13
+ import { useSeries } from '../hooks/useSeries';
14
14
  import { jsx as _jsx } from "react/jsx-runtime";
15
15
  const DEFAULT_CATEGORY_GAP_RATIO = 0.2;
16
16
  const DEFAULT_BAR_GAP_RATIO = 0.1;
@@ -42,7 +42,7 @@ function CartesianContextProvider(props) {
42
42
  dataset,
43
43
  children
44
44
  } = props;
45
- const formattedSeries = React.useContext(SeriesContext);
45
+ const formattedSeries = useSeries();
46
46
  const drawingArea = useDrawingArea();
47
47
  const xAxis = React.useMemo(() => inXAxis?.map(axisConfig => {
48
48
  const dataKey = axisConfig.dataKey;
@@ -20,7 +20,10 @@ if (process.env.NODE_ENV !== 'production') {
20
20
  DrawingContext.displayName = 'DrawingContext';
21
21
  }
22
22
  export const SvgContext = /*#__PURE__*/React.createContext({
23
- current: null
23
+ isInitialized: false,
24
+ data: {
25
+ current: null
26
+ }
24
27
  });
25
28
  if (process.env.NODE_ENV !== 'production') {
26
29
  SvgContext.displayName = 'SvgContext';
@@ -38,8 +41,12 @@ export function DrawingProvider(props) {
38
41
  const value = React.useMemo(() => _extends({
39
42
  chartId: chartId ?? ''
40
43
  }, drawingArea), [chartId, drawingArea]);
44
+ const refValue = React.useMemo(() => ({
45
+ isInitialized: true,
46
+ data: svgRef
47
+ }), [svgRef]);
41
48
  return /*#__PURE__*/_jsx(SvgContext.Provider, {
42
- value: svgRef,
49
+ value: refValue,
43
50
  children: /*#__PURE__*/_jsx(DrawingContext.Provider, {
44
51
  value: value,
45
52
  children: children
@@ -18,11 +18,14 @@ import * as React from 'react';
18
18
  */
19
19
 
20
20
  export const HighlightedContext = /*#__PURE__*/React.createContext({
21
- highlightedItem: null,
22
- setHighlighted: () => {},
23
- clearHighlighted: () => {},
24
- isHighlighted: () => false,
25
- isFaded: () => false
21
+ isInitialized: false,
22
+ data: {
23
+ highlightedItem: null,
24
+ setHighlighted: () => {},
25
+ clearHighlighted: () => {},
26
+ isHighlighted: () => false,
27
+ isFaded: () => false
28
+ }
26
29
  });
27
30
  if (process.env.NODE_ENV !== 'production') {
28
31
  HighlightedContext.displayName = 'HighlightedContext';
@@ -47,18 +47,21 @@ function HighlightedProvider({
47
47
  const highlightScope = highlightedItem && highlightedItem.seriesId ? seriesById.get(highlightedItem.seriesId) ?? undefined : undefined;
48
48
  const providerValue = React.useMemo(() => {
49
49
  return {
50
- highlightScope,
51
- highlightedItem,
52
- setHighlighted: itemData => {
53
- setHighlightedItem(itemData);
54
- onHighlightChange?.(itemData);
55
- },
56
- clearHighlighted: () => {
57
- setHighlightedItem(null);
58
- onHighlightChange?.(null);
59
- },
60
- isHighlighted: createIsHighlighted(highlightScope, highlightedItem),
61
- isFaded: createIsFaded(highlightScope, highlightedItem)
50
+ isInitialized: true,
51
+ data: {
52
+ highlightScope,
53
+ highlightedItem,
54
+ setHighlighted: itemData => {
55
+ setHighlightedItem(itemData);
56
+ onHighlightChange?.(itemData);
57
+ },
58
+ clearHighlighted: () => {
59
+ setHighlightedItem(null);
60
+ onHighlightChange?.(null);
61
+ },
62
+ isHighlighted: createIsHighlighted(highlightScope, highlightedItem),
63
+ isFaded: createIsFaded(highlightScope, highlightedItem)
64
+ }
62
65
  };
63
66
  }, [highlightedItem, highlightScope, setHighlightedItem, onHighlightChange]);
64
67
  return /*#__PURE__*/_jsx(HighlightedContext.Provider, {
@@ -9,9 +9,12 @@ import { HighlightedContext } from './HighlightedContext';
9
9
  * @returns {HighlightedState} the state of the chart
10
10
  */
11
11
  export function useHighlighted() {
12
- const highlighted = React.useContext(HighlightedContext);
13
- if (highlighted === undefined) {
12
+ const {
13
+ isInitialized,
14
+ data
15
+ } = React.useContext(HighlightedContext);
16
+ if (!isInitialized) {
14
17
  throw new Error(['MUI X: Could not find the highlighted ref context.', 'It looks like you rendered your component outside of a ChartsContainer parent component.'].join('\n'));
15
18
  }
16
- return highlighted;
19
+ return data;
17
20
  }
@@ -1,5 +1,4 @@
1
- import * as React from 'react';
2
- import { HighlightedContext } from './HighlightedContext';
1
+ import { useHighlighted } from './useHighlighted';
3
2
  /**
4
3
  * A hook to check the highlighted state of the item.
5
4
  * This function already calculates that an item is not faded if it is highlighted.
@@ -10,10 +9,7 @@ import { HighlightedContext } from './HighlightedContext';
10
9
  * @returns {ItemHighlightedState} the state of the item
11
10
  */
12
11
  export function useItemHighlighted(item) {
13
- const highlighted = React.useContext(HighlightedContext);
14
- if (highlighted === undefined) {
15
- throw new Error(['MUI X: Could not find the highlighted ref context.', 'It looks like you rendered your component outside of a ChartsContainer parent component.'].join('\n'));
16
- }
12
+ const highlighted = useHighlighted();
17
13
  if (!item) {
18
14
  return {
19
15
  isHighlighted: false,