@mui/x-charts 7.3.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 (176) hide show
  1. package/BarChart/BarChart.d.ts +1 -0
  2. package/BarChart/BarChart.js +8 -97
  3. package/BarChart/BarElement.d.ts +63 -62
  4. package/BarChart/BarElement.js +1 -2
  5. package/BarChart/BarPlot.js +3 -3
  6. package/CHANGELOG.md +79 -2
  7. package/ChartContainer/ChartContainer.js +3 -1
  8. package/ChartsAxis/ChartsAxis.js +7 -99
  9. package/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
  10. package/ChartsClipPath/ChartsClipPath.js +1 -1
  11. package/ChartsGrid/ChartsGrid.js +1 -1
  12. package/ChartsLegend/ChartsLegend.js +1 -1
  13. package/ChartsLegend/DefaultChartsLegend.js +1 -1
  14. package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +1 -1
  15. package/ChartsReferenceLine/ChartsReferenceLine.js +1 -1
  16. package/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
  17. package/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
  18. package/ChartsSurface.js +1 -1
  19. package/ChartsText/ChartsText.js +1 -1
  20. package/ChartsTooltip/ChartsAxisTooltipContent.js +17 -4
  21. package/ChartsTooltip/ChartsItemTooltipContent.js +20 -4
  22. package/ChartsTooltip/ChartsTooltip.js +1 -1
  23. package/ChartsTooltip/ChartsTooltipTable.d.ts +3 -7
  24. package/ChartsTooltip/ChartsTooltipTable.js +8 -9
  25. package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -5
  26. package/ChartsTooltip/DefaultChartsItemTooltipContent.js +2 -4
  27. package/ChartsTooltip/utils.js +1 -1
  28. package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +1 -1
  29. package/ChartsXAxis/ChartsXAxis.js +1 -1
  30. package/ChartsYAxis/ChartsYAxis.js +1 -1
  31. package/Gauge/Gauge.js +1 -1
  32. package/Gauge/GaugeContainer.js +1 -1
  33. package/Gauge/GaugeProvider.js +1 -1
  34. package/Gauge/GaugeReferenceArc.js +1 -1
  35. package/Gauge/GaugeValueArc.js +1 -1
  36. package/Gauge/GaugeValueText.js +1 -1
  37. package/LineChart/AnimatedArea.d.ts +63 -62
  38. package/LineChart/AnimatedArea.js +1 -1
  39. package/LineChart/AnimatedLine.d.ts +63 -62
  40. package/LineChart/AnimatedLine.js +1 -1
  41. package/LineChart/AreaElement.js +1 -1
  42. package/LineChart/AreaPlot.js +1 -1
  43. package/LineChart/LineChart.d.ts +1 -0
  44. package/LineChart/LineChart.js +8 -97
  45. package/LineChart/LineElement.js +1 -1
  46. package/LineChart/LineHighlightElement.js +1 -1
  47. package/LineChart/LineHighlightPlot.js +1 -1
  48. package/LineChart/LinePlot.js +1 -1
  49. package/LineChart/MarkElement.js +1 -1
  50. package/LineChart/MarkPlot.js +1 -1
  51. package/PieChart/PieArc.d.ts +1 -0
  52. package/PieChart/PieArc.js +1 -1
  53. package/PieChart/PieArcLabel.d.ts +1 -0
  54. package/PieChart/PieArcLabel.js +1 -1
  55. package/PieChart/PieArcLabelPlot.js +1 -1
  56. package/PieChart/PieArcPlot.js +1 -1
  57. package/PieChart/PieChart.d.ts +1 -0
  58. package/PieChart/PieChart.js +8 -97
  59. package/PieChart/PiePlot.js +1 -1
  60. package/PieChart/dataTransform/transition.d.ts +1 -0
  61. package/PieChart/dataTransform/useTransformData.js +1 -1
  62. package/ResponsiveChartContainer/ResponsiveChartContainer.js +3 -1
  63. package/ResponsiveChartContainer/useChartContainerDimensions.js +1 -1
  64. package/ScatterChart/Scatter.js +1 -1
  65. package/ScatterChart/ScatterChart.d.ts +3 -1
  66. package/ScatterChart/ScatterChart.js +63 -124
  67. package/ScatterChart/ScatterPlot.js +9 -2
  68. package/ScatterChart/getColor.d.ts +2 -1
  69. package/ScatterChart/getColor.js +18 -1
  70. package/SparkLineChart/SparkLineChart.js +1 -1
  71. package/context/CartesianContextProvider.d.ts +2 -1
  72. package/context/CartesianContextProvider.js +1 -1
  73. package/context/DrawingProvider.js +1 -1
  74. package/context/HighlightProvider.js +1 -1
  75. package/context/InteractionProvider.js +1 -1
  76. package/context/SeriesContextProvider.js +1 -1
  77. package/context/ZAxisContextProvider.d.ts +33 -0
  78. package/context/ZAxisContextProvider.js +98 -0
  79. package/context/index.d.ts +2 -0
  80. package/context/index.js +8 -1
  81. package/esm/BarChart/BarChart.js +8 -98
  82. package/esm/BarChart/BarElement.js +0 -1
  83. package/esm/BarChart/BarPlot.js +2 -2
  84. package/esm/ChartContainer/ChartContainer.js +3 -2
  85. package/esm/ChartsAxis/ChartsAxis.js +7 -100
  86. package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -2
  87. package/esm/ChartsGrid/ChartsGrid.js +1 -2
  88. package/esm/ChartsLegend/DefaultChartsLegend.js +1 -2
  89. package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +1 -2
  90. package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +1 -2
  91. package/esm/ChartsSurface.js +1 -2
  92. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +16 -3
  93. package/esm/ChartsTooltip/ChartsItemTooltipContent.js +19 -3
  94. package/esm/ChartsTooltip/ChartsTooltipTable.js +8 -8
  95. package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -6
  96. package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +2 -5
  97. package/esm/ChartsXAxis/ChartsXAxis.js +1 -2
  98. package/esm/ChartsYAxis/ChartsYAxis.js +1 -2
  99. package/esm/Gauge/Gauge.js +1 -2
  100. package/esm/LineChart/AnimatedArea.js +1 -2
  101. package/esm/LineChart/AnimatedLine.js +1 -2
  102. package/esm/LineChart/LineChart.js +8 -98
  103. package/esm/PieChart/PieChart.js +8 -98
  104. package/esm/PieChart/PiePlot.js +1 -2
  105. package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +2 -0
  106. package/esm/ScatterChart/ScatterChart.js +63 -125
  107. package/esm/ScatterChart/ScatterPlot.js +8 -1
  108. package/esm/ScatterChart/getColor.js +18 -1
  109. package/esm/SparkLineChart/SparkLineChart.js +1 -2
  110. package/esm/context/ZAxisContextProvider.js +89 -0
  111. package/esm/context/index.js +1 -1
  112. package/esm/internals/colorGetter.js +2 -2
  113. package/esm/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +1 -2
  114. package/esm/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +1 -2
  115. package/esm/models/z-axis.js +1 -0
  116. package/hooks/useAxisEvents.js +1 -1
  117. package/hooks/useChartDimensions.js +1 -1
  118. package/hooks/useChartId.js +1 -1
  119. package/hooks/useDrawingArea.js +1 -1
  120. package/hooks/useInteractionItemProps.js +1 -1
  121. package/hooks/useMounted.js +1 -1
  122. package/hooks/useScale.js +1 -1
  123. package/hooks/useSeries.js +1 -1
  124. package/hooks/useSvgRef.js +1 -1
  125. package/hooks/useTicks.js +1 -1
  126. package/index.js +1 -1
  127. package/internals/colorGetter.d.ts +3 -1
  128. package/internals/colorGetter.js +2 -2
  129. package/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +1 -1
  130. package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +1 -1
  131. package/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +1 -1
  132. package/internals/defaultizeColor.d.ts +1 -0
  133. package/internals/useAnimatedPath.d.ts +1 -0
  134. package/internals/useAnimatedPath.js +1 -1
  135. package/models/colorMapping.d.ts +3 -2
  136. package/models/seriesType/pie.d.ts +5 -0
  137. package/models/seriesType/scatter.d.ts +5 -0
  138. package/models/z-axis.d.ts +14 -0
  139. package/models/z-axis.js +5 -0
  140. package/modern/BarChart/BarChart.js +8 -98
  141. package/modern/BarChart/BarElement.js +0 -1
  142. package/modern/BarChart/BarPlot.js +2 -2
  143. package/modern/ChartContainer/ChartContainer.js +3 -2
  144. package/modern/ChartsAxis/ChartsAxis.js +7 -100
  145. package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -2
  146. package/modern/ChartsGrid/ChartsGrid.js +1 -2
  147. package/modern/ChartsLegend/DefaultChartsLegend.js +1 -2
  148. package/modern/ChartsReferenceLine/ChartsXReferenceLine.js +1 -2
  149. package/modern/ChartsReferenceLine/ChartsYReferenceLine.js +1 -2
  150. package/modern/ChartsSurface.js +1 -2
  151. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +16 -3
  152. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +19 -3
  153. package/modern/ChartsTooltip/ChartsTooltipTable.js +8 -8
  154. package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -6
  155. package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +2 -5
  156. package/modern/ChartsXAxis/ChartsXAxis.js +1 -2
  157. package/modern/ChartsYAxis/ChartsYAxis.js +1 -2
  158. package/modern/Gauge/Gauge.js +1 -2
  159. package/modern/LineChart/AnimatedArea.js +1 -2
  160. package/modern/LineChart/AnimatedLine.js +1 -2
  161. package/modern/LineChart/LineChart.js +8 -98
  162. package/modern/PieChart/PieChart.js +8 -98
  163. package/modern/PieChart/PiePlot.js +1 -2
  164. package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +2 -0
  165. package/modern/ScatterChart/ScatterChart.js +63 -125
  166. package/modern/ScatterChart/ScatterPlot.js +8 -1
  167. package/modern/ScatterChart/getColor.js +18 -1
  168. package/modern/SparkLineChart/SparkLineChart.js +1 -2
  169. package/modern/context/ZAxisContextProvider.js +89 -0
  170. package/modern/context/index.js +1 -1
  171. package/modern/index.js +1 -1
  172. package/modern/internals/colorGetter.js +2 -2
  173. package/modern/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +1 -2
  174. package/modern/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +1 -2
  175. package/modern/models/z-axis.js +1 -0
  176. package/package.json +3 -5
