@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
@@ -8,7 +8,8 @@ import { useReducedMotion } from '../hooks/useReducedMotion';
8
8
  import { ChartsSurface } from '../ChartsSurface';
9
9
  import { CartesianContextProvider } from '../context/CartesianContextProvider';
10
10
  import { HighlightProvider } from '../context/HighlightProvider';
11
- import { jsx as _jsx } from "react/jsx-runtime";
11
+ import { ChartsAxesGradients } from '../internals/components/ChartsAxesGradients';
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
13
  const ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContainer(props, ref) {
13
14
  const {
14
15
  width,
@@ -44,7 +45,7 @@ const ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContainer(pro
44
45
  dataset: dataset,
45
46
  children: /*#__PURE__*/_jsx(InteractionProvider, {
46
47
  children: /*#__PURE__*/_jsx(HighlightProvider, {
47
- children: /*#__PURE__*/_jsx(ChartsSurface, {
48
+ children: /*#__PURE__*/_jsxs(ChartsSurface, {
48
49
  width: width,
49
50
  height: height,
50
51
  ref: handleRef,
@@ -52,7 +53,7 @@ const ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContainer(pro
52
53
  title: title,
53
54
  desc: desc,
54
55
  disableAxisListener: disableAxisListener,
55
- children: children
56
+ children: [/*#__PURE__*/_jsx(ChartsAxesGradients, {}), children]
56
57
  })
57
58
  })
58
59
  })
@@ -119,11 +120,27 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
119
120
  width: PropTypes.number.isRequired,
120
121
  /**
121
122
  * The configuration of the x-axes.
122
- * If not provided, a default axis config is used with id set to `DEFAULT_X_AXIS_KEY`.
123
+ * If not provided, a default axis config is used.
124
+ * An array of [[AxisConfig]] objects.
123
125
  */
124
126
  xAxis: PropTypes.arrayOf(PropTypes.shape({
125
127
  axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
126
128
  classes: PropTypes.object,
129
+ colorMap: PropTypes.oneOfType([PropTypes.shape({
130
+ color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
131
+ max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
132
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
133
+ type: PropTypes.oneOf(['continuous']).isRequired
134
+ }), PropTypes.shape({
135
+ colors: PropTypes.arrayOf(PropTypes.string).isRequired,
136
+ thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
137
+ type: PropTypes.oneOf(['piecewise']).isRequired
138
+ }), PropTypes.shape({
139
+ colors: PropTypes.arrayOf(PropTypes.string).isRequired,
140
+ type: PropTypes.oneOf(['ordinal']).isRequired,
141
+ unknownColor: PropTypes.string,
142
+ values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
143
+ })]),
127
144
  data: PropTypes.array,
128
145
  dataKey: PropTypes.string,
129
146
  disableLine: PropTypes.bool,
@@ -156,11 +173,27 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
156
173
  })),
157
174
  /**
158
175
  * The configuration of the y-axes.
159
- * If not provided, a default axis config is used with id set to `DEFAULT_Y_AXIS_KEY`.
176
+ * If not provided, a default axis config is used.
177
+ * An array of [[AxisConfig]] objects.
160
178
  */
161
179
  yAxis: PropTypes.arrayOf(PropTypes.shape({
162
180
  axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
163
181
  classes: PropTypes.object,
182
+ colorMap: PropTypes.oneOfType([PropTypes.shape({
183
+ color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
184
+ max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
185
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
186
+ type: PropTypes.oneOf(['continuous']).isRequired
187
+ }), PropTypes.shape({
188
+ colors: PropTypes.arrayOf(PropTypes.string).isRequired,
189
+ thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
190
+ type: PropTypes.oneOf(['piecewise']).isRequired
191
+ }), PropTypes.shape({
192
+ colors: PropTypes.arrayOf(PropTypes.string).isRequired,
193
+ type: PropTypes.oneOf(['ordinal']).isRequired,
194
+ unknownColor: PropTypes.string,
195
+ values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
196
+ })]),
164
197
  data: PropTypes.array,
165
198
  dataKey: PropTypes.string,
166
199
  disableLine: PropTypes.bool,
@@ -4,14 +4,13 @@ import PropTypes from 'prop-types';
4
4
  import { CartesianContext } from '../context/CartesianContextProvider';
5
5
  import { ChartsXAxis } from '../ChartsXAxis';
6
6
  import { ChartsYAxis } from '../ChartsYAxis';
7
- import { jsx as _jsx } from "react/jsx-runtime";
8
- import { jsxs as _jsxs } from "react/jsx-runtime";
9
- const getAxisId = propsValue => {
7
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
8
+ const getAxisId = (propsValue, defaultAxisId) => {
10
9
  if (propsValue == null) {
11
10
  return null;
12
11
  }
13
12
  if (typeof propsValue === 'object') {
14
- return propsValue.axisId ?? null;
13
+ return propsValue.axisId ?? defaultAxisId ?? null;
15
14
  }
16
15
  return propsValue;
17
16
  };
@@ -53,10 +52,10 @@ function ChartsAxis(props) {
53
52
  // TODO: use for plotting line without ticks or any thing
54
53
  // const drawingArea = React.useContext(DrawingContext);
55
54
 
56
- const leftId = getAxisId(leftAxis === undefined ? yAxisIds[0] : leftAxis);
57
- const bottomId = getAxisId(bottomAxis === undefined ? xAxisIds[0] : bottomAxis);
58
- const topId = getAxisId(topAxis);
59
- const rightId = getAxisId(rightAxis);
55
+ const leftId = getAxisId(leftAxis === undefined ? yAxisIds[0] : leftAxis, yAxisIds[0]);
56
+ const bottomId = getAxisId(bottomAxis === undefined ? xAxisIds[0] : bottomAxis, xAxisIds[0]);
57
+ const topId = getAxisId(topAxis, xAxisIds[0]);
58
+ const rightId = getAxisId(rightAxis, yAxisIds[0]);
60
59
  if (topId !== null && !xAxis[topId]) {
61
60
  throw Error([`MUI X Charts: id used for top axis "${topId}" is not defined.`, `Available ids are: ${xAxisIds.join(', ')}.`].join('\n'));
62
61
  }
@@ -99,88 +98,19 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
99
98
  * Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
100
99
  * @default xAxisIds[0] The id of the first provided axis
101
100
  */
102
- bottomAxis: PropTypes.oneOfType([PropTypes.shape({
103
- axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
104
- classes: PropTypes.object,
105
- disableLine: PropTypes.bool,
106
- disableTicks: PropTypes.bool,
107
- fill: PropTypes.string,
108
- label: PropTypes.string,
109
- labelFontSize: PropTypes.number,
110
- labelStyle: PropTypes.object,
111
- position: PropTypes.oneOf(['bottom', 'top']),
112
- slotProps: PropTypes.object,
113
- slots: PropTypes.object,
114
- stroke: PropTypes.string,
115
- tickFontSize: PropTypes.number,
116
- tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
117
- tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
118
- tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
119
- tickLabelStyle: PropTypes.object,
120
- tickMaxStep: PropTypes.number,
121
- tickMinStep: PropTypes.number,
122
- tickNumber: PropTypes.number,
123
- tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
124
- tickSize: PropTypes.number
125
- }), PropTypes.string]),
101
+ bottomAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
126
102
  /**
127
103
  * Indicate which axis to display the left of the charts.
128
104
  * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
129
105
  * @default yAxisIds[0] The id of the first provided axis
130
106
  */
131
- leftAxis: PropTypes.oneOfType([PropTypes.shape({
132
- axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
133
- classes: PropTypes.object,
134
- disableLine: PropTypes.bool,
135
- disableTicks: PropTypes.bool,
136
- fill: PropTypes.string,
137
- label: PropTypes.string,
138
- labelFontSize: PropTypes.number,
139
- labelStyle: PropTypes.object,
140
- position: PropTypes.oneOf(['left', 'right']),
141
- slotProps: PropTypes.object,
142
- slots: PropTypes.object,
143
- stroke: PropTypes.string,
144
- tickFontSize: PropTypes.number,
145
- tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
146
- tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
147
- tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
148
- tickLabelStyle: PropTypes.object,
149
- tickMaxStep: PropTypes.number,
150
- tickMinStep: PropTypes.number,
151
- tickNumber: PropTypes.number,
152
- tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
153
- tickSize: PropTypes.number
154
- }), PropTypes.string]),
107
+ leftAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
155
108
  /**
156
109
  * Indicate which axis to display the right of the charts.
157
110
  * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
158
111
  * @default null
159
112
  */
160
- rightAxis: PropTypes.oneOfType([PropTypes.shape({
161
- axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
162
- classes: PropTypes.object,
163
- disableLine: PropTypes.bool,
164
- disableTicks: PropTypes.bool,
165
- fill: PropTypes.string,
166
- label: PropTypes.string,
167
- labelFontSize: PropTypes.number,
168
- labelStyle: PropTypes.object,
169
- position: PropTypes.oneOf(['left', 'right']),
170
- slotProps: PropTypes.object,
171
- slots: PropTypes.object,
172
- stroke: PropTypes.string,
173
- tickFontSize: PropTypes.number,
174
- tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
175
- tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
176
- tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
177
- tickLabelStyle: PropTypes.object,
178
- tickMaxStep: PropTypes.number,
179
- tickMinStep: PropTypes.number,
180
- tickNumber: PropTypes.number,
181
- tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
182
- tickSize: PropTypes.number
183
- }), PropTypes.string]),
113
+ rightAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
184
114
  /**
185
115
  * The props used for each component slot.
186
116
  * @default {}
@@ -196,29 +126,6 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
196
126
  * Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
197
127
  * @default null
198
128
  */
199
- topAxis: PropTypes.oneOfType([PropTypes.shape({
200
- axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
201
- classes: PropTypes.object,
202
- disableLine: PropTypes.bool,
203
- disableTicks: PropTypes.bool,
204
- fill: PropTypes.string,
205
- label: PropTypes.string,
206
- labelFontSize: PropTypes.number,
207
- labelStyle: PropTypes.object,
208
- position: PropTypes.oneOf(['bottom', 'top']),
209
- slotProps: PropTypes.object,
210
- slots: PropTypes.object,
211
- stroke: PropTypes.string,
212
- tickFontSize: PropTypes.number,
213
- tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
214
- tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
215
- tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
216
- tickLabelStyle: PropTypes.object,
217
- tickMaxStep: PropTypes.number,
218
- tickMinStep: PropTypes.number,
219
- tickNumber: PropTypes.number,
220
- tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
221
- tickSize: PropTypes.number
222
- }), PropTypes.string])
129
+ topAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string])
223
130
  } : void 0;
224
131
  export { ChartsAxis };
@@ -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';