@mui/x-charts 6.0.0-alpha.5 → 6.0.0-alpha.7

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 (163) hide show
  1. package/BarChart/BarChart.d.ts +18 -2
  2. package/BarChart/BarChart.js +74 -17
  3. package/BarChart/BarElement.d.ts +22 -0
  4. package/BarChart/BarElement.js +21 -10
  5. package/BarChart/BarPlot.d.ts +14 -1
  6. package/BarChart/BarPlot.js +23 -4
  7. package/BarChart/formatter.js +23 -12
  8. package/CHANGELOG.md +154 -0
  9. package/ChartContainer/index.js +3 -0
  10. package/ChartsAxis/ChartsAxis.d.ts +11 -1
  11. package/ChartsAxis/ChartsAxis.js +51 -6
  12. package/ChartsLegend/ChartsLegend.d.ts +25 -2
  13. package/ChartsLegend/ChartsLegend.js +49 -17
  14. package/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
  15. package/ChartsTooltip/ChartsTooltipTable.d.ts +2 -9
  16. package/ChartsXAxis/ChartsXAxis.js +44 -9
  17. package/ChartsYAxis/ChartsYAxis.js +44 -9
  18. package/LineChart/AreaElement.d.ts +22 -0
  19. package/LineChart/AreaElement.js +31 -11
  20. package/LineChart/AreaPlot.d.ts +14 -1
  21. package/LineChart/AreaPlot.js +32 -5
  22. package/LineChart/LineChart.d.ts +20 -2
  23. package/LineChart/LineChart.js +76 -16
  24. package/LineChart/LineElement.d.ts +22 -0
  25. package/LineChart/LineElement.js +31 -10
  26. package/LineChart/LinePlot.d.ts +14 -1
  27. package/LineChart/LinePlot.js +38 -6
  28. package/LineChart/MarkElement.js +1 -1
  29. package/LineChart/MarkPlot.d.ts +24 -1
  30. package/LineChart/MarkPlot.js +30 -6
  31. package/LineChart/formatter.js +23 -12
  32. package/PieChart/PieArcLabel.js +0 -1
  33. package/PieChart/PieChart.d.ts +14 -2
  34. package/PieChart/PieChart.js +60 -13
  35. package/PieChart/PiePlot.d.ts +27 -1
  36. package/PieChart/PiePlot.js +29 -6
  37. package/ScatterChart/ScatterChart.d.ts +18 -2
  38. package/ScatterChart/ScatterChart.js +64 -13
  39. package/ScatterChart/ScatterPlot.d.ts +24 -1
  40. package/ScatterChart/ScatterPlot.js +28 -4
  41. package/SparkLineChart/SparkLineChart.d.ts +73 -0
  42. package/SparkLineChart/SparkLineChart.js +218 -0
  43. package/SparkLineChart/index.d.ts +1 -0
  44. package/SparkLineChart/index.js +12 -0
  45. package/SparkLineChart/package.json +6 -0
  46. package/colorPalettes/colorPalettes.js +2 -2
  47. package/context/CartesianContextProvider.d.ts +3 -1
  48. package/context/CartesianContextProvider.js +50 -14
  49. package/context/SeriesContextProvider.d.ts +3 -2
  50. package/context/SeriesContextProvider.js +5 -3
  51. package/esm/BarChart/BarChart.js +77 -17
  52. package/esm/BarChart/BarElement.js +21 -11
  53. package/esm/BarChart/BarPlot.js +23 -4
  54. package/esm/BarChart/formatter.js +23 -12
  55. package/esm/ChartContainer/index.js +3 -0
  56. package/esm/ChartsAxis/ChartsAxis.js +51 -6
  57. package/esm/ChartsLegend/ChartsLegend.js +47 -14
  58. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
  59. package/esm/ChartsXAxis/ChartsXAxis.js +45 -9
  60. package/esm/ChartsYAxis/ChartsYAxis.js +45 -9
  61. package/esm/LineChart/AreaElement.js +31 -11
  62. package/esm/LineChart/AreaPlot.js +33 -5
  63. package/esm/LineChart/LineChart.js +79 -16
  64. package/esm/LineChart/LineElement.js +31 -11
  65. package/esm/LineChart/LinePlot.js +45 -9
  66. package/esm/LineChart/MarkElement.js +1 -1
  67. package/esm/LineChart/MarkPlot.js +31 -6
  68. package/esm/LineChart/formatter.js +23 -13
  69. package/esm/PieChart/PieArcLabel.js +0 -1
  70. package/esm/PieChart/PieChart.js +60 -13
  71. package/esm/PieChart/PiePlot.js +31 -6
  72. package/esm/ScatterChart/ScatterChart.js +64 -13
  73. package/esm/ScatterChart/ScatterPlot.js +29 -4
  74. package/esm/SparkLineChart/SparkLineChart.js +210 -0
  75. package/esm/SparkLineChart/index.js +1 -0
  76. package/esm/colorPalettes/colorPalettes.js +2 -2
  77. package/esm/context/CartesianContextProvider.js +50 -14
  78. package/esm/context/SeriesContextProvider.js +5 -3
  79. package/esm/hooks/useTicks.js +9 -6
  80. package/esm/index.js +1 -0
  81. package/esm/internals/components/AxisSharedComponents.js +10 -10
  82. package/esm/models/index.js +3 -1
  83. package/hooks/useTicks.d.ts +20 -5
  84. package/hooks/useTicks.js +9 -6
  85. package/index.d.ts +1 -0
  86. package/index.js +12 -1
  87. package/internals/components/AxisSharedComponents.d.ts +4 -4
  88. package/internals/components/AxisSharedComponents.js +15 -15
  89. package/internals/defaultizeColor.d.ts +4 -2
  90. package/legacy/BarChart/BarChart.js +75 -17
  91. package/legacy/BarChart/BarElement.js +20 -10
  92. package/legacy/BarChart/BarPlot.js +23 -4
  93. package/legacy/BarChart/formatter.js +23 -10
  94. package/legacy/ChartContainer/index.js +3 -0
  95. package/legacy/ChartsAxis/ChartsAxis.js +51 -6
  96. package/legacy/ChartsLegend/ChartsLegend.js +46 -15
  97. package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
  98. package/legacy/ChartsXAxis/ChartsXAxis.js +45 -9
  99. package/legacy/ChartsYAxis/ChartsYAxis.js +45 -9
  100. package/legacy/LineChart/AreaElement.js +30 -10
  101. package/legacy/LineChart/AreaPlot.js +31 -5
  102. package/legacy/LineChart/LineChart.js +77 -16
  103. package/legacy/LineChart/LineElement.js +30 -10
  104. package/legacy/LineChart/LinePlot.js +38 -6
  105. package/legacy/LineChart/MarkElement.js +1 -1
  106. package/legacy/LineChart/MarkPlot.js +29 -6
  107. package/legacy/LineChart/formatter.js +23 -11
  108. package/legacy/PieChart/PieArcLabel.js +0 -1
  109. package/legacy/PieChart/PieChart.js +60 -13
  110. package/legacy/PieChart/PiePlot.js +29 -6
  111. package/legacy/ScatterChart/ScatterChart.js +64 -13
  112. package/legacy/ScatterChart/ScatterPlot.js +27 -4
  113. package/legacy/SparkLineChart/SparkLineChart.js +214 -0
  114. package/legacy/SparkLineChart/index.js +1 -0
  115. package/legacy/colorPalettes/colorPalettes.js +2 -2
  116. package/legacy/context/CartesianContextProvider.js +59 -15
  117. package/legacy/context/SeriesContextProvider.js +6 -4
  118. package/legacy/hooks/useTicks.js +9 -9
  119. package/legacy/index.js +2 -1
  120. package/legacy/internals/components/AxisSharedComponents.js +10 -10
  121. package/legacy/models/index.js +3 -1
  122. package/models/axis.d.ts +34 -3
  123. package/models/index.d.ts +2 -0
  124. package/models/index.js +11 -0
  125. package/models/seriesType/bar.d.ts +8 -1
  126. package/models/seriesType/common.d.ts +2 -2
  127. package/models/seriesType/config.d.ts +4 -1
  128. package/models/seriesType/line.d.ts +8 -1
  129. package/modern/BarChart/BarChart.js +74 -17
  130. package/modern/BarChart/BarElement.js +20 -11
  131. package/modern/BarChart/BarPlot.js +23 -4
  132. package/modern/BarChart/formatter.js +23 -12
  133. package/modern/ChartContainer/index.js +3 -0
  134. package/modern/ChartsAxis/ChartsAxis.js +51 -6
  135. package/modern/ChartsLegend/ChartsLegend.js +46 -14
  136. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
  137. package/modern/ChartsXAxis/ChartsXAxis.js +44 -9
  138. package/modern/ChartsYAxis/ChartsYAxis.js +44 -9
  139. package/modern/LineChart/AreaElement.js +30 -11
  140. package/modern/LineChart/AreaPlot.js +33 -5
  141. package/modern/LineChart/LineChart.js +76 -16
  142. package/modern/LineChart/LineElement.js +30 -11
  143. package/modern/LineChart/LinePlot.js +39 -6
  144. package/modern/LineChart/MarkElement.js +1 -1
  145. package/modern/LineChart/MarkPlot.js +30 -6
  146. package/modern/LineChart/formatter.js +23 -13
  147. package/modern/PieChart/PieArcLabel.js +0 -1
  148. package/modern/PieChart/PieChart.js +60 -13
  149. package/modern/PieChart/PiePlot.js +30 -6
  150. package/modern/ScatterChart/ScatterChart.js +64 -13
  151. package/modern/ScatterChart/ScatterPlot.js +28 -4
  152. package/modern/SparkLineChart/SparkLineChart.js +210 -0
  153. package/modern/SparkLineChart/index.js +1 -0
  154. package/modern/colorPalettes/colorPalettes.js +2 -2
  155. package/modern/context/CartesianContextProvider.js +50 -14
  156. package/modern/context/SeriesContextProvider.js +5 -3
  157. package/modern/hooks/useTicks.js +9 -6
  158. package/modern/index.js +2 -1
  159. package/modern/internals/components/AxisSharedComponents.js +10 -10
  160. package/modern/models/index.js +3 -1
  161. package/package.json +4 -2
  162. package/themeAugmentation/components.d.ts +0 -10
  163. package/themeAugmentation/overrides.d.ts +0 -2
