@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
@@ -23,6 +23,7 @@ var LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
23
23
  height = props.height,
24
24
  margin = props.margin,
25
25
  colors = props.colors,
26
+ dataset = props.dataset,
26
27
  sx = props.sx,
27
28
  tooltip = props.tooltip,
28
29
  _props$axisHighlight = props.axisHighlight,
@@ -34,7 +35,9 @@ var LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
34
35
  leftAxis = props.leftAxis,
35
36
  rightAxis = props.rightAxis,
36
37
  bottomAxis = props.bottomAxis,
37
- children = props.children;
38
+ children = props.children,
39
+ slots = props.slots,
40
+ slotProps = props.slotProps;
38
41
  var id = useId();
39
42
  var clipPathId = "".concat(id, "-clip-path");
40
43
  return /*#__PURE__*/_jsxs(ResponsiveChartContainer, {
@@ -52,7 +55,8 @@ var LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
52
55
  scaleType: 'point',
53
56
  data: Array.from({
54
57
  length: Math.max.apply(Math, _toConsumableArray(series.map(function (s) {
55
- return s.data.length;
58
+ var _ref, _s$data;
59
+ return ((_ref = (_s$data = s.data) != null ? _s$data : dataset) != null ? _ref : []).length;
56
60
  })))
57
61
  }, function (_, index) {
58
62
  return index;
@@ -60,17 +64,32 @@ var LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
60
64
  }],
61
65
  yAxis: yAxis,
62
66
  colors: colors,
67
+ dataset: dataset,
63
68
  sx: sx,
64
69
  disableAxisListener: (tooltip == null ? void 0 : tooltip.trigger) !== 'axis' && (axisHighlight == null ? void 0 : axisHighlight.x) === 'none' && (axisHighlight == null ? void 0 : axisHighlight.y) === 'none',
65
70
  children: [/*#__PURE__*/_jsxs("g", {
66
71
  clipPath: "url(#".concat(clipPathId, ")"),
67
- children: [/*#__PURE__*/_jsx(AreaPlot, {}), /*#__PURE__*/_jsx(LinePlot, {})]
72
+ children: [/*#__PURE__*/_jsx(AreaPlot, {
73
+ slots: slots,
74
+ slotProps: slotProps
75
+ }), /*#__PURE__*/_jsx(LinePlot, {
76
+ slots: slots,
77
+ slotProps: slotProps
78
+ })]
68
79
  }), /*#__PURE__*/_jsx(ChartsAxis, {
69
80
  topAxis: topAxis,
70
81
  leftAxis: leftAxis,
71
82
  rightAxis: rightAxis,
72
- bottomAxis: bottomAxis
73
- }), /*#__PURE__*/_jsx(MarkPlot, {}), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend)), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlight)), /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip)), /*#__PURE__*/_jsx(ChartsClipPath, {
83
+ bottomAxis: bottomAxis,
84
+ slots: slots,
85
+ slotProps: slotProps
86
+ }), /*#__PURE__*/_jsx(MarkPlot, {
87
+ slots: slots,
88
+ slotProps: slotProps
89
+ }), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend, {
90
+ slots: slots,
91
+ slotProps: slotProps
92
+ })), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlight)), /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip)), /*#__PURE__*/_jsx(ChartsClipPath, {
74
93
  id: clipPathId
75
94
  }), children]
76
95
  });
@@ -98,8 +117,13 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
98
117
  label: PropTypes.string,
99
118
  labelFontSize: PropTypes.number,
100
119
  position: PropTypes.oneOf(['bottom', 'top']),
120
+ slotProps: PropTypes.object,
121
+ slots: PropTypes.object,
101
122
  stroke: PropTypes.string,
102
123
  tickFontSize: PropTypes.number,
124
+ tickMaxStep: PropTypes.number,
125
+ tickMinStep: PropTypes.number,
126
+ tickNumber: PropTypes.number,
103
127
  tickSize: PropTypes.number
104
128
  }), PropTypes.string]),
105
129
  children: PropTypes.node,
@@ -108,6 +132,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
108
132
  * Color palette used to colorize multiple series.
109
133
  */
