@mui/x-charts 7.2.0 → 7.3.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 (269) hide show
  1. package/BarChart/BarChart.d.ts +1 -0
  2. package/BarChart/BarChart.js +40 -99
  3. package/BarChart/BarElement.d.ts +63 -62
  4. package/BarChart/BarElement.js +1 -2
  5. package/BarChart/BarPlot.js +14 -7
  6. package/BarChart/getColor.d.ts +3 -0
  7. package/BarChart/getColor.js +33 -0
  8. package/CHANGELOG.md +204 -2
  9. package/ChartContainer/ChartContainer.js +38 -5
  10. package/ChartsAxis/ChartsAxis.js +11 -103
  11. package/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
  12. package/ChartsClipPath/ChartsClipPath.js +3 -3
  13. package/ChartsGrid/ChartsGrid.js +1 -1
  14. package/ChartsLegend/ChartsLegend.js +3 -3
  15. package/ChartsLegend/DefaultChartsLegend.js +1 -1
  16. package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +1 -1
  17. package/ChartsReferenceLine/ChartsReferenceLine.js +1 -1
  18. package/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
  19. package/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
  20. package/ChartsSurface.js +1 -1
  21. package/ChartsText/ChartsText.js +1 -1
  22. package/ChartsTooltip/ChartsAxisTooltipContent.d.ts +4 -1
  23. package/ChartsTooltip/ChartsAxisTooltipContent.js +21 -3
  24. package/ChartsTooltip/ChartsItemTooltipContent.d.ts +6 -0
  25. package/ChartsTooltip/ChartsItemTooltipContent.js +32 -2
  26. package/ChartsTooltip/ChartsTooltip.js +1 -1
  27. package/ChartsTooltip/ChartsTooltipTable.d.ts +3 -7
  28. package/ChartsTooltip/ChartsTooltipTable.js +8 -9
  29. package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +7 -7
  30. package/ChartsTooltip/DefaultChartsItemTooltipContent.js +15 -8
  31. package/ChartsTooltip/utils.d.ts +5 -1
  32. package/ChartsTooltip/utils.js +1 -1
  33. package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +7 -7
  34. package/ChartsXAxis/ChartsXAxis.js +3 -3
  35. package/ChartsYAxis/ChartsYAxis.js +3 -3
  36. package/Gauge/Gauge.js +1 -1
  37. package/Gauge/GaugeContainer.js +1 -1
  38. package/Gauge/GaugeProvider.js +6 -6
  39. package/Gauge/GaugeReferenceArc.js +1 -1
  40. package/Gauge/GaugeValueArc.js +1 -1
  41. package/Gauge/GaugeValueText.js +1 -1
  42. package/LineChart/AnimatedArea.d.ts +63 -62
  43. package/LineChart/AnimatedArea.js +7 -6
  44. package/LineChart/AnimatedLine.d.ts +63 -62
  45. package/LineChart/AnimatedLine.js +8 -6
  46. package/LineChart/AreaElement.d.ts +1 -0
  47. package/LineChart/AreaElement.js +5 -2
  48. package/LineChart/AreaPlot.js +8 -2
  49. package/LineChart/LineChart.d.ts +1 -0
  50. package/LineChart/LineChart.js +40 -99
  51. package/LineChart/LineElement.d.ts +1 -0
  52. package/LineChart/LineElement.js +5 -2
  53. package/LineChart/LineHighlightElement.js +1 -1
  54. package/LineChart/LineHighlightPlot.js +5 -2
  55. package/LineChart/LinePlot.js +8 -2
  56. package/LineChart/MarkElement.js +1 -1
  57. package/LineChart/MarkPlot.js +6 -6
  58. package/LineChart/getColor.d.ts +3 -0
  59. package/LineChart/getColor.js +31 -0
  60. package/PieChart/PieArc.d.ts +1 -0
  61. package/PieChart/PieArc.js +1 -1
  62. package/PieChart/PieArcLabel.d.ts +1 -0
  63. package/PieChart/PieArcLabel.js +1 -1
  64. package/PieChart/PieArcLabelPlot.js +1 -1
  65. package/PieChart/PieArcPlot.js +1 -1
  66. package/PieChart/PieChart.d.ts +1 -0
  67. package/PieChart/PieChart.js +40 -99
  68. package/PieChart/PiePlot.js +27 -7
  69. package/PieChart/dataTransform/transition.d.ts +1 -0
  70. package/PieChart/dataTransform/useTransformData.js +1 -1
  71. package/PieChart/formatter.js +4 -2
  72. package/PieChart/getColor.d.ts +2 -0
  73. package/PieChart/getColor.js +11 -0
  74. package/PieChart/getPieCoordinates.d.ts +7 -0
  75. package/PieChart/getPieCoordinates.js +25 -0
  76. package/PieChart/index.d.ts +1 -0
  77. package/PieChart/index.js +11 -0
  78. package/ResponsiveChartContainer/ResponsiveChartContainer.js +35 -3
  79. package/ResponsiveChartContainer/useChartContainerDimensions.js +1 -1
  80. package/ScatterChart/Scatter.d.ts +1 -0
  81. package/ScatterChart/Scatter.js +7 -4
  82. package/ScatterChart/ScatterChart.d.ts +3 -1
  83. package/ScatterChart/ScatterChart.js +95 -126
  84. package/ScatterChart/ScatterPlot.js +11 -1
  85. package/ScatterChart/getColor.d.ts +4 -0
  86. package/ScatterChart/getColor.js +48 -0
  87. package/SparkLineChart/SparkLineChart.js +16 -1
  88. package/context/CartesianContextProvider.d.ts +4 -3
  89. package/context/CartesianContextProvider.js +24 -9
  90. package/context/DrawingProvider.js +1 -1
  91. package/context/HighlightProvider.js +1 -1
  92. package/context/InteractionProvider.js +1 -1
  93. package/context/SeriesContextProvider.js +1 -1
  94. package/context/ZAxisContextProvider.d.ts +33 -0
  95. package/context/ZAxisContextProvider.js +98 -0
  96. package/context/index.d.ts +2 -0
  97. package/context/index.js +8 -1
  98. package/esm/BarChart/BarChart.js +40 -100
  99. package/esm/BarChart/BarElement.js +0 -1
  100. package/esm/BarChart/BarPlot.js +15 -7
  101. package/esm/BarChart/getColor.js +27 -0
  102. package/esm/ChartContainer/ChartContainer.js +38 -5
  103. package/esm/ChartsAxis/ChartsAxis.js +11 -104
  104. package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -2
  105. package/esm/ChartsClipPath/ChartsClipPath.js +2 -2
  106. package/esm/ChartsGrid/ChartsGrid.js +1 -2
  107. package/esm/ChartsLegend/ChartsLegend.js +2 -2
  108. package/esm/ChartsLegend/DefaultChartsLegend.js +1 -2
  109. package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +1 -2
  110. package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +1 -2
  111. package/esm/ChartsSurface.js +1 -2
  112. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +20 -2
  113. package/esm/ChartsTooltip/ChartsItemTooltipContent.js +31 -1
  114. package/esm/ChartsTooltip/ChartsTooltipTable.js +8 -8
  115. package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +7 -8
  116. package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +15 -9
  117. package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +6 -6
  118. package/esm/ChartsXAxis/ChartsXAxis.js +3 -4
  119. package/esm/ChartsYAxis/ChartsYAxis.js +3 -4
  120. package/esm/Gauge/Gauge.js +1 -2
  121. package/esm/Gauge/GaugeProvider.js +5 -5
  122. package/esm/LineChart/AnimatedArea.js +7 -7
  123. package/esm/LineChart/AnimatedLine.js +8 -7
  124. package/esm/LineChart/AreaElement.js +4 -1
  125. package/esm/LineChart/AreaPlot.js +7 -1
  126. package/esm/LineChart/LineChart.js +40 -100
  127. package/esm/LineChart/LineElement.js +4 -1
  128. package/esm/LineChart/LineHighlightPlot.js +4 -1
  129. package/esm/LineChart/LinePlot.js +7 -1
  130. package/esm/LineChart/MarkPlot.js +5 -5
  131. package/esm/LineChart/getColor.js +25 -0
  132. package/esm/PieChart/PieChart.js +40 -100
  133. package/esm/PieChart/PiePlot.js +27 -8
  134. package/esm/PieChart/formatter.js +4 -2
  135. package/esm/PieChart/getColor.js +5 -0
  136. package/esm/PieChart/getPieCoordinates.js +19 -0
  137. package/esm/PieChart/index.js +2 -1
  138. package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +34 -2
  139. package/esm/ScatterChart/Scatter.js +6 -3
  140. package/esm/ScatterChart/ScatterChart.js +95 -127
  141. package/esm/ScatterChart/ScatterPlot.js +10 -0
  142. package/esm/ScatterChart/getColor.js +42 -0
  143. package/esm/SparkLineChart/SparkLineChart.js +16 -2
  144. package/esm/context/CartesianContextProvider.js +23 -8
  145. package/esm/context/ZAxisContextProvider.js +89 -0
  146. package/esm/context/index.js +1 -1
  147. package/esm/hooks/index.js +4 -1
  148. package/esm/hooks/useAxisEvents.js +7 -6
  149. package/esm/hooks/useChartId.js +8 -0
  150. package/esm/hooks/useSeries.js +64 -0
  151. package/esm/hooks/useSvgRef.js +9 -0
  152. package/esm/internals/colorGetter.js +22 -0
  153. package/esm/internals/colorScale.js +16 -0
  154. package/esm/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +95 -0
  155. package/esm/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +55 -0
  156. package/esm/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +40 -0
  157. package/esm/internals/components/ChartsAxesGradients/index.js +1 -0
  158. package/esm/models/colorMapping.js +1 -0
  159. package/esm/models/seriesType/index.js +6 -1
  160. package/esm/models/z-axis.js +1 -0
  161. package/hooks/index.d.ts +3 -0
  162. package/hooks/index.js +65 -1
  163. package/hooks/useAxisEvents.js +8 -7
  164. package/hooks/useChartDimensions.js +1 -1
  165. package/hooks/useChartId.d.ts +1 -0
  166. package/hooks/useChartId.js +16 -0
  167. package/hooks/useDrawingArea.js +1 -1
  168. package/hooks/useInteractionItemProps.js +1 -1
  169. package/hooks/useMounted.js +1 -1
  170. package/hooks/useScale.js +1 -1
  171. package/hooks/useSeries.d.ts +45 -0
  172. package/hooks/useSeries.js +75 -0
  173. package/hooks/useSvgRef.d.ts +2 -0
  174. package/hooks/useSvgRef.js +17 -0
  175. package/hooks/useTicks.js +1 -1
  176. package/index.js +1 -1
  177. package/internals/colorGetter.d.ts +7 -0
  178. package/internals/colorGetter.js +29 -0
  179. package/internals/colorScale.d.ts +5 -0
  180. package/internals/colorScale.js +24 -0
  181. package/internals/components/ChartsAxesGradients/ChartsAxesGradients.d.ts +3 -0
  182. package/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +105 -0
  183. package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.d.ts +13 -0
  184. package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +63 -0
  185. package/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.d.ts +12 -0
  186. package/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +48 -0
  187. package/internals/components/ChartsAxesGradients/index.d.ts +1 -0
  188. package/internals/components/ChartsAxesGradients/index.js +16 -0
  189. package/internals/defaultizeColor.d.ts +5 -4
  190. package/internals/defaultizeValueFormatter.d.ts +5 -5
  191. package/internals/getScale.d.ts +2 -2
  192. package/internals/useAnimatedPath.d.ts +1 -0
  193. package/internals/useAnimatedPath.js +1 -1
  194. package/models/axis.d.ts +44 -4
  195. package/models/colorMapping.d.ts +46 -0
  196. package/models/colorMapping.js +5 -0
  197. package/models/index.d.ts +1 -1
  198. package/models/seriesType/common.d.ts +10 -2
  199. package/models/seriesType/index.d.ts +2 -0
  200. package/models/seriesType/index.js +17 -1
  201. package/models/seriesType/pie.d.ts +5 -0
  202. package/models/seriesType/scatter.d.ts +5 -0
  203. package/models/z-axis.d.ts +14 -0
  204. package/models/z-axis.js +5 -0
  205. package/modern/BarChart/BarChart.js +40 -100
  206. package/modern/BarChart/BarElement.js +0 -1
  207. package/modern/BarChart/BarPlot.js +15 -7
  208. package/modern/BarChart/getColor.js +27 -0
  209. package/modern/ChartContainer/ChartContainer.js +38 -5
  210. package/modern/ChartsAxis/ChartsAxis.js +11 -104
  211. package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -2
  212. package/modern/ChartsClipPath/ChartsClipPath.js +2 -2
  213. package/modern/ChartsGrid/ChartsGrid.js +1 -2
  214. package/modern/ChartsLegend/ChartsLegend.js +2 -2
  215. package/modern/ChartsLegend/DefaultChartsLegend.js +1 -2
  216. package/modern/ChartsReferenceLine/ChartsXReferenceLine.js +1 -2
  217. package/modern/ChartsReferenceLine/ChartsYReferenceLine.js +1 -2
  218. package/modern/ChartsSurface.js +1 -2
  219. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +20 -2
  220. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +31 -1
  221. package/modern/ChartsTooltip/ChartsTooltipTable.js +8 -8
  222. package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +7 -8
  223. package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +15 -9
  224. package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +6 -6
  225. package/modern/ChartsXAxis/ChartsXAxis.js +3 -4
  226. package/modern/ChartsYAxis/ChartsYAxis.js +3 -4
  227. package/modern/Gauge/Gauge.js +1 -2
  228. package/modern/Gauge/GaugeProvider.js +5 -5
  229. package/modern/LineChart/AnimatedArea.js +7 -7
  230. package/modern/LineChart/AnimatedLine.js +8 -7
  231. package/modern/LineChart/AreaElement.js +4 -1
  232. package/modern/LineChart/AreaPlot.js +7 -1
  233. package/modern/LineChart/LineChart.js +40 -100
  234. package/modern/LineChart/LineElement.js +4 -1
  235. package/modern/LineChart/LineHighlightPlot.js +4 -1
  236. package/modern/LineChart/LinePlot.js +7 -1
  237. package/modern/LineChart/MarkPlot.js +5 -5
  238. package/modern/LineChart/getColor.js +25 -0
  239. package/modern/PieChart/PieChart.js +40 -100
  240. package/modern/PieChart/PiePlot.js +27 -8
  241. package/modern/PieChart/formatter.js +4 -2
  242. package/modern/PieChart/getColor.js +5 -0
  243. package/modern/PieChart/getPieCoordinates.js +19 -0
  244. package/modern/PieChart/index.js +2 -1
  245. package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +34 -2
  246. package/modern/ScatterChart/Scatter.js +6 -3
  247. package/modern/ScatterChart/ScatterChart.js +95 -127
  248. package/modern/ScatterChart/ScatterPlot.js +10 -0
  249. package/modern/ScatterChart/getColor.js +42 -0
  250. package/modern/SparkLineChart/SparkLineChart.js +16 -2
  251. package/modern/context/CartesianContextProvider.js +23 -8
  252. package/modern/context/ZAxisContextProvider.js +89 -0
  253. package/modern/context/index.js +1 -1
  254. package/modern/hooks/index.js +4 -1
  255. package/modern/hooks/useAxisEvents.js +7 -6
  256. package/modern/hooks/useChartId.js +8 -0
  257. package/modern/hooks/useSeries.js +64 -0
  258. package/modern/hooks/useSvgRef.js +9 -0
  259. package/modern/index.js +1 -1
  260. package/modern/internals/colorGetter.js +22 -0
  261. package/modern/internals/colorScale.js +16 -0
  262. package/modern/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +95 -0
  263. package/modern/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +55 -0
  264. package/modern/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +40 -0
  265. package/modern/internals/components/ChartsAxesGradients/index.js +1 -0
  266. package/modern/models/colorMapping.js +1 -0
  267. package/modern/models/seriesType/index.js +6 -1
  268. package/modern/models/z-axis.js +1 -0
  269. package/package.json +3 -5