@@ -21,6 +21,7 @@ const BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
21
21
  height,
22
22
  margin,
23
23
  colors,
24
+ dataset,
24
25
  sx,
25
26
  tooltip,
26
27
  axisHighlight,
@@ -29,7 +30,9 @@ const BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
29
30
  leftAxis,
30
31
  rightAxis,
31
32
  bottomAxis,
32
- children
33
+ children,
34
+ slots,
35
+ slotProps
33
36
  } = props;
34
37
  const id = useId();
35
38
  const clipPathId = `${id}-clip-path`;
@@ -45,24 +48,36 @@ const BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
45
48
  id: DEFAULT_X_AXIS_KEY,
46
49
  scaleType: 'band',
47
50
  data: Array.from({
48
- length: Math.max(...series.map(s => s.data.length))
51
+ length: Math.max(...series.map(s => (s.data ?? dataset ?? []).length))
49
52
  }, (_, index) => index)
50
53
  }],
51
54
  yAxis: yAxis,
52
55
  colors: colors,
56
+ dataset: dataset,
53
57
  sx: sx,
54
58
  disableAxisListener: tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none',
55
59
  children: [/*#__PURE__*/_jsx("g", {
56
60
  clipPath: `url(#${clipPathId})`,
57
- children: /*#__PURE__*/_jsx(BarPlot, {})
61
+ children: /*#__PURE__*/_jsx(BarPlot, {
62
+ slots: slots,
63
+ slotProps: slotProps
64
+ })
58
65
  }), /*#__PURE__*/_jsx(ChartsAxis, {
59
66
  topAxis: topAxis,
60
67
  leftAxis: leftAxis,
61
68
  rightAxis: rightAxis,
62
- bottomAxis: bottomAxis
63
- }), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend)), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({
69
+ bottomAxis: bottomAxis,
70
+ slots: slots,
71
+ slotProps: slotProps
72
+ }), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend, {
73
+ slots: slots,
74
+ slotProps: slotProps
75
+ })), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({
64
76
  x: "band"
65
- }, axisHighlight)), /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip)), /*#__PURE__*/_jsx(ChartsClipPath, {
77
+ }, axisHighlight)), /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip, {
78
+ slots: slots,
79
+ slotProps: slotProps
80
+ })), /*#__PURE__*/_jsx(ChartsClipPath, {
66
81
  id: clipPathId
67
82
  }), children]