110
134
  colors: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.func]),
135
+ dataset: PropTypes.arrayOf(PropTypes.object),
111
136
  desc: PropTypes.string,
112
137
  disableAxisListener: PropTypes.bool,
113
138
  height: PropTypes.number,
@@ -125,8 +150,13 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
125
150
  label: PropTypes.string,
126
151
  labelFontSize: PropTypes.number,
127
152
  position: PropTypes.oneOf(['left', 'right']),
153
+ slotProps: PropTypes.object,
154
+ slots: PropTypes.object,
128
155
  stroke: PropTypes.string,
129
156
  tickFontSize: PropTypes.number,
157
+ tickMaxStep: PropTypes.number,
158
+ tickMinStep: PropTypes.number,
159
+ tickNumber: PropTypes.number,
130
160
  tickSize: PropTypes.number
131
161
  }), PropTypes.string]),
132
162
  legend: PropTypes.shape({
@@ -143,6 +173,8 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
143
173
  horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
144
174
  vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
145
175
  }),
176
+ slotProps: PropTypes.object,
177
+ slots: PropTypes.object,
146
178
  spacing: PropTypes.number
147
179
  }),
148
180
  margin: PropTypes.shape({
@@ -165,15 +197,21 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
165
197
  label: PropTypes.string,
166
198
  labelFontSize: PropTypes.number,
167
199
  position: PropTypes.oneOf(['left', 'right']),
200
+ slotProps: PropTypes.object,
201
+ slots: PropTypes.object,
168
202
  stroke: PropTypes.string,
169
203
  tickFontSize: PropTypes.number,
204
+ tickMaxStep: PropTypes.number,
205
+ tickMinStep: PropTypes.number,
206
+ tickNumber: PropTypes.number,
170
207
  tickSize: PropTypes.number
171
208
  }), PropTypes.string]),
172
209
  series: PropTypes.arrayOf(PropTypes.shape({
173
210
  area: PropTypes.bool,
174
211
  color: PropTypes.string,
175
212
  curve: PropTypes.oneOf(['catmullRom', 'linear', 'monotoneX', 'monotoneY', 'natural', 'step', 'stepAfter', 'stepBefore']),
176
- data: PropTypes.arrayOf(PropTypes.number).isRequired,
213
+ data: PropTypes.arrayOf(PropTypes.number),
214
+ dataKey: PropTypes.string,
177
215
  highlightScope: PropTypes.shape({
178
216
  faded: PropTypes.oneOf(['global', 'none', 'series']),
179
217
  highlighted: PropTypes.oneOf(['item', 'none', 'series'])
@@ -188,6 +226,16 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
188
226
  xAxisKey: PropTypes.string,
189
227
  yAxisKey: PropTypes.string
190
228
  })).isRequired,
229
+ /**
230
+ * The props used for each component slot.
231
+ * @default {}
232
+ */
233
+ slotProps: PropTypes.object,
234
+ /**
235
+ * Overridable component slots.
236
+ * @default {}
237
+ */
238
+ slots: PropTypes.object,
191
239
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
192
240
  title: PropTypes.string,
193
241
  tooltip: PropTypes.shape({
@@ -210,8 +258,13 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
210
258
  label: PropTypes.string,
211
259
  labelFontSize: PropTypes.number,
212
260
  position: PropTypes.oneOf(['bottom', 'top']),
261
+ slotProps: PropTypes.object,
262
+ slots: PropTypes.object,
213
263
  stroke: PropTypes.string,
214
264
  tickFontSize: PropTypes.number,
265
+ tickMaxStep: PropTypes.number,
266
+ tickMinStep: PropTypes.number,
267
+ tickNumber: PropTypes.number,
215
268
  tickSize: PropTypes.number
216
269
  }), PropTypes.string]),
