@mui/x-charts 6.0.0-alpha.4 → 6.0.0-alpha.6

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 (104) hide show
  1. package/BarChart/BarChart.js +18 -10
  2. package/BarChart/formatter.js +23 -12
  3. package/CHANGELOG.md +156 -0
  4. package/ChartContainer/index.js +3 -0
  5. package/ChartsAxis/ChartsAxis.d.ts +4 -4
  6. package/ChartsAxis/ChartsAxis.js +4 -4
  7. package/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
  8. package/LineChart/AreaPlot.d.ts +1 -1
  9. package/LineChart/AreaPlot.js +4 -3
  10. package/LineChart/LineChart.js +18 -10
  11. package/LineChart/LinePlot.d.ts +1 -1
  12. package/LineChart/LinePlot.js +4 -3
  13. package/LineChart/MarkElement.js +1 -1
  14. package/LineChart/MarkPlot.d.ts +1 -1
  15. package/LineChart/MarkPlot.js +5 -3
  16. package/LineChart/formatter.js +23 -12
  17. package/PieChart/PieChart.js +13 -8
  18. package/ScatterChart/Scatter.js +39 -53
  19. package/ScatterChart/ScatterChart.js +13 -8
  20. package/SparkLineChart/SparkLineChart.d.ts +55 -0
  21. package/SparkLineChart/SparkLineChart.js +195 -0
  22. package/SparkLineChart/index.d.ts +1 -0
  23. package/SparkLineChart/index.js +12 -0
  24. package/SparkLineChart/package.json +6 -0
  25. package/context/CartesianContextProvider.d.ts +3 -1
  26. package/context/CartesianContextProvider.js +36 -6
  27. package/context/DrawingProvider.d.ts +1 -1
  28. package/context/DrawingProvider.js +1 -1
  29. package/context/SeriesContextProvider.d.ts +3 -2
  30. package/context/SeriesContextProvider.js +5 -3
  31. package/esm/BarChart/BarChart.js +21 -10
  32. package/esm/BarChart/formatter.js +23 -12
  33. package/esm/ChartContainer/index.js +3 -0
  34. package/esm/ChartsAxis/ChartsAxis.js +4 -4
  35. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
  36. package/esm/LineChart/AreaPlot.js +4 -3
  37. package/esm/LineChart/LineChart.js +21 -10
  38. package/esm/LineChart/LinePlot.js +4 -3
  39. package/esm/LineChart/MarkElement.js +1 -1
  40. package/esm/LineChart/MarkPlot.js +4 -3
  41. package/esm/LineChart/formatter.js +23 -13
  42. package/esm/PieChart/PieChart.js +13 -8
  43. package/esm/ScatterChart/Scatter.js +39 -53
  44. package/esm/ScatterChart/ScatterChart.js +13 -8
  45. package/esm/SparkLineChart/SparkLineChart.js +187 -0
  46. package/esm/SparkLineChart/index.js +1 -0
  47. package/esm/context/CartesianContextProvider.js +36 -6
  48. package/esm/context/DrawingProvider.js +1 -1
  49. package/esm/context/SeriesContextProvider.js +5 -3
  50. package/esm/index.js +1 -0
  51. package/esm/models/index.js +3 -1
  52. package/index.d.ts +1 -0
  53. package/index.js +12 -1
  54. package/internals/defaultizeColor.d.ts +4 -2
  55. package/legacy/BarChart/BarChart.js +19 -10
  56. package/legacy/BarChart/formatter.js +23 -10
  57. package/legacy/ChartContainer/index.js +3 -0
  58. package/legacy/ChartsAxis/ChartsAxis.js +4 -4
  59. package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
  60. package/legacy/LineChart/AreaPlot.js +4 -3
  61. package/legacy/LineChart/LineChart.js +19 -10
  62. package/legacy/LineChart/LinePlot.js +4 -3
  63. package/legacy/LineChart/MarkElement.js +1 -1
  64. package/legacy/LineChart/MarkPlot.js +4 -3
  65. package/legacy/LineChart/formatter.js +23 -11
  66. package/legacy/PieChart/PieChart.js +13 -8
  67. package/legacy/ScatterChart/Scatter.js +35 -46
  68. package/legacy/ScatterChart/ScatterChart.js +13 -8
  69. package/legacy/SparkLineChart/SparkLineChart.js +191 -0
  70. package/legacy/SparkLineChart/index.js +1 -0
  71. package/legacy/context/CartesianContextProvider.js +45 -7
  72. package/legacy/context/DrawingProvider.js +1 -1
  73. package/legacy/context/SeriesContextProvider.js +6 -4
  74. package/legacy/index.js +2 -1
  75. package/legacy/models/index.js +3 -1
  76. package/models/axis.d.ts +10 -2
  77. package/models/index.d.ts +2 -0
  78. package/models/index.js +11 -0
  79. package/models/seriesType/bar.d.ts +8 -1
  80. package/models/seriesType/common.d.ts +2 -2
  81. package/models/seriesType/config.d.ts +4 -1
  82. package/models/seriesType/line.d.ts +8 -1
  83. package/modern/BarChart/BarChart.js +18 -10
  84. package/modern/BarChart/formatter.js +23 -12
  85. package/modern/ChartContainer/index.js +3 -0
  86. package/modern/ChartsAxis/ChartsAxis.js +4 -4
  87. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
  88. package/modern/LineChart/AreaPlot.js +4 -3
  89. package/modern/LineChart/LineChart.js +18 -10
  90. package/modern/LineChart/LinePlot.js +4 -3
  91. package/modern/LineChart/MarkElement.js +1 -1
  92. package/modern/LineChart/MarkPlot.js +4 -3
  93. package/modern/LineChart/formatter.js +23 -13
  94. package/modern/PieChart/PieChart.js +13 -8
  95. package/modern/ScatterChart/Scatter.js +39 -53
  96. package/modern/ScatterChart/ScatterChart.js +13 -8
  97. package/modern/SparkLineChart/SparkLineChart.js +187 -0
  98. package/modern/SparkLineChart/index.js +1 -0
  99. package/modern/context/CartesianContextProvider.js +36 -6
  100. package/modern/context/DrawingProvider.js +1 -1
  101. package/modern/context/SeriesContextProvider.js +5 -3
  102. package/modern/index.js +2 -1
  103. package/modern/models/index.js +3 -1
  104. package/package.json +3 -1