68
83
  });
@@ -90,8 +105,13 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
90
105
  label: PropTypes.string,
91
106
  labelFontSize: PropTypes.number,
92
107
  position: PropTypes.oneOf(['bottom', 'top']),
108
+ slotProps: PropTypes.object,
109
+ slots: PropTypes.object,
93
110
  stroke: PropTypes.string,
94
111
  tickFontSize: PropTypes.number,
112
+ tickMaxStep: PropTypes.number,
113
+ tickMinStep: PropTypes.number,
114
+ tickNumber: PropTypes.number,
95
115
  tickSize: PropTypes.number
96
116
  }), PropTypes.string]),
97
117
  children: PropTypes.node,
@@ -100,6 +120,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
100
120
  * Color palette used to colorize multiple series.
101
121
  */
102
122
  colors: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.func]),
123
+ dataset: PropTypes.arrayOf(PropTypes.object),
103
124
  desc: PropTypes.string,
104
125
  disableAxisListener: PropTypes.bool,
105
126
  height: PropTypes.number,
@@ -117,8 +138,13 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
117
138
  label: PropTypes.string,
118
139
  labelFontSize: PropTypes.number,
119
140
  position: PropTypes.oneOf(['left', 'right']),
141
+ slotProps: PropTypes.object,
142
+ slots: PropTypes.object,
120
143
  stroke: PropTypes.string,