217
270
  viewBox: PropTypes.shape({
@@ -225,44 +278,52 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
225
278
  axisId: PropTypes.string,
226
279
  classes: PropTypes.object,
227
280
  data: PropTypes.array,
281
+ dataKey: PropTypes.string,
228
282
  disableLine: PropTypes.bool,
229
283
  disableTicks: PropTypes.bool,
230
284
  fill: PropTypes.string,
285
+ hideTooltip: PropTypes.bool,
231
286
  id: PropTypes.string,
232
287
  label: PropTypes.string,
233
288
  labelFontSize: PropTypes.number,
234
- max: PropTypes.number,
235
- maxTicks: PropTypes.number,
236
- min: PropTypes.number,
237
- minTicks: PropTypes.number,
289
+ max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
290
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
238
291
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
239
292
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
293
+ slotProps: PropTypes.object,
294
+ slots: PropTypes.object,
240
295
  stroke: PropTypes.string,
241
296
  tickFontSize: PropTypes.number,
297
+ tickMaxStep: PropTypes.number,
298
+ tickMinStep: PropTypes.number,
299
+ tickNumber: PropTypes.number,
242
300
  tickSize: PropTypes.number,
243
- tickSpacing: PropTypes.number,
244
301
  valueFormatter: PropTypes.func
245
302
  })),
246
303
  yAxis: PropTypes.arrayOf(PropTypes.shape({
247
304
  axisId: PropTypes.string,
248
305
  classes: PropTypes.object,
249
306
  data: PropTypes.array,
307
+ dataKey: PropTypes.string,
250
308
  disableLine: PropTypes.bool,
251
309
  disableTicks: PropTypes.bool,
252
310
  fill: PropTypes.string,
311
+ hideTooltip: PropTypes.bool,
253
312
  id: PropTypes.string,
254
313
  label: PropTypes.string,
255
314
  labelFontSize: PropTypes.number,
256
- max: PropTypes.number,
257
- maxTicks: PropTypes.number,
258
- min: PropTypes.number,
259
- minTicks: PropTypes.number,
315
+ max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
316
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
260
317
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
261
318
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
319
+ slotProps: PropTypes.object,
320
+ slots: PropTypes.object,
262
321
  stroke: PropTypes.string,
263
322
  tickFontSize: PropTypes.number,
323
+ tickMaxStep: PropTypes.number,
324
+ tickMinStep: PropTypes.number,
325
+ tickNumber: PropTypes.number,
264
326
  tickSize: PropTypes.number,
265
- tickSpacing: PropTypes.number,
266
327
  valueFormatter: PropTypes.func
267
328
  }))
268
329
  } : void 0;
@@ -1,10 +1,11 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
- var _excluded = ["id", "classes", "color", "highlightScope"];
3
+ var _excluded = ["id", "classes", "color", "highlightScope", "slots", "slotProps"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import { color as d3Color } from 'd3-color';
7
7
  import composeClasses from '@mui/utils/composeClasses';
8
+ import { useSlotProps } from '@mui/base/utils';
8
9
  import generateUtilityClass from '@mui/utils/generateUtilityClass';
9
10
  import { styled } from '@mui/material/styles';
10
11
  import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
@@ -25,7 +26,7 @@ var useUtilityClasses = function useUtilityClasses(ownerState) {
25
26
  };
26
27
  return composeClasses(slots, getLineElementUtilityClass, classes);
27
28
  };
