@mui/x-charts 7.6.1 → 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 (245) 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 +147 -0
  10. package/ChartContainer/ChartContainer.d.ts +15 -3
  11. package/ChartContainer/ChartContainer.js +70 -22
  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/ChartsOverlay/index.d.ts +1 -0
  20. package/ChartsReferenceLine/ChartsXReferenceLine.js +3 -5
  21. package/ChartsReferenceLine/ChartsYReferenceLine.js +3 -5
  22. package/ChartsText/ChartsText.js +1 -3
  23. package/ChartsTooltip/ChartsAxisTooltipContent.js +9 -15
  24. package/ChartsTooltip/ChartsItemTooltipContent.js +8 -18
  25. package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +5 -4
  26. package/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
  27. package/ChartsTooltip/utils.d.ts +1 -7
  28. package/ChartsTooltip/utils.js +2 -10
  29. package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -2
  30. package/ChartsXAxis/ChartsXAxis.js +17 -19
  31. package/ChartsYAxis/ChartsYAxis.js +17 -19
  32. package/LineChart/AreaPlot.js +2 -2
  33. package/LineChart/LineChart.d.ts +2 -2
  34. package/LineChart/LineChart.js +3 -3
  35. package/LineChart/LineHighlightPlot.js +2 -2
  36. package/LineChart/LinePlot.js +2 -2
  37. package/LineChart/MarkPlot.js +2 -2
  38. package/LineChart/formatter.js +2 -2
  39. package/LineChart/getColor.d.ts +1 -1
  40. package/LineChart/getColor.js +2 -2
  41. package/LineChart/plugin.d.ts +2 -0
  42. package/LineChart/plugin.js +17 -0
  43. package/PieChart/PieChart.d.ts +2 -2
  44. package/PieChart/PieChart.js +3 -3
  45. package/PieChart/PiePlot.js +2 -2
  46. package/PieChart/plugin.d.ts +2 -0
  47. package/PieChart/plugin.js +14 -0
  48. package/ResponsiveChartContainer/ResizableContainer.d.ts +10 -0
  49. package/ResponsiveChartContainer/ResizableContainer.js +32 -0
  50. package/ResponsiveChartContainer/ResponsiveChartContainer.js +32 -24
  51. package/ScatterChart/ScatterChart.d.ts +2 -2
  52. package/ScatterChart/ScatterChart.js +3 -3
  53. package/ScatterChart/ScatterPlot.js +2 -2
  54. package/ScatterChart/formatter.js +2 -3
  55. package/ScatterChart/getColor.d.ts +1 -1
  56. package/ScatterChart/getColor.js +2 -2
  57. package/ScatterChart/plugin.d.ts +2 -0
  58. package/ScatterChart/plugin.js +17 -0
  59. package/SparkLineChart/SparkLineChart.d.ts +9 -4
  60. package/SparkLineChart/SparkLineChart.js +58 -2
  61. package/context/CartesianContextProvider.d.ts +21 -10
  62. package/context/CartesianContextProvider.js +7 -20
  63. package/context/ColorProvider.d.ts +12 -0
  64. package/context/ColorProvider.js +25 -0
  65. package/context/DrawingProvider.d.ts +3 -1
  66. package/context/DrawingProvider.js +9 -2
  67. package/context/HighlightedProvider/HighlightedContext.d.ts +2 -1
  68. package/context/HighlightedProvider/HighlightedContext.js +8 -5
  69. package/context/HighlightedProvider/HighlightedProvider.js +15 -12
  70. package/context/HighlightedProvider/useHighlighted.js +6 -3
  71. package/context/HighlightedProvider/useItemHighlighted.js +2 -8
  72. package/context/SeriesContextProvider.d.ts +16 -5
  73. package/context/SeriesContextProvider.js +14 -17
  74. package/context/context.types.d.ts +4 -0
  75. package/context/context.types.js +5 -0
  76. package/esm/BarChart/BarChart.js +2 -2
  77. package/esm/BarChart/BarPlot.js +2 -2
  78. package/esm/BarChart/formatter.js +1 -1
  79. package/esm/BarChart/getColor.js +4 -4
  80. package/esm/BarChart/plugin.js +10 -0
  81. package/esm/ChartContainer/ChartContainer.js +71 -23
  82. package/esm/ChartContainer/defaultPlugins.js +5 -0
  83. package/esm/ChartContainer/usePluginsMerge.js +31 -0
  84. package/esm/ChartsLegend/ChartsLegend.js +2 -2
  85. package/esm/ChartsLegend/utils.js +4 -1
  86. package/esm/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +4 -4
  87. package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +3 -5
  88. package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +3 -5
  89. package/esm/ChartsText/ChartsText.js +1 -3
  90. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +8 -14
  91. package/esm/ChartsTooltip/ChartsItemTooltipContent.js +8 -18
  92. package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +5 -4
  93. package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
  94. package/esm/ChartsTooltip/utils.js +2 -8
  95. package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -2
  96. package/esm/ChartsXAxis/ChartsXAxis.js +17 -19
  97. package/esm/ChartsYAxis/ChartsYAxis.js +17 -19
  98. package/esm/LineChart/AreaPlot.js +2 -2
  99. package/esm/LineChart/LineChart.js +3 -3
  100. package/esm/LineChart/LineHighlightPlot.js +2 -2
  101. package/esm/LineChart/LinePlot.js +2 -2
  102. package/esm/LineChart/MarkPlot.js +2 -2
  103. package/esm/LineChart/formatter.js +1 -1
  104. package/esm/LineChart/getColor.js +2 -2
  105. package/esm/LineChart/plugin.js +10 -0
  106. package/esm/PieChart/PieChart.js +3 -3
  107. package/esm/PieChart/PiePlot.js +2 -2
  108. package/esm/PieChart/plugin.js +7 -0
  109. package/esm/ResponsiveChartContainer/ResizableContainer.js +26 -0
  110. package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +31 -23
  111. package/esm/ScatterChart/ScatterChart.js +3 -3
  112. package/esm/ScatterChart/ScatterPlot.js +2 -2
  113. package/esm/ScatterChart/formatter.js +1 -1
  114. package/esm/ScatterChart/getColor.js +2 -2
  115. package/esm/ScatterChart/plugin.js +10 -0
  116. package/esm/SparkLineChart/SparkLineChart.js +58 -2
  117. package/esm/context/CartesianContextProvider.js +7 -20
  118. package/esm/context/ColorProvider.js +16 -0
  119. package/esm/context/DrawingProvider.js +9 -2
  120. package/esm/context/HighlightedProvider/HighlightedContext.js +8 -5
  121. package/esm/context/HighlightedProvider/HighlightedProvider.js +15 -12
  122. package/esm/context/HighlightedProvider/useHighlighted.js +6 -3
  123. package/esm/context/HighlightedProvider/useItemHighlighted.js +2 -6
  124. package/esm/context/SeriesContextProvider.js +14 -17
  125. package/esm/context/context.types.js +1 -0
  126. package/esm/hooks/index.js +1 -0
  127. package/esm/hooks/useColor.js +9 -0
  128. package/esm/hooks/useColorScale.js +27 -0
  129. package/esm/hooks/useInteractionItemProps.js +2 -2
  130. package/esm/hooks/useReducedMotion.js +7 -0
  131. package/esm/hooks/useSeries.js +6 -3
  132. package/esm/hooks/useSvgRef.js +6 -3
  133. package/esm/internals/configInit.js +20 -0
  134. package/esm/internals/defaultizeValueFormatter.js +2 -3
  135. package/esm/internals/index.js +27 -0
  136. package/esm/internals/isCartesian.js +7 -0
  137. package/esm/internals/warning.js +13 -0
  138. package/esm/models/index.js +1 -0
  139. package/esm/models/plugin.js +1 -0
  140. package/esm/models/seriesType/index.js +6 -0
  141. package/hooks/index.d.ts +1 -0
  142. package/hooks/index.js +12 -0
  143. package/hooks/useColor.d.ts +4 -0
  144. package/hooks/useColor.js +17 -0
  145. package/hooks/useColorScale.d.ts +4 -0
  146. package/hooks/useColorScale.js +37 -0
  147. package/hooks/useInteractionItemProps.js +1 -1
  148. package/hooks/useReducedMotion.js +7 -0
  149. package/hooks/useSeries.d.ts +6 -11
  150. package/hooks/useSeries.js +6 -3
  151. package/hooks/useSvgRef.js +6 -3
  152. package/hooks/useTicks.d.ts +4 -2
  153. package/index.js +1 -1
  154. package/internals/configInit.d.ts +9 -0
  155. package/internals/configInit.js +26 -0
  156. package/internals/defaultizeColor.d.ts +8 -8
  157. package/internals/defaultizeValueFormatter.d.ts +1 -2
  158. package/internals/defaultizeValueFormatter.js +2 -3
  159. package/internals/index.d.ts +17 -0
  160. package/internals/index.js +203 -0
  161. package/internals/isCartesian.d.ts +7 -0
  162. package/internals/isCartesian.js +14 -0
  163. package/internals/package.json +6 -0
  164. package/internals/warning.d.ts +1 -0
  165. package/internals/warning.js +19 -0
  166. package/models/axis.d.ts +4 -5
  167. package/models/index.d.ts +1 -0
  168. package/models/index.js +11 -0
  169. package/models/plugin.d.ts +16 -0
  170. package/models/plugin.js +5 -0
  171. package/models/seriesType/config.d.ts +30 -5
  172. package/models/seriesType/index.d.ts +8 -11
  173. package/models/seriesType/index.js +6 -0
  174. package/modern/BarChart/BarChart.js +2 -2
  175. package/modern/BarChart/BarPlot.js +2 -2
  176. package/modern/BarChart/formatter.js +1 -1
  177. package/modern/BarChart/getColor.js +4 -4
  178. package/modern/BarChart/plugin.js +10 -0
  179. package/modern/ChartContainer/ChartContainer.js +71 -23
  180. package/modern/ChartContainer/defaultPlugins.js +5 -0
  181. package/modern/ChartContainer/usePluginsMerge.js +31 -0
  182. package/modern/ChartsLegend/ChartsLegend.js +2 -2
  183. package/modern/ChartsLegend/utils.js +4 -1
  184. package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +4 -4
  185. package/modern/ChartsReferenceLine/ChartsXReferenceLine.js +3 -5
  186. package/modern/ChartsReferenceLine/ChartsYReferenceLine.js +3 -5
  187. package/modern/ChartsText/ChartsText.js +1 -3
  188. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +8 -14
  189. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +8 -18
  190. package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +5 -4
  191. package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
  192. package/modern/ChartsTooltip/utils.js +2 -8
  193. package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -2
  194. package/modern/ChartsXAxis/ChartsXAxis.js +17 -19
  195. package/modern/ChartsYAxis/ChartsYAxis.js +17 -19
  196. package/modern/LineChart/AreaPlot.js +2 -2
  197. package/modern/LineChart/LineChart.js +3 -3
  198. package/modern/LineChart/LineHighlightPlot.js +2 -2
  199. package/modern/LineChart/LinePlot.js +2 -2
  200. package/modern/LineChart/MarkPlot.js +2 -2
  201. package/modern/LineChart/formatter.js +1 -1
  202. package/modern/LineChart/getColor.js +2 -2
  203. package/modern/LineChart/plugin.js +10 -0
  204. package/modern/PieChart/PieChart.js +3 -3
  205. package/modern/PieChart/PiePlot.js +2 -2
  206. package/modern/PieChart/plugin.js +7 -0
  207. package/modern/ResponsiveChartContainer/ResizableContainer.js +26 -0
  208. package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +31 -23
  209. package/modern/ScatterChart/ScatterChart.js +3 -3
  210. package/modern/ScatterChart/ScatterPlot.js +2 -2
  211. package/modern/ScatterChart/formatter.js +1 -1
  212. package/modern/ScatterChart/getColor.js +2 -2
  213. package/modern/ScatterChart/plugin.js +10 -0
  214. package/modern/SparkLineChart/SparkLineChart.js +58 -2
  215. package/modern/context/CartesianContextProvider.js +7 -20
  216. package/modern/context/ColorProvider.js +16 -0
  217. package/modern/context/DrawingProvider.js +9 -2
  218. package/modern/context/HighlightedProvider/HighlightedContext.js +8 -5
  219. package/modern/context/HighlightedProvider/HighlightedProvider.js +15 -12
  220. package/modern/context/HighlightedProvider/useHighlighted.js +6 -3
  221. package/modern/context/HighlightedProvider/useItemHighlighted.js +2 -6
  222. package/modern/context/SeriesContextProvider.js +14 -17
  223. package/modern/context/context.types.js +1 -0
  224. package/modern/hooks/index.js +1 -0
  225. package/modern/hooks/useColor.js +9 -0
  226. package/modern/hooks/useColorScale.js +27 -0
  227. package/modern/hooks/useInteractionItemProps.js +2 -2
  228. package/modern/hooks/useReducedMotion.js +7 -0
  229. package/modern/hooks/useSeries.js +6 -3
  230. package/modern/hooks/useSvgRef.js +6 -3
  231. package/modern/index.js +1 -1
  232. package/modern/internals/configInit.js +20 -0
  233. package/modern/internals/defaultizeValueFormatter.js +2 -3
  234. package/modern/internals/index.js +27 -0
  235. package/modern/internals/isCartesian.js +7 -0
  236. package/modern/internals/warning.js +13 -0
  237. package/modern/models/index.js +1 -0
  238. package/modern/models/plugin.js +1 -0
  239. package/modern/models/seriesType/index.js +6 -0
  240. package/package.json +2 -2
  241. package/themeAugmentation/components.d.ts +12 -12
  242. package/esm/internals/colorGetter.js +0 -22
  243. package/internals/colorGetter.d.ts +0 -7
  244. package/internals/colorGetter.js +0 -29
  245. package/modern/internals/colorGetter.js +0 -22