121
144
  tickFontSize: PropTypes.number,
145
+ tickMaxStep: PropTypes.number,
146
+ tickMinStep: PropTypes.number,
147
+ tickNumber: PropTypes.number,
122
148
  tickSize: PropTypes.number
123
149
  }), PropTypes.string]),
124
150
  legend: PropTypes.shape({
@@ -135,6 +161,8 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
135
161
  horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
136
162
  vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
137
163
  }),
164
+ slotProps: PropTypes.object,
165
+ slots: PropTypes.object,
138
166
  spacing: PropTypes.number
139
167
  }),
140
168
  margin: PropTypes.shape({
@@ -157,13 +185,19 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
157
185
  label: PropTypes.string,
158
186
  labelFontSize: PropTypes.number,
159
187
  position: PropTypes.oneOf(['left', 'right']),
188
+ slotProps: PropTypes.object,
189
+ slots: PropTypes.object,
160
190
  stroke: PropTypes.string,
161
191
  tickFontSize: PropTypes.number,
192
+ tickMaxStep: PropTypes.number,
193
+ tickMinStep: PropTypes.number,
194
+ tickNumber: PropTypes.number,
162
195
  tickSize: PropTypes.number
163
196
  }), PropTypes.string]),
164
197
  series: PropTypes.arrayOf(PropTypes.shape({
165
198
  color: PropTypes.string,
166
- data: PropTypes.arrayOf(PropTypes.number).isRequired,
199
+ data: PropTypes.arrayOf(PropTypes.number),
200
+ dataKey: PropTypes.string,
167
201
  highlightScope: PropTypes.shape({
168
202
  faded: PropTypes.oneOf(['global', 'none', 'series']),
169
203
  highlighted: PropTypes.oneOf(['item', 'none', 'series'])
@@ -178,6 +212,16 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
178
212
  xAxisKey: PropTypes.string,
179
213
  yAxisKey: PropTypes.string
180
214
  })).isRequired,
215
+ /**
216
+ * The props used for each component slot.
217
+ * @default {}
218
+ */
219
+ slotProps: PropTypes.object,
220
+ /**
221
+ * Overridable component slots.
222
+ * @default {}
223
+ */
224
+ slots: PropTypes.object,
181
225
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
182
226
  title: PropTypes.string,
183
227
  tooltip: PropTypes.shape({
@@ -200,8 +244,13 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
200
244
  label: PropTypes.string,
201
245
  labelFontSize: PropTypes.number,
202
246
  position: PropTypes.oneOf(['bottom', 'top']),
247
+ slotProps: PropTypes.object,
248
+ slots: PropTypes.object,
203
249
  stroke: PropTypes.string,
204
250
  tickFontSize: PropTypes.number,
251
+ tickMaxStep: PropTypes.number,
252
+ tickMinStep: PropTypes.number,
253
+ tickNumber: PropTypes.number,
205
254
  tickSize: PropTypes.number
206
255
  }), PropTypes.string]),
207
256
  viewBox: PropTypes.shape({
@@ -215,44 +264,52 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
215
264
  axisId: PropTypes.string,
216
265
  classes: PropTypes.object,
217
266
  data: PropTypes.array,
267
+ dataKey: PropTypes.string,
218
268
  disableLine: PropTypes.bool,
219
269
  disableTicks: PropTypes.bool,
220
270
  fill: PropTypes.string,
271
+ hideTooltip: PropTypes.bool,
221
272
  id: PropTypes.string,
222
273
  label: PropTypes.string,
223
274
  labelFontSize: PropTypes.number,
224
- max: PropTypes.number,
225
- maxTicks: PropTypes.number,
226
- min: PropTypes.number,
227
- minTicks: PropTypes.number,
275
+ max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
276
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
228
277
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
229
278
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
279
+ slotProps: PropTypes.object,
280
+ slots: PropTypes.object,
230
281
  stroke: PropTypes.string,
231
282
  tickFontSize: PropTypes.number,
283
+ tickMaxStep: PropTypes.number,
284
+ tickMinStep: PropTypes.number,
285
+ tickNumber: PropTypes.number,
232
286
  tickSize: PropTypes.number,
233
- tickSpacing: PropTypes.number,
234
287
  valueFormatter: PropTypes.func
235
288
  })),