28
- var LineElementPath = styled('path', {
29
+ export var LineElementPath = styled('path', {
29
30
  name: 'MuiLineElement',
30
31
  slot: 'Root',
31
32
  overridesResolver: function overridesResolver(_, styles) {
@@ -58,10 +59,13 @@ LineElementPath.propTypes = {
58
59
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
59
60
  };
60
61
  function LineElement(props) {
62
+ var _slots$line;
61
63
  var id = props.id,
62
64
  innerClasses = props.classes,
63
65
  color = props.color,
64
66
  highlightScope = props.highlightScope,
67
+ slots = props.slots,
68
+ slotProps = props.slotProps,
65
69
  other = _objectWithoutProperties(props, _excluded);
66
70
  var getInteractionItemProps = useInteractionItemProps(highlightScope);
67
71
  var _React$useContext = React.useContext(InteractionContext),
@@ -82,13 +86,19 @@ function LineElement(props) {
82
86
  isHighlighted: isHighlighted
83
87
  };
84
88
  var classes = useUtilityClasses(ownerState);
85
- return /*#__PURE__*/_jsx(LineElementPath, _extends({}, other, {
86
- ownerState: ownerState,
87
- className: classes.root
88
- }, getInteractionItemProps({
89
- type: 'line',
90
- seriesId: id
91
- })));
89
+ var Line = (_slots$line = slots == null ? void 0 : slots.line) != null ? _slots$line : LineElementPath;
90
+ var lineProps = useSlotProps({
91
+ elementType: Line,
92
+ externalSlotProps: slotProps == null ? void 0 : slotProps.line,
93
+ additionalProps: _extends({}, other, getInteractionItemProps({
94
+ type: 'line',
95
+ seriesId: id
96
+ }), {
97
+ className: classes.root
98
+ }),
99
+ ownerState: ownerState
100
+ });
101
+ return /*#__PURE__*/_jsx(Line, _extends({}, lineProps));
92
102
  }
93
103
  process.env.NODE_ENV !== "production" ? LineElement.propTypes = {
94
104
  // ----------------------------- Warning --------------------------------
@@ -99,6 +109,16 @@ process.env.NODE_ENV !== "production" ? LineElement.propTypes = {
99
109
  highlightScope: PropTypes.shape({
100
110
  faded: PropTypes.oneOf(['global', 'none', 'series']),
101
111
  highlighted: PropTypes.oneOf(['item', 'none', 'series'])
102
- })
112
+ }),
113
+ /**
114
+ * The props used for each component slot.
115
+ * @default {}
116
+ */
117
+ slotProps: PropTypes.object,
118
+ /**
119
+ * Overridable component slots.
120
+ * @default {}
121
+ */
122
+ slots: PropTypes.object
103
123
  } : void 0;
104
124
  export { LineElement };
@@ -1,4 +1,8 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
+ var _excluded = ["slots", "slotProps"];
1
4
  import * as React from 'react';
5
+ import PropTypes from 'prop-types';
2
6
  import { line as d3Line } from 'd3-shape';
3
7
  import { SeriesContext } from '../context/SeriesContextProvider';
4
8
  import { CartesianContext } from '../context/CartesianContextProvider';
@@ -6,7 +10,10 @@ import { LineElement } from './LineElement';
6
10
  import { getValueToPositionMapper } from '../hooks/useScale';
7
11
  import getCurveFactory from '../internals/getCurve';
8
12
  import { jsx as _jsx } from "react/jsx-runtime";
9
- export function LinePlot() {
13
+ function LinePlot(props) {
14
+ var slots = props.slots,
15
+ slotProps = props.slotProps,
16
+ other = _objectWithoutProperties(props, _excluded);
10
17
  var seriesData = React.useContext(SeriesContext).line;
11
18
  var axisData = React.useContext(CartesianContext);
12
19
  if (seriesData === undefined) {
@@ -20,7 +27,7 @@ export function LinePlot() {
20
27
  yAxisIds = axisData.yAxisIds;
21
28
  var defaultXAxisId = xAxisIds[0];
22
29
  var defaultYAxisId = yAxisIds[0];
23
- return /*#__PURE__*/_jsx("g", {
30
+ return /*#__PURE__*/_jsx("g", _extends({}, other, {
24
31
  children: stackingGroups.flatMap(function (_ref) {
25
32
  var groupIds = _ref.ids;
26
33
  return groupIds.flatMap(function (seriesId) {
@@ -41,20 +48,45 @@ export function LinePlot() {
41
48
  }).y(function (d) {
42
49
  return yScale(d.y[1]);
43
50
  });
51
+ if (process.env.NODE_ENV !== 'production') {
52
+ if (xData.length !== stackedData.length) {
53
+ throw new Error("MUI: data length of the x axis (".concat(xData.length, " items) does not match length of series (").concat(stackedData.length, " items)"));
54
+ }
55
+ }
44
56
  var curve = getCurveFactory(series[seriesId].curve);
45
57
  var d3Data = xData == null ? void 0 : xData.map(function (x, index) {
58
+ var _stackedData$index;
46
59
  return {
47
60
  x: x,
48
- y: stackedData[index]
61
+ y: (_stackedData$index = stackedData[index]) != null ? _stackedData$index : [0, 0]
49
62
  };
50
63
  });
51
64
  return /*#__PURE__*/_jsx(LineElement, {
52
65
  id: seriesId,
53
66
  d: linePath.curve(curve)(d3Data) || undefined,
54
67
  color: series[seriesId].color,
55
- highlightScope: series[seriesId].highlightScope
68
+ highlightScope: series[seriesId].highlightScope,
69
+ slots: slots,
70
+ slotProps: slotProps
56
71
  }, seriesId);
57
72
  });
58
73
  })
59
- });
60
- }
74
+ }));
75
+ }
76
+ process.env.NODE_ENV !== "production" ? LinePlot.propTypes = {
77
+ // ----------------------------- Warning --------------------------------
78
+ // | These PropTypes are generated from the TypeScript type definitions |
79
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
80
+ // ----------------------------------------------------------------------
81
+ /**
82
+ * The props used for each component slot.
83
+ * @default {}
84
+ */
85
+ slotProps: PropTypes.object,
86
+ /**
87
+ * Overridable component slots.
88
+ * @default {}
89
+ */
90
+ slots: PropTypes.object
91
+ } : void 0;
92
+ export { LinePlot };
@@ -38,7 +38,7 @@ var MarkElementPath = styled('path', {
38
38
  return {
39
39
  transform: "translate(".concat(ownerState.x, "px, ").concat(ownerState.y, "px)"),
40
40
  transformOrigin: "".concat(ownerState.x, "px ").concat(ownerState.y, "px"),
41
- fill: (theme.vars || theme).palette.background.paper,
41
+ fill: theme.palette.background.paper,
42
42
  stroke: ownerState.color,
43
43
  strokeWidth: 2,
44
44
  '&.MuiMarkElement-highlighted': {
@@ -1,13 +1,19 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
1
2
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
3
  import * as React from 'react';
4
+ import PropTypes from 'prop-types';
3
5
  import { SeriesContext } from '../context/SeriesContextProvider';
4
6
  import { CartesianContext } from '../context/CartesianContextProvider';
5
7
  import { MarkElement } from './MarkElement';
6
8
  import { getValueToPositionMapper } from '../hooks/useScale';
7
9
  import { jsx as _jsx } from "react/jsx-runtime";
8
- export function MarkPlot() {
10
+ function MarkPlot(props) {
11
+ var _slots$mark;
12
+ var slots = props.slots,
13
+ slotProps = props.slotProps;
9
14
  var seriesData = React.useContext(SeriesContext).line;
10
15
  var axisData = React.useContext(CartesianContext);
16
+ var Mark = (_slots$mark = slots == null ? void 0 : slots.mark) != null ? _slots$mark : MarkElement;
11
17
  if (seriesData === undefined) {
12
18
  return null;
13
19
  }
@@ -19,7 +25,7 @@ export function MarkPlot() {
19
25
  yAxisIds = axisData.yAxisIds;
20
26
  var defaultXAxisId = xAxisIds[0];
21
27
  var defaultYAxisId = yAxisIds[0];
22
- return /*#__PURE__*/_jsx("g", {
28
+ return /*#__PURE__*/_jsx("g", _extends({}, props, {
23
29
  children: stackingGroups.flatMap(function (_ref) {
24
30
  var groupIds = _ref.ids;
25
31
  return groupIds.flatMap(function (seriesId) {
@@ -59,7 +65,7 @@ export function MarkPlot() {
59
65
  var x = _ref3.x,
60
66
  y = _ref3.y,
61
67
  index = _ref3.index;
62
- return /*#__PURE__*/_jsx(MarkElement, {
68
+ return /*#__PURE__*/_jsx(Mark, _extends({
63
69
  id: seriesId,
64
70
  dataIndex: index,
65
71
  shape: "circle",
@@ -67,9 +73,26 @@ export function MarkPlot() {
67
73
  x: x,
68
74
  y: y,
69
75
  highlightScope: series[seriesId].highlightScope
70
- }, "".concat(seriesId, "-").concat(index));
76
+ }, slotProps == null ? void 0 : slotProps.mark), "".concat(seriesId, "-").concat(index));
71
77
  });
72
78
  });
73
79
  })
74
- });
75
- }
80
+ }));
81
+ }
82
+ process.env.NODE_ENV !== "production" ? MarkPlot.propTypes = {
83
+ // ----------------------------- Warning --------------------------------
84
+ // | These PropTypes are generated from the TypeScript type definitions |
85
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
86
+ // ----------------------------------------------------------------------
87
+ /**
88
+ * The props used for each component slot.
89
+ * @default {}
90
+ */
91
+ slotProps: PropTypes.object,
92
+ /**
93
+ * Overridable component slots.
94
+ * @default {}
95
+ */
96
+ slots: PropTypes.object
97
+ } : void 0;
98
+ export { MarkPlot };
@@ -4,23 +4,27 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
4
  import { stack as d3Stack } from 'd3-shape';
5
5
  import { getStackingGroups } from '../internals/stackSeries';
6
6
  import defaultizeValueFormatter from '../internals/defaultizeValueFormatter';
7
-
8
7
  // For now it's a copy past of bar charts formatter, but maybe will diverge later
9
- var formatter = function formatter(params) {
8
+ var formatter = function formatter(params, dataset) {
10
9
  var seriesOrder = params.seriesOrder,
11
10
  series = params.series;
12
11
  var stackingGroups = getStackingGroups(params);
13
12
 
14
13
  // Create a data set with format adapted to d3
15
- var d3Dataset = [];
14
+ var d3Dataset = dataset != null ? dataset : [];
16
15
  seriesOrder.forEach(function (id) {
17
- series[id].data.forEach(function (value, index) {
18
- if (d3Dataset.length <= index) {
19
- d3Dataset.push(_defineProperty({}, id, value));
20
- } else {
21
- d3Dataset[index][id] = value;
22
- }
23
- });
16
+ var data = series[id].data;
17
+ if (data !== undefined) {
18
+ data.forEach(function (value, index) {
19
+ if (d3Dataset.length <= index) {
20
+ d3Dataset.push(_defineProperty({}, id, value));
21
+ } else {
22
+ d3Dataset[index][id] = value;
23
+ }
24
+ });
25
+ } else if (dataset === undefined) {
26
+ throw new Error(["MUI: line series with id='".concat(id, "' has no data."), 'Either provide a data property to the series or use the dataset prop.'].join('\n'));
27
+ }
24
28
  });
25
29
  var completedSeries = {};
26
30
  stackingGroups.forEach(function (stackingGroup) {
@@ -28,9 +32,17 @@ var formatter = function formatter(params) {
28
32
  var ids = stackingGroup.ids,
29
33
  stackingOrder = stackingGroup.stackingOrder,
30
34
  stackingOffset = stackingGroup.stackingOffset;
31
- var stackedSeries = d3Stack().keys(ids).order(stackingOrder).offset(stackingOffset)(d3Dataset);
35
+ var stackedSeries = d3Stack().keys(ids.map(function (id) {
36
+ // Use dataKey if needed and available
37
+ var dataKey = series[id].dataKey;
38
+ return series[id].data === undefined && dataKey !== undefined ? dataKey : id;
39
+ })).order(stackingOrder).offset(stackingOffset)(d3Dataset);
32
40
  ids.forEach(function (id, index) {
41
+ var dataKey = series[id].dataKey;
33
42
  completedSeries[id] = _extends({}, series[id], {
43
+ data: dataKey ? dataset.map(function (d) {
44
+ return d[dataKey];
45
+ }) : series[id].data,
34
46
  stackedData: stackedSeries[index].map(function (_ref) {
35
47
  var _ref2 = _slicedToArray(_ref, 2),
36
48
  a = _ref2[0],
@@ -35,7 +35,6 @@ var PieArcLabelRoot = styled('text', {
35
35
  var theme = _ref.theme;
36
36
  return {
37
37
  fill: theme.palette.text.primary,
38
- alignmentBaseline: 'baseline',
39
38
  textAnchor: 'middle'
40
39
  };
41
40
  });