@@ -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 [];
@@ -15,7 +15,7 @@ import { ChartsClipPath } from '../ChartsClipPath';
15
15
  import { LineHighlightPlot } from './LineHighlightPlot';
16
16
  import { ChartsGrid } from '../ChartsGrid';
17
17
  import { ChartsOnAxisClickHandler } from '../ChartsOnAxisClickHandler';
18
- import { ChartsOverlay } from '../ChartsOverlay/ChartsOverlay';
18
+ import { ChartsOverlay } from '../ChartsOverlay';
19
19
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
20
20
  /**
21
21
  * Demos:
@@ -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
+ };
@@ -9,7 +9,7 @@ import { ChartsLegend } from '../ChartsLegend';
9
9
  import { ChartsAxisHighlight } from '../ChartsAxisHighlight';
10
10
  import { PiePlot } from './PiePlot';
11
11
  import { useIsRTL } from '../internals/useIsRTL';
12
- import { ChartsOverlay } from '../ChartsOverlay/ChartsOverlay';
12
+ import { ChartsOverlay } from '../ChartsOverlay';
13
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  const defaultMargin = {
15
15
  top: 5,
@@ -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
+ };
@@ -0,0 +1,26 @@
1
+ import { styled } from '@mui/material/styles';
2
+ /**
3
+ * Wrapping div that take the shape of its parent.
4
+ *
5
+ * @ignore - do not document.
6
+ */
7
+ export const ResizableContainer = styled('div', {
8
+ name: 'MuiResponsiveChart',
9
+ slot: 'Container'
10
+ })(({
11
+ ownerState
12
+ }) => ({
13
+ width: ownerState.width ?? '100%',
14
+ height: ownerState.height ?? '100%',
15
+ display: 'flex',
16
+ position: 'relative',
17
+ flexGrow: 1,
18
+ flexDirection: 'column',
19
+ alignItems: 'center',
20
+ justifyContent: 'center',
21
+ overflow: 'hidden',
22
+ '&>svg': {
23
+ width: '100%',
24
+ height: '100%'
25
+ }
26
+ }));
@@ -3,30 +3,10 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
3
3
  const _excluded = ["width", "height"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
- import { styled } from '@mui/material/styles';
7
6
  import { ChartContainer } from '../ChartContainer';
8
7
  import { useChartContainerDimensions } from './useChartContainerDimensions';
8
+ import { ResizableContainer } from './ResizableContainer';
9
9
  import { jsx as _jsx } from "react/jsx-runtime";
10
- const ResizableContainer = styled('div', {
11
- name: 'MuiResponsiveChart',
12
- slot: 'Container'
13
- })(({
14
- ownerState
15
- }) => ({
16
- width: ownerState.width ?? '100%',
17
- height: ownerState.height ?? '100%',
18
- display: 'flex',
19
- position: 'relative',
20
- flexGrow: 1,
21
- flexDirection: 'column',
22
- alignItems: 'center',
23
- justifyContent: 'center',
24
- overflow: 'hidden',
25
- '&>svg': {
26
- width: '100%',
27
- height: '100%'
28
- }
29
- }));
30
10
  const ResponsiveChartContainer = /*#__PURE__*/React.forwardRef(function ResponsiveChartContainer(props, ref) {
31
11
  const {
32
12
  width: inWidth,
@@ -99,6 +79,11 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
99
79
  * @param {HighlightItemData | null} highlightedItem The newly highlighted item.
100
80
  */
101
81
  onHighlightChange: PropTypes.func,
82
+ /**
83
+ * An array of plugins defining how to preprocess data.
84
+ * If not provided, the container supports line, bar, scatter and pie charts.
85
+ */
86
+ plugins: PropTypes.arrayOf(PropTypes.object),
102
87
  /**
103
88
  * The array of series to display.
104
89
  * Each type of series has its own specificity.
@@ -152,7 +137,7 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
152
137
  labelStyle: PropTypes.object,
153
138
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
154
139
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
155
- position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
140
+ position: PropTypes.oneOf(['bottom', 'top']),
156
141
  reverse: PropTypes.bool,
157
142
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
158
143
  slotProps: PropTypes.object,
@@ -205,7 +190,7 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
205
190
  labelStyle: PropTypes.object,
206
191
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
207
192
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
208
- position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
193
+ position: PropTypes.oneOf(['left', 'right']),
209
194
  reverse: PropTypes.bool,
210
195
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
211
196
  slotProps: PropTypes.object,
@@ -222,6 +207,29 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
222
207
  tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
223
208
  tickSize: PropTypes.number,
224
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
225
233
  }))
226
234
  } : void 0;
227
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';
@@ -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
+ };
@@ -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]),
@@ -265,7 +269,59 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
265
269
  labelStyle: PropTypes.object,
266
270
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
267
271
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
268
- position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
272
+ position: PropTypes.oneOf(['bottom', 'top']),
273
+ reverse: PropTypes.bool,
274
+ scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
275
+ slotProps: PropTypes.object,
276
+ slots: PropTypes.object,
277
+ stroke: PropTypes.string,
278
+ tickFontSize: PropTypes.number,
279
+ tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
280
+ tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
281
+ tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
282
+ tickLabelStyle: PropTypes.object,
283
+ tickMaxStep: PropTypes.number,
284
+ tickMinStep: PropTypes.number,
285
+ tickNumber: PropTypes.number,
286
+ tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
287
+ tickSize: PropTypes.number,
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']),
269
325
  reverse: PropTypes.bool,
270
326
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
271
327
  slotProps: PropTypes.object,
@@ -1,31 +1,16 @@
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
- import { SeriesContext } from './SeriesContextProvider';
10
6
  import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from '../constants';
11
7
  import { getTickNumber } from '../hooks/useTicks';
12
8
  import { useDrawingArea } from '../hooks/useDrawingArea';
13
9
  import { getColorScale, getOrdinalColorScale } from '../internals/colorScale';
10
+ 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,9 +25,11 @@ 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
- const formattedSeries = React.useContext(SeriesContext);
32
+ const formattedSeries = useSeries();
46
33
  const drawingArea = useDrawingArea();
47
34
  const xAxis = React.useMemo(() => inXAxis?.map(axisConfig => {
48
35
  const dataKey = axisConfig.dataKey;
@@ -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
+ }
@@ -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';