236
289
  yAxis: PropTypes.arrayOf(PropTypes.shape({
237
290
  axisId: PropTypes.string,
238
291
  classes: PropTypes.object,
239
292
  data: PropTypes.array,
293
+ dataKey: PropTypes.string,
240
294
  disableLine: PropTypes.bool,
241
295
  disableTicks: PropTypes.bool,
242
296
  fill: PropTypes.string,
297
+ hideTooltip: PropTypes.bool,
243
298
  id: PropTypes.string,
244
299
  label: PropTypes.string,
245
300
  labelFontSize: PropTypes.number,
246
- max: PropTypes.number,
247
- maxTicks: PropTypes.number,
248
- min: PropTypes.number,
249
- minTicks: PropTypes.number,
301
+ max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
302
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
250
303
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
251
304
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
305
+ slotProps: PropTypes.object,
306
+ slots: PropTypes.object,
252
307
  stroke: PropTypes.string,
253
308
  tickFontSize: PropTypes.number,
309
+ tickMaxStep: PropTypes.number,
310
+ tickMinStep: PropTypes.number,
311
+ tickNumber: PropTypes.number,
254
312
  tickSize: PropTypes.number,
255
- tickSpacing: PropTypes.number,
256
313
  valueFormatter: PropTypes.func
257
314
  }))
258
315
  } : void 0;
@@ -1,8 +1,9 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["id", "dataIndex", "classes", "color", "highlightScope"];
3
+ const _excluded = ["id", "dataIndex", "classes", "color", "highlightScope", "slots", "slotProps"];
4
4
  import * as React from 'react';
5
5
  import composeClasses from '@mui/utils/composeClasses';
6
+ import { useSlotProps } from '@mui/base/utils';
6
7
  import generateUtilityClass from '@mui/utils/generateUtilityClass';
7
8
  import { styled } from '@mui/material/styles';
8
9
  import { color as d3Color } from 'd3-color';
@@ -24,7 +25,7 @@ const useUtilityClasses = ownerState => {
24
25
  };
25
26
  return composeClasses(slots, getBarElementUtilityClass, classes);
26
27
  };
27
- const BarElementPath = styled('rect', {
28
+ export const BarElementPath = styled('rect', {
28
29
  name: 'MuiBarElement',
29
30
  slot: 'Root',
30
31
  overridesResolver: (_, styles) => styles.root
@@ -43,7 +44,9 @@ export function BarElement(props) {
43
44
  dataIndex,
44
45
  classes: innerClasses,
45
46
  color,
46
- highlightScope
47
+ highlightScope,
48
+ slots,
49
+ slotProps
47
50
  } = props,
48
51
  other = _objectWithoutPropertiesLoose(props, _excluded);
49
52
  const getInteractionItemProps = useInteractionItemProps(highlightScope);
@@ -69,12 +72,18 @@ export function BarElement(props) {
69
72
  isHighlighted
70
73
  };
71
74
  const classes = useUtilityClasses(ownerState);
72
- return /*#__PURE__*/_jsx(BarElementPath, _extends({}, other, {
73
- ownerState: ownerState,
74
- className: classes.root
75
- }, getInteractionItemProps({
76
- type: 'bar',
77
- seriesId: id,
78
- dataIndex
79
- })));
75
+ const Bar = slots?.bar ?? BarElementPath;
76
+ const barProps = useSlotProps({
77
+ elementType: Bar,
78
+ externalSlotProps: slotProps?.bar,
79
+ additionalProps: _extends({}, other, getInteractionItemProps({
80
+ type: 'bar',
81
+ seriesId: id,
82
+ dataIndex
83
+ }), {
84
+ className: classes.root
85
+ }),
86
+ ownerState
87
+ });
88
+ return /*#__PURE__*/_jsx(Bar, _extends({}, barProps));
80
89
  }
@@ -1,4 +1,6 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
1
2
  import * as React from 'react';
3
+ import PropTypes from 'prop-types';
2
4
  import { SeriesContext } from '../context/SeriesContextProvider';
3
5
  import { CartesianContext } from '../context/CartesianContextProvider';
4
6
  import { BarElement } from './BarElement';
@@ -32,7 +34,7 @@ function getBandSize({
32
34
  offset
33
35
  };
34
36
  }
35
- export function BarPlot() {
37
+ function BarPlot(props) {
36
38
  const seriesData = React.useContext(SeriesContext).bar;
37
39
  const axisData = React.useContext(CartesianContext);
38
40
  if (seriesData === undefined) {
@@ -87,7 +89,7 @@ export function BarPlot() {
87
89
  return stackedData.map((values, dataIndex) => {
88
90
  const baseline = Math.min(...values);
89
91
  const value = Math.max(...values);
90
- return /*#__PURE__*/_jsx(BarElement, {
92
+ return /*#__PURE__*/_jsx(BarElement, _extends({
91
93
  id: seriesId,
92
94
  dataIndex: dataIndex,
93
95
  x: xScale(xAxis[xAxisKey].data?.[dataIndex]) + groupIndex * (barWidth + offset),
@@ -96,9 +98,26 @@ export function BarPlot() {
96
98
  width: barWidth,
97
99
  color: color,
98
100
  highlightScope: series[seriesId].highlightScope
99
- }, `${seriesId}-${dataIndex}`);
101
+ }, props), `${seriesId}-${dataIndex}`);
100
102
  });
101
103
  });
102
104
  })
103
105
  });
104
- }
106
+ }
107
+ process.env.NODE_ENV !== "production" ? BarPlot.propTypes = {
108
+ // ----------------------------- Warning --------------------------------
109
+ // | These PropTypes are generated from the TypeScript type definitions |
110
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
111
+ // ----------------------------------------------------------------------
112
+ /**
113
+ * The props used for each component slot.
114
+ * @default {}
115
+ */
116
+ slotProps: PropTypes.object,
117
+ /**
118
+ * Overridable component slots.
119
+ * @default {}
120
+ */
121
+ slots: PropTypes.object
122
+ } : void 0;
123
+ export { BarPlot };
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import { stack as d3Stack } from 'd3-shape';
3
3
  import { getStackingGroups } from '../internals/stackSeries';