@@ -9,8 +9,7 @@ import { InteractionContext } from '../context/InteractionProvider';
9
9
  import { CartesianContext } from '../context/CartesianContextProvider';
10
10
  import { getValueToPositionMapper } from '../hooks/useScale';
11
11
  import { isBandScale } from '../internals/isBandScale';
12
- import { jsx as _jsx } from "react/jsx-runtime";
13
- import { jsxs as _jsxs } from "react/jsx-runtime";
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
13
  export function getAxisHighlightUtilityClass(slot) {
15
14
  return generateUtilityClass('MuiChartsAxisHighlight', slot);
16
15
  }
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import PropTypes from 'prop-types';
4
- import { DrawingContext } from '../context/DrawingProvider';
4
+ import { useDrawingArea } from '../hooks/useDrawingArea';
5
5
  import { jsx as _jsx } from "react/jsx-runtime";
6
6
  /**
7
7
  * API:
@@ -18,7 +18,7 @@ function ChartsClipPath(props) {
18
18
  top,
19
19
  width,
20
20
  height
21
- } = React.useContext(DrawingContext);
21
+ } = useDrawingArea();
22
22
  const offset = _extends({
23
23
  top: 0,
24
24
  right: 0,
@@ -8,8 +8,7 @@ import { styled } from '@mui/material/styles';
8
8
  import { CartesianContext } from '../context/CartesianContextProvider';
9
9
  import { useTicks } from '../hooks/useTicks';
10
10
  import { getChartsGridUtilityClass, chartsGridClasses } from './chartsGridClasses';
11
- import { jsx as _jsx } from "react/jsx-runtime";
12
- import { jsxs as _jsxs } from "react/jsx-runtime";
11
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
12
  const GridRoot = styled('g', {
14
13
  name: 'MuiChartsGrid',
15
14
  slot: 'Root',
@@ -4,11 +4,11 @@ import PropTypes from 'prop-types';
4
4
  import { useSlotProps } from '@mui/base/utils';
5
5
  import { unstable_composeClasses as composeClasses } from '@mui/utils';
6
6
  import { useThemeProps, useTheme } from '@mui/material/styles';
7
- import { DrawingContext } from '../context/DrawingProvider';
8
7
  import { getSeriesToDisplay } from './utils';
9
8
  import { SeriesContext } from '../context/SeriesContextProvider';
10
9
  import { getLegendUtilityClass } from './chartsLegendClasses';
11
10
  import { DefaultChartsLegend } from './DefaultChartsLegend';
11
+ import { useDrawingArea } from '../hooks';
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  const useUtilityClasses = ownerState => {
14
14
  const {
@@ -46,7 +46,7 @@ function ChartsLegend(inProps) {
46
46
  const classes = useUtilityClasses(_extends({}, props, {
47
47
  theme
48
48
  }));
49
- const drawingArea = React.useContext(DrawingContext);
49
+ const drawingArea = useDrawingArea();
50
50
  const series = React.useContext(SeriesContext);
51
51
  const seriesToDisplay = getSeriesToDisplay(series);
52
52
  const ChartLegendRender = slots?.legend ?? DefaultChartsLegend;
@@ -8,8 +8,7 @@ import { NoSsr } from '@mui/base/NoSsr';
8
8
  import { useTheme, styled } from '@mui/material/styles';
9
9
  import { ChartsText } from '../ChartsText';
10
10
  import { getWordsByLines } from '../internals/getWordsByLines';
11
- import { jsx as _jsx } from "react/jsx-runtime";
12
- import { jsxs as _jsxs } from "react/jsx-runtime";
11
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
12
  export const ChartsLegendRoot = styled('g', {
14
13
  name: 'MuiChartsLegend',
15
14
  slot: 'Root',
@@ -5,8 +5,7 @@ import { useDrawingArea, useXScale } from '../hooks';
5
5
  import { ReferenceLineRoot } from './common';
6
6
  import { ChartsText } from '../ChartsText';
7
7
  import { getReferenceLineUtilityClass } from './chartsReferenceLineClasses';
8
- import { jsx as _jsx } from "react/jsx-runtime";
9
- import { jsxs as _jsxs } from "react/jsx-runtime";
8
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
9
  const getTextParams = ({
11
10
  top,
12
11
  height,
@@ -5,8 +5,7 @@ import { useDrawingArea, useYScale } from '../hooks';
5
5
  import { ReferenceLineRoot } from './common';
6
6
  import { ChartsText } from '../ChartsText';
7
7
  import { getReferenceLineUtilityClass } from './chartsReferenceLineClasses';
8
- import { jsx as _jsx } from "react/jsx-runtime";
9
- import { jsxs as _jsxs } from "react/jsx-runtime";
8
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
9
  const getTextParams = ({
11
10
  left,
12
11
  width,
@@ -5,8 +5,7 @@ import { styled } from '@mui/material/styles';
5
5
  import PropTypes from 'prop-types';
6
6
  import * as React from 'react';
7
7
  import { useAxisEvents } from './hooks/useAxisEvents';
8
- import { jsx as _jsx } from "react/jsx-runtime";
9
- import { jsxs as _jsxs } from "react/jsx-runtime";
8
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
9
  const ChartChartsSurfaceStyles = styled('svg', {
11
10
  name: 'MuiChartsSurface',
12
11
  slot: 'Root'
@@ -6,6 +6,8 @@ import { SeriesContext } from '../context/SeriesContextProvider';
6
6
  import { CartesianContext } from '../context/CartesianContextProvider';
7
7
  import { DefaultChartsAxisTooltipContent } from './DefaultChartsAxisTooltipContent';
8
8
  import { isCartesianSeriesType } from './utils';
9
+ import colorGetter from '../internals/colorGetter';
10
+ import { ZAxisContext } from '../context/ZAxisContextProvider';
9
11
  import { jsx as _jsx } from "react/jsx-runtime";
10
12
  function ChartsAxisTooltipContent(props) {
11
13
  const {
@@ -24,6 +26,10 @@ function ChartsAxisTooltipContent(props) {
24
26
  yAxisIds,
25
27
  yAxis
26
28
  } = React.useContext(CartesianContext);
29
+ const {
30
+ zAxisIds,
31
+ zAxis
32
+ } = React.useContext(ZAxisContext);
27
33
  const series = React.useContext(SeriesContext);
28
34
  const USED_AXIS_ID = isXaxis ? xAxisIds[0] : yAxisIds[0];
29
35
  const relevantSeries = React.useMemo(() => {
@@ -33,12 +39,24 @@ function ChartsAxisTooltipContent(props) {
33
39
  const item = series[seriesType].series[seriesId];
34
40
  const axisKey = isXaxis ? item.xAxisKey : item.yAxisKey;
35
41
  if (axisKey === undefined || axisKey === USED_AXIS_ID) {
36
- rep.push(series[seriesType].series[seriesId]);
42
+ const seriesToAdd = series[seriesType].series[seriesId];
43
+ let getColor;
44
+ switch (seriesToAdd.type) {
45
+ case 'scatter':
46
+ getColor = colorGetter(seriesToAdd, xAxis[seriesToAdd.xAxisKey ?? xAxisIds[0]], yAxis[seriesToAdd.yAxisKey ?? yAxisIds[0]], zAxis[seriesToAdd.zAxisKey ?? zAxisIds[0]]);
47
+ break;
48
+ default:
49
+ getColor = colorGetter(seriesToAdd, xAxis[seriesToAdd.xAxisKey ?? xAxisIds[0]], yAxis[seriesToAdd.yAxisKey ?? yAxisIds[0]]);
50
+ break;
51
+ }
52
+ rep.push(_extends({}, seriesToAdd, {
53
+ getColor
54
+ }));
37
55
  }
38
56
  });
39
57
  });
40
58
  return rep;
41
- }, [USED_AXIS_ID, isXaxis, series]);
59
+ }, [USED_AXIS_ID, isXaxis, series, xAxis, xAxisIds, yAxis, yAxisIds, zAxis, zAxisIds]);
42
60
  const relevantAxis = React.useMemo(() => {
43
61
  return isXaxis ? xAxis[USED_AXIS_ID] : yAxis[USED_AXIS_ID];
44
62
  }, [USED_AXIS_ID, isXaxis, xAxis, yAxis]);
@@ -4,6 +4,9 @@ import PropTypes from 'prop-types';
4
4
  import { useSlotProps } from '@mui/base/utils';
5
5
  import { SeriesContext } from '../context/SeriesContextProvider';
6
6
  import { DefaultChartsItemTooltipContent } from './DefaultChartsItemTooltipContent';
7
+ import { CartesianContext } from '../context/CartesianContextProvider';
8
+ import colorGetter from '../internals/colorGetter';
9
+ import { ZAxisContext } from '../context/ZAxisContextProvider';
7
10
  import { jsx as _jsx } from "react/jsx-runtime";
8
11
  function ChartsItemTooltipContent(props) {
9
12
  const {
@@ -14,6 +17,31 @@ function ChartsItemTooltipContent(props) {
14
17
  contentProps
15
18
  } = props;
16
19
  const series = React.useContext(SeriesContext)[itemData.type].series[itemData.seriesId];
20
+ const {
21
+ xAxis,
22
+ yAxis,
23
+ xAxisIds,
24
+ yAxisIds
25
+ } = React.useContext(CartesianContext);
26
+ const {
27
+ zAxis,
28
+ zAxisIds
29
+ } = React.useContext(ZAxisContext);
30
+ const defaultXAxisId = xAxisIds[0];
31
+ const defaultYAxisId = yAxisIds[0];
32
+ const defaultZAxisId = zAxisIds[0];
33
+ let getColor;
34
+ switch (series.type) {
35
+ case 'pie':
36
+ getColor = colorGetter(series);
37
+ break;
38
+ case 'scatter':
39
+ getColor = colorGetter(series, xAxis[series.xAxisKey ?? defaultXAxisId], yAxis[series.yAxisKey ?? defaultYAxisId], zAxis[series.zAxisKey ?? defaultZAxisId]);
40
+ break;
41
+ default:
42
+ getColor = colorGetter(series, xAxis[series.xAxisKey ?? defaultXAxisId], yAxis[series.yAxisKey ?? defaultYAxisId]);
43
+ break;
44
+ }
17
45
  const Content = content ?? DefaultChartsItemTooltipContent;
18
46
  const chartTooltipContentProps = useSlotProps({
19
47
  elementType: Content,
@@ -22,7 +50,8 @@ function ChartsItemTooltipContent(props) {
22
50
  itemData,
23
51
  series,
24
52
  sx,
25
- classes
53
+ classes,
54
+ getColor
26
55
  },
27
56
  ownerState: {}
28
57
  });
@@ -37,6 +66,7 @@ process.env.NODE_ENV !== "production" ? ChartsItemTooltipContent.propTypes = {
37
66
  content: PropTypes.elementType,
38
67
  contentProps: PropTypes.shape({
39
68
  classes: PropTypes.object,
69
+ getColor: PropTypes.func,
40
70
  itemData: PropTypes.shape({
41
71
  dataIndex: PropTypes.number,
42
72
  seriesId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
@@ -1,5 +1,5 @@
1
- import Box from '@mui/system/Box';
2
1
  import { styled } from '@mui/material/styles';
2
+ import { shouldForwardProp } from '@mui/system';
3
3
  import { chartsTooltipClasses } from './chartsTooltipClasses';
4
4
  export const ChartsTooltipPaper = styled('div', {
5
5
  name: 'MuiChartsTooltip',
@@ -7,10 +7,10 @@ export const ChartsTooltipPaper = styled('div', {
7
7
  })(({
8
8
  theme
9
9
  }) => ({
10
+ boxShadow: theme.shadows[1],
10
11
  backgroundColor: (theme.vars || theme).palette.background.paper,
11
12
  color: (theme.vars || theme).palette.text.primary,
12
13
  transition: theme.transitions.create('box-shadow'),
13
- border: `1px solid ${(theme.vars || theme).palette.divider}`,
14
14
  borderRadius: theme.shape.borderRadius
15
15
  }));
16
16
  export const ChartsTooltipTable = styled('table', {
@@ -59,19 +59,19 @@ export const ChartsTooltipCell = styled('td', {
59
59
  paddingRight: theme.spacing(2)
60
60
  }
61
61
  }));
62
-
63
- // eslint-disable-next-line material-ui/no-styled-box
64
- export const ChartsTooltipMark = styled(Box, {
62
+ export const ChartsTooltipMark = styled('div', {
65
63
  name: 'MuiChartsTooltip',
66
- slot: 'Mark'
64
+ slot: 'Mark',
65
+ shouldForwardProp: prop => shouldForwardProp(prop) && prop !== 'color'
67
66
  })(({
68
67
  theme,
69
- ownerState
68
+ color
70
69
  }) => ({
71
70
  width: theme.spacing(1),
72
71
  height: theme.spacing(1),
73
72
  borderRadius: '50%',
74
- backgroundColor: ownerState.color,
73
+ boxShadow: theme.shadows[1],
74
+ backgroundColor: color,
75
75
  borderColor: (theme.vars || theme).palette.background.paper,
76
76
  border: `solid ${(theme.vars || theme).palette.background.paper} ${theme.spacing(0.25)}`,
77
77
  boxSizing: 'content-box'
@@ -4,8 +4,7 @@ import clsx from 'clsx';
4
4
  import Typography from '@mui/material/Typography';
5
5
  import { ChartsTooltipCell, ChartsTooltipPaper, ChartsTooltipTable, ChartsTooltipMark, ChartsTooltipRow } from './ChartsTooltipTable';
6
6
  import { isCartesianSeries, utcFormatter } from './utils';
7
- import { jsx as _jsx } from "react/jsx-runtime";
8
- import { jsxs as _jsxs } from "react/jsx-runtime";
7
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
8
  function DefaultChartsAxisTooltipContent(props) {
10
9
  const {
11
10
  series,
@@ -41,10 +40,13 @@ function DefaultChartsAxisTooltipContent(props) {
41
40
  id,
42
41
  label,
43
42
  valueFormatter,
44
- data
43
+ data,
44
+ getColor
45
45
  }) => {
46
46
  // @ts-ignore
47
- const formattedValue = valueFormatter(data[dataIndex] ?? null);
47
+ const formattedValue = valueFormatter(data[dataIndex] ?? null, {
48
+ dataIndex
49
+ });
48
50
  if (formattedValue == null) {
49
51
  return null;
50
52
  }
@@ -53,10 +55,7 @@ function DefaultChartsAxisTooltipContent(props) {
53
55
  children: [/*#__PURE__*/_jsx(ChartsTooltipCell, {
54
56
  className: clsx(classes.markCell, classes.cell),
55
57
  children: /*#__PURE__*/_jsx(ChartsTooltipMark, {
56
- ownerState: {
57
- color
58
- },
59
- boxShadow: 1,
58
+ color: getColor(dataIndex) ?? color,
60
59
  className: classes.mark
61
60
  })
62
61
  }), /*#__PURE__*/_jsx(ChartsTooltipCell, {
@@ -2,14 +2,14 @@ import * as React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import clsx from 'clsx';
4
4
  import { ChartsTooltipTable, ChartsTooltipCell, ChartsTooltipMark, ChartsTooltipPaper, ChartsTooltipRow } from './ChartsTooltipTable';
5
- import { jsx as _jsx } from "react/jsx-runtime";
6
- import { jsxs as _jsxs } from "react/jsx-runtime";
5
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
6
  function DefaultChartsItemTooltipContent(props) {
8
7
  const {
9
8
  series,
10
9
  itemData,
11
10
  sx,
12
- classes
11
+ classes,
12
+ getColor
13
13
  } = props;
14
14
  if (itemData.dataIndex === undefined || !series.data[itemData.dataIndex]) {
15
15
  return null;
@@ -18,14 +18,16 @@ function DefaultChartsItemTooltipContent(props) {
18
18
  displayedLabel,
19
19
  color
20
20
  } = series.type === 'pie' ? {
21
- color: series.data[itemData.dataIndex].color,
21
+ color: getColor(itemData.dataIndex),
22
22
  displayedLabel: series.data[itemData.dataIndex].label
23
23
  } : {
24
- color: series.color,
24
+ color: getColor(itemData.dataIndex) ?? series.color,
25
25
  displayedLabel: series.label
26
26
  };
27
27
  const value = series.data[itemData.dataIndex];
28
- const formattedValue = series.valueFormatter?.(value);
28
+ const formattedValue = series.valueFormatter?.(value, {
29
+ dataIndex: itemData.dataIndex
30
+ });
29
31
  return /*#__PURE__*/_jsx(ChartsTooltipPaper, {
30
32
  sx: sx,
31
33
  className: classes.root,
@@ -37,9 +39,7 @@ function DefaultChartsItemTooltipContent(props) {
37
39
  children: [/*#__PURE__*/_jsx(ChartsTooltipCell, {
38
40
  className: clsx(classes.markCell, classes.cell),
39
41
  children: /*#__PURE__*/_jsx(ChartsTooltipMark, {
40
- ownerState: {
41
- color
42
- },
42
+ color: color,
43
43
  className: classes.mark
44
44
  })
45
45
  }), /*#__PURE__*/_jsx(ChartsTooltipCell, {
@@ -63,6 +63,12 @@ process.env.NODE_ENV !== "production" ? DefaultChartsItemTooltipContent.propType
63
63
  * Override or extend the styles applied to the component.
64
64
  */
65
65
  classes: PropTypes.object.isRequired,
66
+ /**
67
+ * Get the color of the item with index `dataIndex`.
68
+ * @param {number} dataIndex The data index of the item.
69
+ * @returns {string} The color to display.
70
+ */
71
+ getColor: PropTypes.func.isRequired,
66
72
  /**
67
73
  * The data used to identify the triggered item.
68
74
  */
@@ -4,23 +4,23 @@ 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 { SvgContext, DrawingContext } from '../context/DrawingProvider';
8
7
  import { SeriesContext } from '../context/SeriesContextProvider';
9
8
  import { getValueToPositionMapper } from '../hooks/useScale';
10
9
  import { getSVGPoint } from '../internals/utils';
10
+ import { useDrawingArea, useSvgRef } from '../hooks';
11
11
  import { jsx as _jsx } from "react/jsx-runtime";
12
12
  function ChartsVoronoiHandler(props) {
13
13
  const {
14
14
  voronoiMaxRadius,
15
15
  onItemClick
16
16
  } = props;
17
- const svgRef = React.useContext(SvgContext);
17
+ const svgRef = useSvgRef();
18
18
  const {
19
- width,
20
- height,
19
+ left,
21
20
  top,
22
- left
23
- } = React.useContext(DrawingContext);
21
+ width,
22
+ height
23
+ } = useDrawingArea();
24
24
  const {
25
25
  xAxis,
26
26
  yAxis,
@@ -7,16 +7,15 @@ import { useSlotProps } from '@mui/base/utils';
7
7
  import { unstable_composeClasses as composeClasses } from '@mui/utils';
8
8
  import { useThemeProps, useTheme } from '@mui/material/styles';
9
9
  import { CartesianContext } from '../context/CartesianContextProvider';
10
- import { DrawingContext } from '../context/DrawingProvider';
11
10
  import { useTicks } from '../hooks/useTicks';
12
11
  import { getAxisUtilityClass } from '../ChartsAxis/axisClasses';
13
12
  import { AxisRoot } from '../internals/components/AxisSharedComponents';
14
13
  import { ChartsText } from '../ChartsText';
15
14
  import { getMinXTranslation } from '../internals/geometry';
16
15
  import { useMounted } from '../hooks/useMounted';
16
+ import { useDrawingArea } from '../hooks/useDrawingArea';
17
17
  import { getWordsByLines } from '../internals/getWordsByLines';
18
- import { jsx as _jsx } from "react/jsx-runtime";
19
- import { jsxs as _jsxs } from "react/jsx-runtime";
18
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
20
19
  const useUtilityClasses = ownerState => {
21
20
  const {
22
21
  classes,
@@ -153,7 +152,7 @@ function ChartsXAxis(inProps) {
153
152
  top,
154
153
  width,
155
154
  height
156
- } = React.useContext(DrawingContext);
155
+ } = useDrawingArea();
157
156
  const tickSize = disableTicks ? 4 : tickSizeProp;
158
157
  const positionSign = position === 'bottom' ? 1 : -1;
159
158
  const Line = slots?.axisLine ?? 'line';
@@ -7,13 +7,12 @@ import { useSlotProps } from '@mui/base/utils';
7
7
  import { unstable_composeClasses as composeClasses } from '@mui/utils';
8
8
  import { useThemeProps, useTheme } from '@mui/material/styles';
9
9
  import { CartesianContext } from '../context/CartesianContextProvider';
10
- import { DrawingContext } from '../context/DrawingProvider';
11
10
  import { useTicks } from '../hooks/useTicks';
11
+ import { useDrawingArea } from '../hooks/useDrawingArea';
12
12
  import { AxisRoot } from '../internals/components/AxisSharedComponents';
13
13
  import { ChartsText } from '../ChartsText';
14
14
  import { getAxisUtilityClass } from '../ChartsAxis/axisClasses';
15
- import { jsx as _jsx } from "react/jsx-runtime";
16
- import { jsxs as _jsxs } from "react/jsx-runtime";
15
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
17
16
  const useUtilityClasses = ownerState => {
18
17
  const {
19
18
  classes,
@@ -94,7 +93,7 @@ function ChartsYAxis(inProps) {
94
93
  top,
95
94
  width,
96
95
  height
97
- } = React.useContext(DrawingContext);
96
+ } = useDrawingArea();
98
97
  const tickSize = disableTicks ? 4 : tickSizeProp;
99
98
  const yTicks = useTicks({
100
99
  scale: yScale,
@@ -9,8 +9,7 @@ import { GaugeValueArc } from './GaugeValueArc';
9
9
  import { GaugeReferenceArc } from './GaugeReferenceArc';
10
10
  import { getGaugeUtilityClass } from './gaugeClasses';
11
11
  import { GaugeValueText } from './GaugeValueText';
12
- import { jsx as _jsx } from "react/jsx-runtime";
13
- import { jsxs as _jsxs } from "react/jsx-runtime";
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
13
  const useUtilityClasses = props => {
15
14
  const {
16
15
  classes
@@ -1,8 +1,8 @@
1
1
  // @ignore - do not document.
2
2
  import * as React from 'react';
3
- import { DrawingContext } from '../context/DrawingProvider';
4
3
  import { getPercentageValue } from '../internals/utils';
5
4
  import { getArcRatios, getAvailableRadius } from './utils';
5
+ import { useDrawingArea } from '../hooks/useDrawingArea';
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
7
7
  export const GaugeContext = /*#__PURE__*/React.createContext({
8
8
  value: null,
@@ -36,11 +36,11 @@ export function GaugeProvider(props) {
36
36
  children
37
37
  } = props;
38
38
  const {
39
- width,
40
- height,
39
+ left,
41
40
  top,
42
- left
43
- } = React.useContext(DrawingContext);
41
+ width,
42
+ height
43
+ } = useDrawingArea();
44
44
  const ratios = getArcRatios(startAngle, endAngle);
45
45
  const innerCx = cxParam ? getPercentageValue(cxParam, width) : ratios.cx * width;
46
46
  const innerCy = cyParam ? getPercentageValue(cyParam, height) : ratios.cy * height;
@@ -7,10 +7,9 @@ import { styled } from '@mui/material/styles';
7
7
  import { color as d3Color } from 'd3-color';
8
8
  import { animated, useSpring } from '@react-spring/web';
9
9
  import { useAnimatedPath } from '../internals/useAnimatedPath';
10
- import { DrawingContext } from '../context/DrawingProvider';
11
10
  import { cleanId } from '../internals/utils';
12
- import { jsx as _jsx } from "react/jsx-runtime";
13
- import { jsxs as _jsxs } from "react/jsx-runtime";
11
+ import { useChartId, useDrawingArea } from '../hooks';
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
13
  export const AreaElementPath = styled(animated.path, {
15
14
  name: 'MuiAreaElement',
16
15
  slot: 'Root',
@@ -19,7 +18,7 @@ export const AreaElementPath = styled(animated.path, {
19
18
  ownerState
20
19
  }) => ({
21
20
  stroke: 'none',
22
- fill: ownerState.isHighlighted ? d3Color(ownerState.color).brighter(1).formatHex() : d3Color(ownerState.color).brighter(0.5).formatHex(),
21
+ fill: ownerState.gradientId && `url(#${ownerState.gradientId})` || ownerState.isHighlighted && d3Color(ownerState.color).brighter(1).formatHex() || d3Color(ownerState.color).brighter(0.5).formatHex(),
23
22
  transition: 'opacity 0.2s ease-in, fill 0.2s ease-in',
24
23
  opacity: ownerState.isFaded ? 0.3 : 1
25
24
  }));
@@ -46,9 +45,9 @@ function AnimatedArea(props) {
46
45
  right,
47
46
  bottom,
48
47
  width,
49
- height,
50
- chartId
51
- } = React.useContext(DrawingContext);
48
+ height
49
+ } = useDrawingArea();
50
+ const chartId = useChartId();
52
51
  const path = useAnimatedPath(d, skipAnimation);
53
52
  const {
54
53
  animatedWidth
@@ -90,6 +89,7 @@ process.env.NODE_ENV !== "production" ? AnimatedArea.propTypes = {
90
89
  ownerState: PropTypes.shape({
91
90
  classes: PropTypes.object,
92
91
  color: PropTypes.string.isRequired,
92
+ gradientId: PropTypes.string,
93
93
  id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
94
94
  isFaded: PropTypes.bool.isRequired,
95
95
  isHighlighted: PropTypes.bool.isRequired
@@ -7,10 +7,10 @@ import { animated, useSpring } from '@react-spring/web';
7
7
  import { color as d3Color } from 'd3-color';
8
8
  import { styled } from '@mui/material/styles';
9
9
  import { useAnimatedPath } from '../internals/useAnimatedPath';
10
- import { DrawingContext } from '../context/DrawingProvider';
11
10
  import { cleanId } from '../internals/utils';
12
- import { jsx as _jsx } from "react/jsx-runtime";
13
- import { jsxs as _jsxs } from "react/jsx-runtime";
11
+ import { useChartId } from '../hooks/useChartId';
12
+ import { useDrawingArea } from '../hooks/useDrawingArea';
13
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  export const LineElementPath = styled(animated.path, {
15
15
  name: 'MuiLineElement',
16
16
  slot: 'Root',
@@ -21,7 +21,7 @@ export const LineElementPath = styled(animated.path, {
21
21
  strokeWidth: 2,
22
22
  strokeLinejoin: 'round',
23
23
  fill: 'none',
24
- stroke: ownerState.isHighlighted ? d3Color(ownerState.color).brighter(0.5).formatHex() : ownerState.color,
24
+ stroke: ownerState.gradientId && `url(#${ownerState.gradientId})` || ownerState.isHighlighted && d3Color(ownerState.color).brighter(0.5).formatHex() || ownerState.color,
25
25
  transition: 'opacity 0.2s ease-in, stroke 0.2s ease-in',
26
26
  opacity: ownerState.isFaded ? 0.3 : 1
27
27
  }));
@@ -48,9 +48,9 @@ function AnimatedLine(props) {
48
48
  bottom,
49
49
  width,
50
50
  height,
51
- right,
52
- chartId
53
- } = React.useContext(DrawingContext);
51
+ right
52
+ } = useDrawingArea();
53
+ const chartId = useChartId();
54
54
  const path = useAnimatedPath(d, skipAnimation);
55
55
  const {
56
56
  animatedWidth
@@ -92,6 +92,7 @@ process.env.NODE_ENV !== "production" ? AnimatedLine.propTypes = {
92
92
  ownerState: PropTypes.shape({
93
93
  classes: PropTypes.object,
94
94
  color: PropTypes.string.isRequired,
95
+ gradientId: PropTypes.string,
95
96
  id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
96
97
  isFaded: PropTypes.bool.isRequired,
97
98
  isHighlighted: PropTypes.bool.isRequired
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["id", "classes", "color", "highlightScope", "slots", "slotProps", "onClick"];
3
+ const _excluded = ["id", "classes", "color", "gradientId", "highlightScope", "slots", "slotProps", "onClick"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import composeClasses from '@mui/utils/composeClasses';
@@ -42,6 +42,7 @@ function AreaElement(props) {
42
42
  id,
43
43
  classes: innerClasses,
44
44
  color,
45
+ gradientId,
45
46
  highlightScope,
46
47
  slots,
47
48
  slotProps,
@@ -64,6 +65,7 @@ function AreaElement(props) {
64
65
  id,
65
66
  classes: innerClasses,
66
67
  color,
68
+ gradientId,
67
69
  isFaded,
68
70
  isHighlighted
69
71
  };
@@ -92,6 +94,7 @@ process.env.NODE_ENV !== "production" ? AreaElement.propTypes = {
92
94
  classes: PropTypes.object,
93
95
  color: PropTypes.string.isRequired,
94
96
  d: PropTypes.string.isRequired,
97
+ gradientId: PropTypes.string,
95
98
  highlightScope: PropTypes.shape({
96
99
  faded: PropTypes.oneOf(['global', 'none', 'series']),
97
100
  highlighted: PropTypes.oneOf(['item', 'none', 'series'])
@@ -10,6 +10,7 @@ import { AreaElement } from './AreaElement';
10
10
  import { getValueToPositionMapper } from '../hooks/useScale';
11
11
  import getCurveFactory from '../internals/getCurve';
12
12
  import { DEFAULT_X_AXIS_KEY } from '../constants';
13
+ import { useChartGradient } from '../internals/components/ChartsAxesGradients';
13
14
  import { jsx as _jsx } from "react/jsx-runtime";
14
15
  const useAggregatedData = () => {
15
16
  const seriesData = React.useContext(SeriesContext).line;
@@ -43,6 +44,7 @@ const useAggregatedData = () => {
43
44
  const xScale = getValueToPositionMapper(xAxis[xAxisKey].scale);
44
45
  const yScale = yAxis[yAxisKey].scale;
45
46
  const xData = xAxis[xAxisKey].data;
47
+ const gradientUsed = yAxis[yAxisKey].colorScale && [yAxisKey, 'y'] || xAxis[xAxisKey].colorScale && [xAxisKey, 'x'] || undefined;
46
48
  if (process.env.NODE_ENV !== 'production') {
47
49
  if (xData === undefined) {
48
50
  throw new Error(`MUI X Charts: ${xAxisKey === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisKey}"`} should have data property to be able to display a line plot.`);
@@ -60,6 +62,7 @@ const useAggregatedData = () => {
60
62
  const d3Data = connectNulls ? formattedData.filter((_, i) => data[i] != null) : formattedData;
61
63
  const d = areaPath.curve(curve)(d3Data) || '';
62
64
  return _extends({}, series[seriesId], {
65
+ gradientUsed,
63
66
  d,
64
67
  seriesId
65
68
  });
@@ -86,6 +89,7 @@ function AreaPlot(props) {
86
89
  skipAnimation
87
90
  } = props,
88
91
  other = _objectWithoutPropertiesLoose(props, _excluded);
92
+ const getGradientId = useChartGradient();
89
93
  const completedData = useAggregatedData();
90
94
  return /*#__PURE__*/_jsx("g", _extends({}, other, {
91
95
  children: completedData.reverse().map(({
@@ -93,11 +97,13 @@ function AreaPlot(props) {
93
97
  seriesId,
94
98
  color,
95
99
  highlightScope,
96
- area
100
+ area,
101
+ gradientUsed
97
102
  }) => !!area && /*#__PURE__*/_jsx(AreaElement, {
98
103
  id: seriesId,
99
104
  d: d,
100
105
  color: color,
106
+ gradientId: gradientUsed && getGradientId(...gradientUsed),
101
107
  highlightScope: highlightScope,
102
108
  slots: slots,
103
109
  slotProps: slotProps,