@@ -9,8 +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 { 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 defaultMargin = {
15
14
  top: 5,
16
15
  bottom: 5,
@@ -124,30 +123,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
124
123
  * Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
125
124
  * @default null
126
125
  */
127
- bottomAxis: PropTypes.oneOfType([PropTypes.shape({
128
- axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
129
- classes: PropTypes.object,
130
- disableLine: PropTypes.bool,
131
- disableTicks: PropTypes.bool,
132
- fill: PropTypes.string,
133
- label: PropTypes.string,
134
- labelFontSize: PropTypes.number,
135
- labelStyle: PropTypes.object,
136
- position: PropTypes.oneOf(['bottom', 'top']),
137
- slotProps: PropTypes.object,
138
- slots: PropTypes.object,
139
- stroke: PropTypes.string,
140
- tickFontSize: PropTypes.number,
141
- tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
142
- tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
143
- tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
144
- tickLabelStyle: PropTypes.object,
145
- tickMaxStep: PropTypes.number,
146
- tickMinStep: PropTypes.number,
147
- tickNumber: PropTypes.number,
148
- tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
149
- tickSize: PropTypes.number
150
- }), PropTypes.string]),
126
+ bottomAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
151
127
  children: PropTypes.node,
152
128
  className: PropTypes.string,
153
129
  /**
@@ -175,30 +151,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
175
151
  * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
176
152
  * @default null
177
153
  */
178
- leftAxis: PropTypes.oneOfType([PropTypes.shape({
179
- axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
180
- classes: PropTypes.object,
181
- disableLine: PropTypes.bool,
182
- disableTicks: PropTypes.bool,
183
- fill: PropTypes.string,
184
- label: PropTypes.string,
185
- labelFontSize: PropTypes.number,
186
- labelStyle: PropTypes.object,
187
- position: PropTypes.oneOf(['left', 'right']),
188
- slotProps: PropTypes.object,
189
- slots: PropTypes.object,
190
- stroke: PropTypes.string,
191
- tickFontSize: PropTypes.number,
192
- tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
193
- tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
194
- tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
195
- tickLabelStyle: PropTypes.object,
196
- tickMaxStep: PropTypes.number,
197
- tickMinStep: PropTypes.number,
198
- tickNumber: PropTypes.number,
199
- tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
200
- tickSize: PropTypes.number
201
- }), PropTypes.string]),
154
+ leftAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
202
155
  /**
203
156
  * The props of the legend.
204
157
  * @default { direction: 'column', position: { vertical: 'middle', horizontal: 'right' } }
@@ -236,32 +189,10 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
236
189
  * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
237
190
  * @default null
238
191
  */
239
- rightAxis: PropTypes.oneOfType([PropTypes.shape({
240
- axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
241
- classes: PropTypes.object,
242
- disableLine: PropTypes.bool,
243
- disableTicks: PropTypes.bool,
244
- fill: PropTypes.string,
245
- label: PropTypes.string,
246
- labelFontSize: PropTypes.number,
247
- labelStyle: PropTypes.object,
248
- position: PropTypes.oneOf(['left', 'right']),
249
- slotProps: PropTypes.object,
250
- slots: PropTypes.object,
251
- stroke: PropTypes.string,
252
- tickFontSize: PropTypes.number,
253
- tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
254
- tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
255
- tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
256
- tickLabelStyle: PropTypes.object,
257
- tickMaxStep: PropTypes.number,
258
- tickMinStep: PropTypes.number,
259
- tickNumber: PropTypes.number,
260
- tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
261
- tickSize: PropTypes.number
262
- }), PropTypes.string]),
192
+ rightAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
263
193
  /**
264
194
  * The series to display in the pie chart.
195
+ * An array of [[PieSeriesType]] objects.
265
196
  */
266
197
  series: PropTypes.arrayOf(PropTypes.object).isRequired,
267
198
  /**
@@ -299,30 +230,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
299
230
  * Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
300
231
  * @default null
301
232
  */
302
- topAxis: PropTypes.oneOfType([PropTypes.shape({
303
- axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
304
- classes: PropTypes.object,
305
- disableLine: PropTypes.bool,
306
- disableTicks: PropTypes.bool,
307
- fill: PropTypes.string,
308
- label: PropTypes.string,
309
- labelFontSize: PropTypes.number,
310
- labelStyle: PropTypes.object,
311
- position: PropTypes.oneOf(['bottom', 'top']),
312
- slotProps: PropTypes.object,
313
- slots: PropTypes.object,
314
- stroke: PropTypes.string,
315
- tickFontSize: PropTypes.number,
316
- tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
317
- tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
318
- tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
319
- tickLabelStyle: PropTypes.object,
320
- tickMaxStep: PropTypes.number,
321
- tickMinStep: PropTypes.number,
322
- tickNumber: PropTypes.number,
323
- tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
324
- tickSize: PropTypes.number
325
- }), PropTypes.string]),
233
+ topAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
326
234
  viewBox: PropTypes.shape({
327
235
  height: PropTypes.number,
328
236
  width: PropTypes.number,
@@ -336,6 +244,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
336
244
  /**
337
245
  * The configuration of the x-axes.
338
246
  * If not provided, a default axis config is used.
247
+ * An array of [[AxisConfig]] objects.
339
248
  */
340
249
  xAxis: PropTypes.arrayOf(PropTypes.shape({
341
250
  axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
@@ -388,6 +297,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
388
297
  /**
389
298
  * The configuration of the y-axes.
390
299
  * If not provided, a default axis config is used.
300
+ * An array of [[AxisConfig]] objects.
391
301
  */
392
302
  yAxis: PropTypes.arrayOf(PropTypes.shape({
393
303
  axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
@@ -6,8 +6,7 @@ import { PieArcPlot } from './PieArcPlot';
6
6
  import { PieArcLabelPlot } from './PieArcLabelPlot';
7
7
  import { getPercentageValue } from '../internals/utils';
8
8
  import { getPieCoordinates } from './getPieCoordinates';
9
- import { jsx as _jsx } from "react/jsx-runtime";
10
- import { jsxs as _jsxs } from "react/jsx-runtime";
9
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
10
  /**
12
11
  * Demos:
13
12
  *
@@ -107,6 +107,7 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
107
107
  /**
108
108
  * The configuration of the x-axes.
109
109
  * If not provided, a default axis config is used.
110
+ * An array of [[AxisConfig]] objects.
110
111
  */
111
112
  xAxis: PropTypes.arrayOf(PropTypes.shape({
112
113
  axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
@@ -159,6 +160,7 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
159
160
  /**
160
161
  * The configuration of the y-axes.
161
162
  * If not provided, a default axis config is used.
163
+ * An array of [[AxisConfig]] objects.
162
164
  */
163
165
  yAxis: PropTypes.arrayOf(PropTypes.shape({
164
166
  axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
@@ -9,8 +9,8 @@ import { ChartsLegend } from '../ChartsLegend';
9
9
  import { ChartsAxisHighlight } from '../ChartsAxisHighlight';
10
10
  import { ChartsVoronoiHandler } from '../ChartsVoronoiHandler/ChartsVoronoiHandler';
11
11
  import { ChartsGrid } from '../ChartsGrid';
12
- import { jsx as _jsx } from "react/jsx-runtime";
13
- import { jsxs as _jsxs } from "react/jsx-runtime";
12
+ import { ZAxisContextProvider } from '../context/ZAxisContextProvider';
13
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  /**
15
15
  * Demos:
16
16
  *
@@ -25,6 +25,7 @@ const ScatterChart = /*#__PURE__*/React.forwardRef(function ScatterChart(props,
25
25
  const {
26
26
  xAxis,
27
27
  yAxis,
28
+ zAxis,
28
29
  series,
29
30
  tooltip,
30
31
  axisHighlight,
@@ -46,7 +47,7 @@ const ScatterChart = /*#__PURE__*/React.forwardRef(function ScatterChart(props,
46
47
  slots,
47
48
  slotProps
48
49
  } = props;
49
- return /*#__PURE__*/_jsxs(ResponsiveChartContainer, {
50
+ return /*#__PURE__*/_jsx(ResponsiveChartContainer, {
50
51
  ref: ref,
51
52
  series: series.map(s => _extends({
52
53
  type: 'scatter'
@@ -58,32 +59,35 @@ const ScatterChart = /*#__PURE__*/React.forwardRef(function ScatterChart(props,
58
59
  xAxis: xAxis,
59
60
  yAxis: yAxis,
60
61
  sx: sx,
61
- children: [!disableVoronoi && /*#__PURE__*/_jsx(ChartsVoronoiHandler, {
62
- voronoiMaxRadius: voronoiMaxRadius,
63
- onItemClick: onItemClick
64
- }), /*#__PURE__*/_jsx(ChartsAxis, {
65
- topAxis: topAxis,
66
- leftAxis: leftAxis,
67
- rightAxis: rightAxis,
68
- bottomAxis: bottomAxis,
69
- slots: slots,
70
- slotProps: slotProps
71
- }), grid && /*#__PURE__*/_jsx(ChartsGrid, {
72
- vertical: grid.vertical,
73
- horizontal: grid.horizontal
74
- }), /*#__PURE__*/_jsx(ScatterPlot, {
75
- slots: slots,
76
- slotProps: slotProps,
77
- onItemClick: disableVoronoi ? onItemClick : undefined
78
- }), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend, {
79
- slots: slots,
80
- slotProps: slotProps
81
- })), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({
82
- x: "none",
83
- y: "none"
84
- }, axisHighlight)), /*#__PURE__*/_jsx(ChartsTooltip, _extends({
85
- trigger: "item"
86
- }, tooltip)), children]
62
+ children: /*#__PURE__*/_jsxs(ZAxisContextProvider, {
63
+ zAxis: zAxis,
64
+ children: [!disableVoronoi && /*#__PURE__*/_jsx(ChartsVoronoiHandler, {
65
+ voronoiMaxRadius: voronoiMaxRadius,
66
+ onItemClick: onItemClick
67
+ }), /*#__PURE__*/_jsx(ChartsAxis, {
68
+ topAxis: topAxis,
69
+ leftAxis: leftAxis,
70
+ rightAxis: rightAxis,
71
+ bottomAxis: bottomAxis,
72
+ slots: slots,
73
+ slotProps: slotProps
74
+ }), grid && /*#__PURE__*/_jsx(ChartsGrid, {
75
+ vertical: grid.vertical,
76
+ horizontal: grid.horizontal
77
+ }), /*#__PURE__*/_jsx(ScatterPlot, {
78
+ slots: slots,
79
+ slotProps: slotProps,
80
+ onItemClick: disableVoronoi ? onItemClick : undefined
81
+ }), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend, {
82
+ slots: slots,
83
+ slotProps: slotProps
84
+ })), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({
85
+ x: "none",
86
+ y: "none"
87
+ }, axisHighlight)), /*#__PURE__*/_jsx(ChartsTooltip, _extends({
88
+ trigger: "item"
89
+ }, tooltip)), children]
90
+ })
87
91
  });
88
92
  });
89
93
  process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
@@ -105,30 +109,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
105
109
  * Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
106
110
  * @default xAxisIds[0] The id of the first provided axis
107
111
  */
108
- bottomAxis: PropTypes.oneOfType([PropTypes.shape({
109
- axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
110
- classes: PropTypes.object,
111
- disableLine: PropTypes.bool,
112
- disableTicks: PropTypes.bool,
113
- fill: PropTypes.string,
114
- label: PropTypes.string,
115
- labelFontSize: PropTypes.number,
116
- labelStyle: PropTypes.object,
117
- position: PropTypes.oneOf(['bottom', 'top']),
118
- slotProps: PropTypes.object,
119
- slots: PropTypes.object,
120
- stroke: PropTypes.string,
121
- tickFontSize: PropTypes.number,
122
- tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
123
- tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
124
- tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
125
- tickLabelStyle: PropTypes.object,
126
- tickMaxStep: PropTypes.number,
127
- tickMinStep: PropTypes.number,
128
- tickNumber: PropTypes.number,
129
- tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
130
- tickSize: PropTypes.number
131
- }), PropTypes.string]),
112
+ bottomAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
132
113
  children: PropTypes.node,
133
114
  className: PropTypes.string,
134
115
  /**
@@ -168,30 +149,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
168
149
  * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
169
150
  * @default yAxisIds[0] The id of the first provided axis
170
151
  */
171
- leftAxis: PropTypes.oneOfType([PropTypes.shape({
172
- axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
173
- classes: PropTypes.object,
174
- disableLine: PropTypes.bool,
175
- disableTicks: PropTypes.bool,
176
- fill: PropTypes.string,
177
- label: PropTypes.string,
178
- labelFontSize: PropTypes.number,
179
- labelStyle: PropTypes.object,
180
- position: PropTypes.oneOf(['left', 'right']),
181
- slotProps: PropTypes.object,
182
- slots: PropTypes.object,
183
- stroke: PropTypes.string,
184
- tickFontSize: PropTypes.number,
185
- tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
186
- tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
187
- tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
188
- tickLabelStyle: PropTypes.object,
189
- tickMaxStep: PropTypes.number,
190
- tickMinStep: PropTypes.number,
191
- tickNumber: PropTypes.number,
192
- tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
193
- tickSize: PropTypes.number
194
- }), PropTypes.string]),
152
+ leftAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
195
153
  /**
196
154
  * @deprecated Consider using `slotProps.legend` instead.
197
155
  */
@@ -229,32 +187,10 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
229
187
  * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
230
188
  * @default null
231
189
  */
232
- rightAxis: PropTypes.oneOfType([PropTypes.shape({
233
- axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
234
- classes: PropTypes.object,
235
- disableLine: PropTypes.bool,
236
- disableTicks: PropTypes.bool,
237
- fill: PropTypes.string,
238
- label: PropTypes.string,
239
- labelFontSize: PropTypes.number,
240
- labelStyle: PropTypes.object,
241
- position: PropTypes.oneOf(['left', 'right']),
242
- slotProps: PropTypes.object,
243
- slots: PropTypes.object,
244
- stroke: PropTypes.string,
245
- tickFontSize: PropTypes.number,
246
- tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
247
- tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
248
- tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
249
- tickLabelStyle: PropTypes.object,
250
- tickMaxStep: PropTypes.number,
251
- tickMinStep: PropTypes.number,
252
- tickNumber: PropTypes.number,
253
- tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
254
- tickSize: PropTypes.number
255
- }), PropTypes.string]),
190
+ rightAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
256
191
  /**
257
192
  * The series to display in the scatter chart.
193
+ * An array of [[ScatterSeriesType]] objects.
258
194
  */
259
195
  series: PropTypes.arrayOf(PropTypes.object).isRequired,
260
196
  /**
@@ -287,30 +223,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
287
223
  * Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
288
224
  * @default null
289
225
  */
290
- topAxis: PropTypes.oneOfType([PropTypes.shape({
291
- axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
292
- classes: PropTypes.object,
293
- disableLine: PropTypes.bool,
294
- disableTicks: PropTypes.bool,
295
- fill: PropTypes.string,
296
- label: PropTypes.string,
297
- labelFontSize: PropTypes.number,
298
- labelStyle: PropTypes.object,
299
- position: PropTypes.oneOf(['bottom', 'top']),
300
- slotProps: PropTypes.object,
301
- slots: PropTypes.object,
302
- stroke: PropTypes.string,
303
- tickFontSize: PropTypes.number,
304
- tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
305
- tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
306
- tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
307
- tickLabelStyle: PropTypes.object,
308
- tickMaxStep: PropTypes.number,
309
- tickMinStep: PropTypes.number,
310
- tickNumber: PropTypes.number,
311
- tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
312
- tickSize: PropTypes.number
313
- }), PropTypes.string]),
226
+ topAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
314
227
  viewBox: PropTypes.shape({
315
228
  height: PropTypes.number,
316
229
  width: PropTypes.number,
@@ -329,6 +242,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
329
242
  /**
330
243
  * The configuration of the x-axes.
331
244
  * If not provided, a default axis config is used.
245
+ * An array of [[AxisConfig]] objects.
332
246
  */
333
247
  xAxis: PropTypes.arrayOf(PropTypes.shape({
334
248
  axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
@@ -381,6 +295,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
381
295
  /**
382
296
  * The configuration of the y-axes.
383
297
  * If not provided, a default axis config is used.
298
+ * An array of [[AxisConfig]] objects.
384
299
  */
385
300
  yAxis: PropTypes.arrayOf(PropTypes.shape({
386
301
  axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
@@ -429,6 +344,29 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
429
344
  tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
430
345
  tickSize: PropTypes.number,
431
346
  valueFormatter: PropTypes.func
347
+ })),
348
+ /**
349
+ * The configuration of the z-axes.
350
+ */
351
+ zAxis: PropTypes.arrayOf(PropTypes.shape({
352
+ colorMap: PropTypes.oneOfType([PropTypes.shape({
353
+ color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
354
+ max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
355
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
356
+ type: PropTypes.oneOf(['continuous']).isRequired
357
+ }), PropTypes.shape({
358
+ colors: PropTypes.arrayOf(PropTypes.string).isRequired,
359
+ thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
360
+ type: PropTypes.oneOf(['piecewise']).isRequired
361
+ }), PropTypes.shape({
362
+ colors: PropTypes.arrayOf(PropTypes.string).isRequired,
363
+ type: PropTypes.oneOf(['ordinal']).isRequired,
364
+ unknownColor: PropTypes.string,
365
+ values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
366
+ })]),
367
+ data: PropTypes.array,
368
+ dataKey: PropTypes.string,
369
+ id: PropTypes.string
432
370
  }))
433
371
  } : void 0;
434
372
  export { ScatterChart };
@@ -5,6 +5,7 @@ import { Scatter } from './Scatter';
5
5
  import { SeriesContext } from '../context/SeriesContextProvider';
6
6
  import { CartesianContext } from '../context/CartesianContextProvider';
7
7
  import getColor from './getColor';
8
+ import { ZAxisContext } from '../context/ZAxisContextProvider';
8
9
  import { jsx as _jsx } from "react/jsx-runtime";
9
10
  /**
10
11
  * Demos:
@@ -24,6 +25,10 @@ function ScatterPlot(props) {
24
25
  } = props;
25
26
  const seriesData = React.useContext(SeriesContext).scatter;
26
27
  const axisData = React.useContext(CartesianContext);
28
+ const {
29
+ zAxis,
30
+ zAxisIds
31
+ } = React.useContext(ZAxisContext);
27
32
  if (seriesData === undefined) {
28
33
  return null;
29
34
  }
@@ -39,6 +44,7 @@ function ScatterPlot(props) {
39
44
  } = axisData;
40
45
  const defaultXAxisId = xAxisIds[0];
41
46
  const defaultYAxisId = yAxisIds[0];
47
+ const defaultZAxisId = zAxisIds[0];
42
48
  const ScatterItems = slots?.scatter ?? Scatter;
43
49
  return /*#__PURE__*/_jsx(React.Fragment, {
44
50
  children: seriesOrder.map(seriesId => {
@@ -46,10 +52,11 @@ function ScatterPlot(props) {
46
52
  id,
47
53
  xAxisKey,
48
54
  yAxisKey,
55
+ zAxisKey,
49
56
  markerSize,
50
57
  color
51
58
  } = series[seriesId];
52
- const colorGetter = getColor(series[seriesId], xAxis[xAxisKey ?? defaultXAxisId], yAxis[yAxisKey ?? defaultYAxisId]);
59
+ const colorGetter = getColor(series[seriesId], xAxis[xAxisKey ?? defaultXAxisId], yAxis[yAxisKey ?? defaultYAxisId], zAxis[zAxisKey ?? defaultZAxisId]);
53
60
  const xScale = xAxis[xAxisKey ?? defaultXAxisId].scale;
54
61
  const yScale = yAxis[yAxisKey ?? defaultYAxisId].scale;
55
62
  return /*#__PURE__*/_jsx(ScatterItems, _extends({
@@ -1,6 +1,23 @@
1
- export default function getColor(series, xAxis, yAxis) {
1
+ export default function getColor(series, xAxis, yAxis, zAxis) {
2
+ const zColorScale = zAxis?.colorScale;
2
3
  const yColorScale = yAxis.colorScale;
3
4
  const xColorScale = xAxis.colorScale;
5
+ if (zColorScale) {
6
+ return dataIndex => {
7
+ if (zAxis?.data?.[dataIndex] !== undefined) {
8
+ const color = zColorScale(zAxis?.data?.[dataIndex]);
9
+ if (color !== null) {
10
+ return color;
11
+ }
12
+ }
13
+ const value = series.data[dataIndex];
14
+ const color = value === null ? series.color : zColorScale(value.z);
15
+ if (color === null) {
16
+ return series.color;
17
+ }
18
+ return color;
19
+ };
20
+ }
4
21
  if (yColorScale) {
5
22
  return dataIndex => {
6
23
  const value = series.data[dataIndex];
@@ -7,8 +7,7 @@ import { ResponsiveChartContainer } from '../ResponsiveChartContainer';
7
7
  import { DEFAULT_X_AXIS_KEY } from '../constants';
8
8
  import { ChartsTooltip } from '../ChartsTooltip';
9
9
  import { ChartsAxisHighlight } from '../ChartsAxisHighlight';
10
- import { jsx as _jsx } from "react/jsx-runtime";
11
- import { jsxs as _jsxs } from "react/jsx-runtime";
10
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
11
  const SPARKLINE_DEFAULT_MARGIN = {
13
12
  top: 5,
14
13
  bottom: 5,
@@ -0,0 +1,89 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import * as React from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import { getColorScale, getOrdinalColorScale } from '../internals/colorScale';
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ export const ZAxisContext = /*#__PURE__*/React.createContext({
7
+ zAxis: {},
8
+ zAxisIds: []
9
+ });
10
+ if (process.env.NODE_ENV !== 'production') {
11
+ ZAxisContext.displayName = 'ZAxisContext';
12
+ }
13
+ function ZAxisContextProvider(props) {
14
+ const {
15
+ zAxis: inZAxis,
16
+ dataset,
17
+ children
18
+ } = props;
19
+ const zAxis = React.useMemo(() => inZAxis?.map(axisConfig => {
20
+ const dataKey = axisConfig.dataKey;
21
+ if (dataKey === undefined || axisConfig.data !== undefined) {
22
+ return axisConfig;
23
+ }
24
+ if (dataset === undefined) {
25
+ throw Error('MUI X Charts: z-axis uses `dataKey` but no `dataset` is provided.');
26
+ }
27
+ return _extends({}, axisConfig, {
28
+ data: dataset.map(d => d[dataKey])
29
+ });
30
+ }), [inZAxis, dataset]);
31
+ const value = React.useMemo(() => {
32
+ const allZAxis = zAxis?.map((axis, index) => _extends({
33
+ id: `defaultized-z-axis-${index}`
34
+ }, axis)) ?? [];
35
+ const completedZAxis = {};
36
+ allZAxis.forEach(axis => {
37
+ completedZAxis[axis.id] = _extends({}, axis, {
38
+ colorScale: axis.colorMap && (axis.colorMap.type === 'ordinal' && axis.data ? getOrdinalColorScale(_extends({
39
+ values: axis.data
40
+ }, axis.colorMap)) : getColorScale(axis.colorMap))
41
+ });
42
+ });
43
+ return {
44
+ zAxis: completedZAxis,
45
+ zAxisIds: allZAxis.map(({
46
+ id
47
+ }) => id)
48
+ };
49
+ }, [zAxis]);
50
+ return /*#__PURE__*/_jsx(ZAxisContext.Provider, {
51
+ value: value,
52
+ children: children
53
+ });
54
+ }
55
+ process.env.NODE_ENV !== "production" ? ZAxisContextProvider.propTypes = {
56
+ // ----------------------------- Warning --------------------------------
57
+ // | These PropTypes are generated from the TypeScript type definitions |
58
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
59
+ // ----------------------------------------------------------------------
60
+ children: PropTypes.node,
61
+ /**
62
+ * An array of objects that can be used to populate series and axes data using their `dataKey` property.
63
+ */
64
+ dataset: PropTypes.arrayOf(PropTypes.object),
65
+ /**
66
+ * The configuration of the z-axes.
67
+ */
68
+ zAxis: PropTypes.arrayOf(PropTypes.shape({
69
+ colorMap: PropTypes.oneOfType([PropTypes.shape({
70
+ color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
71
+ max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
72
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
73
+ type: PropTypes.oneOf(['continuous']).isRequired
74
+ }), PropTypes.shape({
75
+ colors: PropTypes.arrayOf(PropTypes.string).isRequired,
76
+ thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
77
+ type: PropTypes.oneOf(['piecewise']).isRequired
78
+ }), PropTypes.shape({
79
+ colors: PropTypes.arrayOf(PropTypes.string).isRequired,
80
+ type: PropTypes.oneOf(['ordinal']).isRequired,
81
+ unknownColor: PropTypes.string,
82
+ values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
83
+ })]),
84
+ data: PropTypes.array,
85
+ dataKey: PropTypes.string,
86
+ id: PropTypes.string
87
+ }))
88
+ } : void 0;
89
+ export { ZAxisContextProvider };
@@ -1 +1 @@
1
- export {};
1
+ export { ZAxisContextProvider } from './ZAxisContextProvider';
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v7.3.0
2
+ * @mui/x-charts v7.3.1
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -2,7 +2,7 @@ import getBarColor from '../BarChart/getColor';
2
2
  import getLineColor from '../LineChart/getColor';
3
3
  import getScatterColor from '../ScatterChart/getColor';
4
4
  import getPieColor from '../PieChart/getColor';
5
- function getColor(series, xAxis, yAxis) {
5
+ function getColor(series, xAxis, yAxis, zAxis) {
6
6
  if (xAxis !== undefined && yAxis !== undefined) {
7
7
  if (series.type === 'bar') {
8
8
  return getBarColor(series, xAxis, yAxis);
@@ -11,7 +11,7 @@ function getColor(series, xAxis, yAxis) {
11
11
  return getLineColor(series, xAxis, yAxis);
12
12
  }
13
13
  if (series.type === 'scatter') {
14
- return getScatterColor(series, xAxis, yAxis);
14
+ return getScatterColor(series, xAxis, yAxis, zAxis);
15
15
  }
16
16
  }
17
17
  if (series.type === 'pie') {
@@ -4,8 +4,7 @@ import { DrawingContext } from '../../../context/DrawingProvider';
4
4
  import { useDrawingArea } from '../../../hooks';
5
5
  import ChartsPiecewiseGradient from './ChartsPiecewiseGradient';
6
6
  import ChartsContinuousGradient from './ChartsContinuousGradient';
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
  export function useChartGradient() {
10
9
  const {
11
10
  chartId
@@ -1,6 +1,5 @@
1
1
  import * as React from 'react';
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- import { jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
3
  export default function ChartsPiecewiseGradient(props) {
5
4
  const {
6
5
  isReveresed,
@@ -0,0 +1 @@
1
+ export {};