4
4
  import defaultizeValueFormatter from '../internals/defaultizeValueFormatter';
5
- const formatter = params => {
5
+ const formatter = (params, dataset) => {
6
6
  const {
7
7
  seriesOrder,
8
8
  series
@@ -10,17 +10,22 @@ const formatter = params => {
10
10
  const stackingGroups = getStackingGroups(params);
11
11
 
12
12
  // Create a data set with format adapted to d3
13
- const d3Dataset = [];
13
+ const d3Dataset = dataset ?? [];
14
14
  seriesOrder.forEach(id => {
15
- series[id].data.forEach((value, index) => {
16
- if (d3Dataset.length <= index) {
17
- d3Dataset.push({
18
- [id]: value
19
- });
20
- } else {
21
- d3Dataset[index][id] = value;
22
- }
23
- });
15
+ const data = series[id].data;
16
+ if (data !== undefined) {
17
+ data.forEach((value, index) => {
18
+ if (d3Dataset.length <= index) {
19
+ d3Dataset.push({
20
+ [id]: value
21
+ });
22
+ } else {
23
+ d3Dataset[index][id] = value;
24
+ }
25
+ });
26
+ } else if (dataset === undefined) {
27
+ throw new Error([`MUI: bar series with id='${id}' has no data.`, 'Either provide a data property to the series or use the dataset prop.'].join('\n'));
28
+ }
24
29
  });
25
30
  const completedSeries = {};
26
31
  stackingGroups.forEach(stackingGroup => {
@@ -30,9 +35,15 @@ const formatter = params => {
30
35
  stackingOrder
31
36
  } = stackingGroup;
32
37
  // Get stacked values, and derive the domain
33
- const stackedSeries = d3Stack().keys(ids).order(stackingOrder).offset(stackingOffset)(d3Dataset);
38
+ const stackedSeries = d3Stack().keys(ids.map(id => {
39
+ // Use dataKey if needed and available
40
+ const dataKey = series[id].dataKey;
41
+ return series[id].data === undefined && dataKey !== undefined ? dataKey : id;
42
+ })).order(stackingOrder).offset(stackingOffset)(d3Dataset);
34
43
  ids.forEach((id, index) => {
44
+ const dataKey = series[id].dataKey;
35
45
  completedSeries[id] = _extends({}, series[id], {
46
+ data: dataKey ? dataset.map(d => d[dataKey]) : series[id].data,
36
47
  stackedData: stackedSeries[index].map(([a, b]) => [a, b])
37
48
  });
38
49
  });
@@ -16,6 +16,7 @@ export const ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContai
16
16
  xAxis,
17
17
  yAxis,
18
18
  colors,
19
+ dataset,
19
20
  sx,
20
21
  title,
21
22
  desc,
@@ -32,9 +33,11 @@ export const ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContai
32
33
  children: /*#__PURE__*/_jsx(SeriesContextProvider, {
33
34
  series: series,
34
35
  colors: colors,
36
+ dataset: dataset,
35
37
  children: /*#__PURE__*/_jsx(CartesianContextProvider, {
36
38
  xAxis: xAxis,
37
39
  yAxis: yAxis,
40
+ dataset: dataset,
38
41
  children: /*#__PURE__*/_jsx(InteractionProvider, {
39
42
  children: /*#__PURE__*/_jsx(HighlightProvider, {
40
43
  children: /*#__PURE__*/_jsx(ChartsSurface, {
@@ -15,12 +15,23 @@ const getAxisId = propsValue => {
15
15
  }
16
16
  return propsValue;
17
17
  };
18
+ const mergeProps = (axisConfig, slots, slotProps) => {
19
+ return typeof axisConfig === 'object' ? _extends({}, axisConfig, {
20
+ slots: _extends({}, slots, axisConfig?.slots),
21
+ slotProps: _extends({}, slotProps, axisConfig?.slotProps)
22
+ }) : {
23
+ slots,
24
+ slotProps
25
+ };
26
+ };
18
27
  function ChartsAxis(props) {
19
28
  const {
20
29
  topAxis,
21
30
  leftAxis,
22
31
  rightAxis,
23
- bottomAxis
32
+ bottomAxis,
33
+ slots,
34
+ slotProps
24
35
  } = props;
25
36
  const {
26
37
  xAxis,
@@ -48,20 +59,24 @@ function ChartsAxis(props) {
48
59
  if (bottomId !== null && !xAxis[bottomId]) {
49
60
  throw Error(`MUI: id used for bottom axis "${bottomId}" is not defined`);
50
61
  }
62
+ const topAxisProps = mergeProps(topAxis, slots, slotProps);
63
+ const bottomAxisProps = mergeProps(bottomAxis, slots, slotProps);
64
+ const leftAxisProps = mergeProps(leftAxis, slots, slotProps);
65
+ const rightAxisProps = mergeProps(rightAxis, slots, slotProps);
51
66
  return /*#__PURE__*/_jsxs(React.Fragment, {
52
- children: [topId && /*#__PURE__*/_jsx(ChartsXAxis, _extends({
67
+ children: [topId && /*#__PURE__*/_jsx(ChartsXAxis, _extends({}, topAxisProps, {
53
68
  position: "top",
54
69
  axisId: topId
55
- }, typeof topAxis === 'object' ? topAxis : {})), bottomId && /*#__PURE__*/_jsx(ChartsXAxis, _extends({
70
+ })), bottomId && /*#__PURE__*/_jsx(ChartsXAxis, _extends({}, bottomAxisProps, {
56
71
  position: "bottom",
57
72
  axisId: bottomId
58
- }, typeof bottomAxis === 'object' ? bottomAxis : {})), leftId && /*#__PURE__*/_jsx(ChartsYAxis, _extends({
73
+ })), leftId && /*#__PURE__*/_jsx(ChartsYAxis, _extends({}, leftAxisProps, {
59
74
  position: "left",
60
75
  axisId: leftId
61
- }, typeof leftAxis === 'object' ? leftAxis : {})), rightId && /*#__PURE__*/_jsx(ChartsYAxis, _extends({
76
+ })), rightId && /*#__PURE__*/_jsx(ChartsYAxis, _extends({}, rightAxisProps, {
62
77
  position: "right",
63
78
  axisId: rightId
64
- }, typeof rightAxis === 'object' ? rightAxis : {}))]
79
+ }))]
65
80
  });
66
81
  }
67
82
  process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
@@ -83,8 +98,13 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
83
98
  label: PropTypes.string,
84
99
  labelFontSize: PropTypes.number,
85
100
  position: PropTypes.oneOf(['bottom', 'top']),
101
+ slotProps: PropTypes.object,
102
+ slots: PropTypes.object,
86
103
  stroke: PropTypes.string,
87
104
  tickFontSize: PropTypes.number,
105
+ tickMaxStep: PropTypes.number,
106
+ tickMinStep: PropTypes.number,
107
+ tickNumber: PropTypes.number,
88
108
  tickSize: PropTypes.number
89
109
  }), PropTypes.string]),
90
110
  /**
@@ -101,8 +121,13 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
101
121
  label: PropTypes.string,
102
122
  labelFontSize: PropTypes.number,
103
123
  position: PropTypes.oneOf(['left', 'right']),
124
+ slotProps: PropTypes.object,
125
+ slots: PropTypes.object,
104
126
  stroke: PropTypes.string,
105
127
  tickFontSize: PropTypes.number,
128
+ tickMaxStep: PropTypes.number,
129
+ tickMinStep: PropTypes.number,
130
+ tickNumber: PropTypes.number,
106
131
  tickSize: PropTypes.number
107
132
  }), PropTypes.string]),
108
133
  /**
@@ -119,10 +144,25 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
119
144
  label: PropTypes.string,
120
145
  labelFontSize: PropTypes.number,
121
146
  position: PropTypes.oneOf(['left', 'right']),
147
+ slotProps: PropTypes.object,
148
+ slots: PropTypes.object,
122
149
  stroke: PropTypes.string,
123
150
  tickFontSize: PropTypes.number,
151
+ tickMaxStep: PropTypes.number,
152
+ tickMinStep: PropTypes.number,
153
+ tickNumber: PropTypes.number,
124
154
  tickSize: PropTypes.number
125
155
  }), PropTypes.string]),
156
+ /**
157
+ * The props used for each component slot.
158
+ * @default {}
159
+ */
160
+ slotProps: PropTypes.object,
161
+ /**
162
+ * Overridable component slots.
163
+ * @default {}
164
+ */
165
+ slots: PropTypes.object,
126
166
  /**
127
167
  * Indicate which axis to display the top of the charts.
128
168
  * Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
@@ -137,8 +177,13 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
137
177
  label: PropTypes.string,
138
178
  labelFontSize: PropTypes.number,
139
179
  position: PropTypes.oneOf(['bottom', 'top']),
180
+ slotProps: PropTypes.object,
181
+ slots: PropTypes.object,
140
182
  stroke: PropTypes.string,
141
183
  tickFontSize: PropTypes.number,
184
+ tickMaxStep: PropTypes.number,
185
+ tickMinStep: PropTypes.number,
186
+ tickNumber: PropTypes.number,
142
187
  tickSize: PropTypes.number
143
188
  }), PropTypes.string])
144
189
  } : void 0;
@@ -1,5 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
+ import { useSlotProps } from '@mui/base/utils';
3
4
  import { unstable_composeClasses as composeClasses } from '@mui/utils';
4
5
  import { useThemeProps, useTheme, styled } from '@mui/material/styles';
5
6
  import { DrawingContext } from '../context/DrawingProvider';
@@ -126,7 +127,7 @@ export const ChartsLegendLabel = styled('text', {
126
127
  calc(0.5 * var(--ChartsLegend-itemMarkSize))
127
128
  )`,
128
129
  fill: theme.palette.text.primary,
129
- alignmentBaseline: 'central'
130
+ dominantBaseline: 'central'
130
131
  }));
131
132
  const defaultProps = {
132
133
  position: {
@@ -138,27 +139,20 @@ const defaultProps = {
138
139
  itemWidth: 100,
139
140
  spacing: 2
140
141
  };
141
- export function ChartsLegend(inProps) {
142
- const props = useThemeProps({
143
- props: _extends({}, defaultProps, inProps),
144
- name: 'MuiChartsLegend'
145
- });
142
+ function DefaultChartsLegend(props) {
146
143
  const {
144
+ hidden,
147
145
  position,
148
146
  direction,
149
147
  offset,
150
- hidden
148
+ series,
149
+ seriesToDisplay,
150
+ drawingArea,
151
+ classes
151
152
  } = props;
152
- const theme = useTheme();
153
- const classes = useUtilityClasses(_extends({}, props, {
154
- theme
155
- }));
156
- const drawingArea = React.useContext(DrawingContext);
157
- const series = React.useContext(SeriesContext);
158
153
  if (hidden) {
159
154
  return null;
160
155
  }
161
- const seriesToDisplay = getSeriesToDisplay(series);
162
156
  return /*#__PURE__*/_jsx(ChartsLegendRoot, {
163
157
  ownerState: {
164
158
  direction,
@@ -190,4 +184,42 @@ export function ChartsLegend(inProps) {
190
184
  })]
191
185
  }, id))
192
186
  });
187
+ }
188
+ export function ChartsLegend(inProps) {
189
+ const props = useThemeProps({
190
+ props: _extends({}, defaultProps, inProps),
191
+ name: 'MuiChartsLegend'
192
+ });
193
+ const {
194
+ position,
195
+ direction,
196
+ offset,
197
+ hidden,
198
+ slots,
199
+ slotProps
200
+ } = props;
201
+ const theme = useTheme();
202
+ const classes = useUtilityClasses(_extends({}, props, {
203
+ theme
204
+ }));
205
+ const drawingArea = React.useContext(DrawingContext);
206
+ const series = React.useContext(SeriesContext);
207
+ const seriesToDisplay = getSeriesToDisplay(series);
208
+ const ChartLegendRender = slots?.legend ?? DefaultChartsLegend;
209
+ const chartLegendRenderProps = useSlotProps({
210
+ elementType: ChartLegendRender,
211
+ externalSlotProps: slotProps?.legend,
212
+ additionalProps: {
213
+ position,
214
+ direction,
215
+ offset,
216
+ classes,
217
+ drawingArea,
218
+ series,
219
+ hidden,
220
+ seriesToDisplay
221
+ },
222
+ ownerState: {}
223
+ });
224
+ return /*#__PURE__*/_jsx(ChartLegendRender, _extends({}, chartLegendRenderProps));
193
225
  }
@@ -23,7 +23,7 @@ export function DefaultChartsAxisContent(props) {
23
23
  variant: "outlined",
24
24
  className: classes.root,
25
25
  children: /*#__PURE__*/_jsxs(ChartsTooltipTable, {
26
- children: [axisValue != null && /*#__PURE__*/_jsx("thead", {
26
+ children: [axisValue != null && !axis.hideTooltip && /*#__PURE__*/_jsx("thead", {
27
27
  children: /*#__PURE__*/_jsx(ChartsTooltipRow, {
28
28
  children: /*#__PURE__*/_jsx(ChartsTooltipCell, {
29
29
  colSpan: 3,