@@ -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,
@@ -45,11 +46,12 @@ const BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
45
46
  id: DEFAULT_X_AXIS_KEY,
46
47
  scaleType: 'band',
47
48
  data: Array.from({
48
- length: Math.max(...series.map(s => s.data.length))
49
+ length: Math.max(...series.map(s => (s.data ?? dataset ?? []).length))
49
50
  }, (_, index) => index)
50
51
  }],
51
52
  yAxis: yAxis,
52
53
  colors: colors,
54
+ dataset: dataset,
53
55
  sx: sx,
54
56
  disableAxisListener: tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none',
55
57
  children: [/*#__PURE__*/_jsx("g", {
@@ -78,7 +80,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
78
80
  }),
79
81
  /**
80
82
  * Indicate which axis to display the bottom of the charts.
81
- * Can be a string (the id of the axis) or an object `ChartsXAxisProps`
83
+ * Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
82
84
  * @default xAxisIds[0] The id of the first provided axis
83
85
  */
84
86
  bottomAxis: PropTypes.oneOfType([PropTypes.shape({
@@ -100,12 +102,13 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
100
102
  * Color palette used to colorize multiple series.
101
103
  */
102
104
  colors: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.func]),
105
+ dataset: PropTypes.arrayOf(PropTypes.object),
103
106
  desc: PropTypes.string,
104
107
  disableAxisListener: PropTypes.bool,
105
108
  height: PropTypes.number,
106
109
  /**
107
110
  * Indicate which axis to display the left of the charts.
108
- * Can be a string (the id of the axis) or an object `ChartsYAxisProps`
111
+ * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
109
112
  * @default yAxisIds[0] The id of the first provided axis
110
113
  */
111
114
  leftAxis: PropTypes.oneOfType([PropTypes.shape({
@@ -145,7 +148,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
145
148
  }),
146
149
  /**
147
150
  * Indicate which axis to display the right of the charts.
148
- * Can be a string (the id of the axis) or an object `ChartsYAxisProps`
151
+ * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
149
152
  * @default null
150
153
  */
151
154
  rightAxis: PropTypes.oneOfType([PropTypes.shape({
@@ -163,7 +166,8 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
163
166
  }), PropTypes.string]),
164
167
  series: PropTypes.arrayOf(PropTypes.shape({
165
168
  color: PropTypes.string,
166
- data: PropTypes.arrayOf(PropTypes.number).isRequired,
169
+ data: PropTypes.arrayOf(PropTypes.number),
170
+ dataKey: PropTypes.string,
167
171
  highlightScope: PropTypes.shape({
168
172
  faded: PropTypes.oneOf(['global', 'none', 'series']),
169
173
  highlighted: PropTypes.oneOf(['item', 'none', 'series'])
@@ -188,7 +192,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
188
192
  }),
189
193
  /**
190
194
  * Indicate which axis to display the top of the charts.
191
- * Can be a string (the id of the axis) or an object `ChartsXAxisProps`
195
+ * Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
192
196
  * @default null
193
197
  */
194
198
  topAxis: PropTypes.oneOfType([PropTypes.shape({
@@ -215,15 +219,17 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
215
219
  axisId: PropTypes.string,
216
220
  classes: PropTypes.object,
217
221
  data: PropTypes.array,
222
+ dataKey: PropTypes.string,
218
223
  disableLine: PropTypes.bool,
219
224
  disableTicks: PropTypes.bool,
220
225
  fill: PropTypes.string,
226
+ hideTooltip: PropTypes.bool,
221
227
  id: PropTypes.string,
222
228
  label: PropTypes.string,
223
229
  labelFontSize: PropTypes.number,
224
- max: PropTypes.number,
230
+ max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
225
231
  maxTicks: PropTypes.number,
226
- min: PropTypes.number,
232
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
227
233
  minTicks: PropTypes.number,
228
234
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
229
235
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
@@ -237,15 +243,17 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
237
243
  axisId: PropTypes.string,
238
244
  classes: PropTypes.object,
239
245
  data: PropTypes.array,
246
+ dataKey: PropTypes.string,
240
247
  disableLine: PropTypes.bool,
241
248
  disableTicks: PropTypes.bool,
242
249
  fill: PropTypes.string,
250
+ hideTooltip: PropTypes.bool,
243
251
  id: PropTypes.string,
244
252
  label: PropTypes.string,
245
253
  labelFontSize: PropTypes.number,
246
- max: PropTypes.number,
254
+ max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
247
255
  maxTicks: PropTypes.number,
248
- min: PropTypes.number,
256
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
249
257
  minTicks: PropTypes.number,
250
258
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
251
259
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
@@ -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, {
@@ -71,7 +71,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
71
71
  // ----------------------------------------------------------------------
72
72
  /**
73
73
  * Indicate which axis to display the bottom of the charts.
74
- * Can be a string (the id of the axis) or an object `ChartsXAxisProps`
74
+ * Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
75
75
  * @default xAxisIds[0] The id of the first provided axis
76
76
  */
77
77
  bottomAxis: PropTypes.oneOfType([PropTypes.shape({
@@ -89,7 +89,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
89
89
  }), PropTypes.string]),
90
90
  /**
91
91
  * Indicate which axis to display the left of the charts.
92
- * Can be a string (the id of the axis) or an object `ChartsYAxisProps`
92
+ * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
93
93
  * @default yAxisIds[0] The id of the first provided axis
94
94
  */
95
95
  leftAxis: PropTypes.oneOfType([PropTypes.shape({
@@ -107,7 +107,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
107
107
  }), PropTypes.string]),
108
108
  /**
109
109
  * Indicate which axis to display the right of the charts.
110
- * Can be a string (the id of the axis) or an object `ChartsYAxisProps`
110
+ * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
111
111
  * @default null
112
112
  */
113
113
  rightAxis: PropTypes.oneOfType([PropTypes.shape({
@@ -125,7 +125,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
125
125
  }), PropTypes.string]),
126
126
  /**
127
127
  * Indicate which axis to display the top of the charts.
128
- * Can be a string (the id of the axis) or an object `ChartsXAxisProps`
128
+ * Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
129
129
  * @default null
130
130
  */
131
131
  topAxis: PropTypes.oneOfType([PropTypes.shape({
@@ -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,
@@ -1,3 +1,4 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
1
2
  import * as React from 'react';
2
3
  import { area as d3Area } from 'd3-shape';
3
4
  import { SeriesContext } from '../context/SeriesContextProvider';
@@ -6,7 +7,7 @@ import { AreaElement } from './AreaElement';
6
7
  import { getValueToPositionMapper } from '../hooks/useScale';
7
8
  import getCurveFactory from '../internals/getCurve';
8
9
  import { jsx as _jsx } from "react/jsx-runtime";
9
- export function AreaPlot() {
10
+ export function AreaPlot(props) {
10
11
  const seriesData = React.useContext(SeriesContext).line;
11
12
  const axisData = React.useContext(CartesianContext);
12
13
  if (seriesData === undefined) {
@@ -24,7 +25,7 @@ export function AreaPlot() {
24
25
  } = axisData;
25
26
  const defaultXAxisId = xAxisIds[0];
26
27
  const defaultYAxisId = yAxisIds[0];
27
- return /*#__PURE__*/_jsx("g", {
28
+ return /*#__PURE__*/_jsx("g", _extends({}, props, {
28
29
  children: stackingGroups.flatMap(({
29
30
  ids: groupIds
30
31
  }) => {
@@ -54,5 +55,5 @@ export function AreaPlot() {
54
55
  }, seriesId);
55
56
  });
56
57
  })
57
- });
58
+ }));
58
59
  }
@@ -23,6 +23,7 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
23
23
  height,
24
24
  margin,
25
25
  colors,
26
+ dataset,
26
27
  sx,
27
28
  tooltip,
28
29
  axisHighlight = {
@@ -49,11 +50,12 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
49
50
  id: DEFAULT_X_AXIS_KEY,
50
51
  scaleType: 'point',
51
52
  data: Array.from({
52
- length: Math.max(...series.map(s => s.data.length))
53
+ length: Math.max(...series.map(s => (s.data ?? dataset ?? []).length))
53
54
  }, (_, index) => index)
54
55
  }],
55
56
  yAxis: yAxis,
56
57
  colors: colors,
58
+ dataset: dataset,
57
59
  sx: sx,
58
60
  disableAxisListener: tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none',
59
61
  children: [/*#__PURE__*/_jsxs("g", {
@@ -80,7 +82,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
80
82
  }),
81
83
  /**
82
84
  * Indicate which axis to display the bottom of the charts.
83
- * Can be a string (the id of the axis) or an object `ChartsXAxisProps`
85
+ * Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
84
86
  * @default xAxisIds[0] The id of the first provided axis
85
87
  */
86
88
  bottomAxis: PropTypes.oneOfType([PropTypes.shape({
@@ -102,12 +104,13 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
102
104
  * Color palette used to colorize multiple series.
103
105
  */
104
106
  colors: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.func]),
107
+ dataset: PropTypes.arrayOf(PropTypes.object),
105
108
  desc: PropTypes.string,
106
109
  disableAxisListener: PropTypes.bool,
107
110
  height: PropTypes.number,
108
111
  /**
109
112
  * Indicate which axis to display the left of the charts.
110
- * Can be a string (the id of the axis) or an object `ChartsYAxisProps`
113
+ * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
111
114
  * @default yAxisIds[0] The id of the first provided axis
112
115
  */
113
116
  leftAxis: PropTypes.oneOfType([PropTypes.shape({
@@ -147,7 +150,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
147
150
  }),
148
151
  /**
149
152
  * Indicate which axis to display the right of the charts.
150
- * Can be a string (the id of the axis) or an object `ChartsYAxisProps`
153
+ * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
151
154
  * @default null
152
155
  */
153
156
  rightAxis: PropTypes.oneOfType([PropTypes.shape({
@@ -167,7 +170,8 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
167
170
  area: PropTypes.bool,
168
171
  color: PropTypes.string,
169
172
  curve: PropTypes.oneOf(['catmullRom', 'linear', 'monotoneX', 'monotoneY', 'natural', 'step', 'stepAfter', 'stepBefore']),
170
- data: PropTypes.arrayOf(PropTypes.number).isRequired,
173
+ data: PropTypes.arrayOf(PropTypes.number),
174
+ dataKey: PropTypes.string,
171
175
  highlightScope: PropTypes.shape({
172
176
  faded: PropTypes.oneOf(['global', 'none', 'series']),
173
177
  highlighted: PropTypes.oneOf(['item', 'none', 'series'])
@@ -192,7 +196,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
192
196
  }),
193
197
  /**
194
198
  * Indicate which axis to display the top of the charts.
195
- * Can be a string (the id of the axis) or an object `ChartsXAxisProps`
199
+ * Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
196
200
  * @default null
197
201
  */
198
202
  topAxis: PropTypes.oneOfType([PropTypes.shape({
@@ -219,15 +223,17 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
219
223
  axisId: PropTypes.string,
220
224
  classes: PropTypes.object,
221
225
  data: PropTypes.array,
226
+ dataKey: PropTypes.string,
222
227
  disableLine: PropTypes.bool,
223
228
  disableTicks: PropTypes.bool,
224
229
  fill: PropTypes.string,
230
+ hideTooltip: PropTypes.bool,
225
231
  id: PropTypes.string,
226
232
  label: PropTypes.string,
227
233
  labelFontSize: PropTypes.number,
228
- max: PropTypes.number,
234
+ max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
229
235
  maxTicks: PropTypes.number,
230
- min: PropTypes.number,
236
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
231
237
  minTicks: PropTypes.number,
232
238
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
233
239
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
@@ -241,15 +247,17 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
241
247
  axisId: PropTypes.string,
242
248
  classes: PropTypes.object,
243
249
  data: PropTypes.array,
250
+ dataKey: PropTypes.string,
244
251
  disableLine: PropTypes.bool,
245
252
  disableTicks: PropTypes.bool,
246
253
  fill: PropTypes.string,
254
+ hideTooltip: PropTypes.bool,
247
255
  id: PropTypes.string,
248
256
  label: PropTypes.string,
249
257
  labelFontSize: PropTypes.number,
250
- max: PropTypes.number,
258
+ max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
251
259
  maxTicks: PropTypes.number,
252
- min: PropTypes.number,
260
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
253
261
  minTicks: PropTypes.number,
254
262
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
255
263
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
@@ -1,3 +1,4 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
1
2
  import * as React from 'react';
2
3
  import { line as d3Line } from 'd3-shape';
3
4
  import { SeriesContext } from '../context/SeriesContextProvider';
@@ -6,7 +7,7 @@ import { LineElement } from './LineElement';
6
7
  import { getValueToPositionMapper } from '../hooks/useScale';
7
8
  import getCurveFactory from '../internals/getCurve';
8
9
  import { jsx as _jsx } from "react/jsx-runtime";
9
- export function LinePlot() {
10
+ export function LinePlot(props) {
10
11
  const seriesData = React.useContext(SeriesContext).line;
11
12
  const axisData = React.useContext(CartesianContext);
12
13
  if (seriesData === undefined) {
@@ -24,7 +25,7 @@ export function LinePlot() {
24
25
  } = axisData;
25
26
  const defaultXAxisId = xAxisIds[0];
26
27
  const defaultYAxisId = yAxisIds[0];
27
- return /*#__PURE__*/_jsx("g", {
28
+ return /*#__PURE__*/_jsx("g", _extends({}, props, {
28
29
  children: stackingGroups.flatMap(({
29
30
  ids: groupIds
30
31
  }) => {
@@ -54,5 +55,5 @@ export function LinePlot() {
54
55
  }, seriesId);
55
56
  });
56
57
  })
57
- });
58
+ }));
58
59
  }
@@ -38,7 +38,7 @@ const MarkElementPath = styled('path', {
38
38
  }) => ({
39
39
  transform: `translate(${ownerState.x}px, ${ownerState.y}px)`,
40
40
  transformOrigin: `${ownerState.x}px ${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,10 +1,11 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
1
2
  import * as React from 'react';
2
3
  import { SeriesContext } from '../context/SeriesContextProvider';
3
4
  import { CartesianContext } from '../context/CartesianContextProvider';
4
5
  import { MarkElement } from './MarkElement';
5
6
  import { getValueToPositionMapper } from '../hooks/useScale';
6
7
  import { jsx as _jsx } from "react/jsx-runtime";
7
- export function MarkPlot() {
8
+ export function MarkPlot(props) {
8
9
  const seriesData = React.useContext(SeriesContext).line;
9
10
  const axisData = React.useContext(CartesianContext);
10
11
  if (seriesData === undefined) {
@@ -22,7 +23,7 @@ export function MarkPlot() {
22
23
  } = axisData;
23
24
  const defaultXAxisId = xAxisIds[0];
24
25
  const defaultYAxisId = yAxisIds[0];
25
- return /*#__PURE__*/_jsx("g", {
26
+ return /*#__PURE__*/_jsx("g", _extends({}, props, {
26
27
  children: stackingGroups.flatMap(({
27
28
  ids: groupIds
28
29
  }) => {
@@ -74,5 +75,5 @@ export function MarkPlot() {
74
75
  }, `${seriesId}-${index}`));
75
76
  });
76
77
  })
77
- });
78
+ }));
78
79
  }
@@ -2,9 +2,8 @@ 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
-
6
5
  // For now it's a copy past of bar charts formatter, but maybe will diverge later
7
- const formatter = params => {
6
+ const formatter = (params, dataset) => {
8
7
  const {
9
8
  seriesOrder,
10
9
  series
@@ -12,17 +11,22 @@ const formatter = params => {
12
11
  const stackingGroups = getStackingGroups(params);
13
12
 
14
13
  // Create a data set with format adapted to d3
15
- const d3Dataset = [];
14
+ const d3Dataset = dataset ?? [];
16
15
  seriesOrder.forEach(id => {
17
- series[id].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
- });
16
+ const data = series[id].data;
17
+ if (data !== undefined) {
18
+ data.forEach((value, index) => {
19
+ if (d3Dataset.length <= index) {
20
+ d3Dataset.push({
21
+ [id]: value
22
+ });
23
+ } else {
24
+ d3Dataset[index][id] = value;
25
+ }
26
+ });
27
+ } else if (dataset === undefined) {
28
+ throw new Error([`MUI: line series with id='${id}' has no data.`, 'Either provide a data property to the series or use the dataset prop.'].join('\n'));
29
+ }
26
30
  });
27
31
  const completedSeries = {};
28
32
  stackingGroups.forEach(stackingGroup => {
@@ -32,9 +36,15 @@ const formatter = params => {
32
36
  stackingOrder,
33
37
  stackingOffset
34
38
  } = stackingGroup;
35
- const stackedSeries = d3Stack().keys(ids).order(stackingOrder).offset(stackingOffset)(d3Dataset);
39
+ const stackedSeries = d3Stack().keys(ids.map(id => {
40
+ // Use dataKey if needed and available
41
+ const dataKey = series[id].dataKey;
42
+ return series[id].data === undefined && dataKey !== undefined ? dataKey : id;
43
+ })).order(stackingOrder).offset(stackingOffset)(d3Dataset);
36
44
  ids.forEach((id, index) => {
45
+ const dataKey = series[id].dataKey;
37
46
  completedSeries[id] = _extends({}, series[id], {
47
+ data: dataKey ? dataset.map(d => d[dataKey]) : series[id].data,
38
48
  stackedData: stackedSeries[index].map(([a, b]) => [a, b])
39
49
  });
40
50
  });
@@ -82,7 +82,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
82
82
  }),
83
83
  /**
84
84
  * Indicate which axis to display the bottom of the charts.
85
- * Can be a string (the id of the axis) or an object `ChartsXAxisProps`
85
+ * Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
86
86
  * @default xAxisIds[0] The id of the first provided axis
87
87
  */
88
88
  bottomAxis: PropTypes.oneOfType([PropTypes.shape({
@@ -104,12 +104,13 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
104
104
  * Color palette used to colorize multiple series.
105
105
  */
106
106
  colors: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.func]),
107
+ dataset: PropTypes.arrayOf(PropTypes.object),
107
108
  desc: PropTypes.string,
108
109
  disableAxisListener: PropTypes.bool,
109
110
  height: PropTypes.number,
110
111
  /**
111
112
  * Indicate which axis to display the left of the charts.
112
- * Can be a string (the id of the axis) or an object `ChartsYAxisProps`
113
+ * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
113
114
  * @default yAxisIds[0] The id of the first provided axis
114
115
  */
115
116
  leftAxis: PropTypes.oneOfType([PropTypes.shape({
@@ -149,7 +150,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
149
150
  }),
150
151
  /**
151
152
  * Indicate which axis to display the right of the charts.
152
- * Can be a string (the id of the axis) or an object `ChartsYAxisProps`
153
+ * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
153
154
  * @default null
154
155
  */
155
156
  rightAxis: PropTypes.oneOfType([PropTypes.shape({
@@ -214,7 +215,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
214
215
  }),
215
216
  /**
216
217
  * Indicate which axis to display the top of the charts.
217
- * Can be a string (the id of the axis) or an object `ChartsXAxisProps`
218
+ * Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
218
219
  * @default null
219
220
  */
220
221
  topAxis: PropTypes.oneOfType([PropTypes.shape({
@@ -241,15 +242,17 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
241
242
  axisId: PropTypes.string,
242
243
  classes: PropTypes.object,
243
244
  data: PropTypes.array,
245
+ dataKey: PropTypes.string,
244
246
  disableLine: PropTypes.bool,
245
247
  disableTicks: PropTypes.bool,
246
248
  fill: PropTypes.string,
249
+ hideTooltip: PropTypes.bool,
247
250
  id: PropTypes.string,
248
251
  label: PropTypes.string,
249
252
  labelFontSize: PropTypes.number,
250
- max: PropTypes.number,
253
+ max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
251
254
  maxTicks: PropTypes.number,
252
- min: PropTypes.number,
255
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
253
256
  minTicks: PropTypes.number,
254
257
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
255
258
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
@@ -263,15 +266,17 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
263
266
  axisId: PropTypes.string,
264
267
  classes: PropTypes.object,
265
268
  data: PropTypes.array,
269
+ dataKey: PropTypes.string,
266
270
  disableLine: PropTypes.bool,
267
271
  disableTicks: PropTypes.bool,
268
272
  fill: PropTypes.string,
273
+ hideTooltip: PropTypes.bool,
269
274
  id: PropTypes.string,
270
275
  label: PropTypes.string,
271
276
  labelFontSize: PropTypes.number,
272
- max: PropTypes.number,
277
+ max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
273
278
  maxTicks: PropTypes.number,
274
- min: PropTypes.number,
279
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
275
280
  minTicks: PropTypes.number,
276
281
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
277
282
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),