@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
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v6.0.0-alpha.4
2
+ * @mui/x-charts v6.0.0-alpha.6
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -175,6 +175,17 @@ Object.keys(_ScatterChart).forEach(function (key) {
175
175
  }
176
176
  });
177
177
  });
178
+ var _SparkLineChart = require("./SparkLineChart");
179
+ Object.keys(_SparkLineChart).forEach(function (key) {
180
+ if (key === "default" || key === "__esModule") return;
181
+ if (key in exports && exports[key] === _SparkLineChart[key]) return;
182
+ Object.defineProperty(exports, key, {
183
+ enumerable: true,
184
+ get: function () {
185
+ return _SparkLineChart[key];
186
+ }
187
+ });
188
+ });
178
189
  var _ChartContainer = require("./ChartContainer");
179
190
  Object.keys(_ChartContainer).forEach(function (key) {
180
191
  if (key === "default" || key === "__esModule") return;
@@ -36,7 +36,8 @@ export declare function defaultizeColor(series: AllSeriesType, seriesIndex: numb
36
36
  highlightScope?: Partial<import("..").HighlightScope> | undefined;
37
37
  } | {
38
38
  type: "bar";
39
- data: number[];
39
+ data?: number[] | undefined;
40
+ dataKey?: string | undefined;
40
41
  label?: string | undefined;
41
42
  id?: string | undefined;
42
43
  color: string;
@@ -49,7 +50,8 @@ export declare function defaultizeColor(series: AllSeriesType, seriesIndex: numb
49
50
  stackOrder?: "reverse" | "none" | "appearance" | "ascending" | "descending" | "insideOut" | undefined;
50
51
  } | {
51
52
  type: "line";
52
- data: number[];
53
+ data?: number[] | undefined;
54
+ dataKey?: string | undefined;
53
55
  stack?: string | undefined;
54
56
  area?: boolean | undefined;
55
57
  label?: string | undefined;
@@ -21,6 +21,7 @@ var BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
21
21
  height = props.height,
22
22
  margin = props.margin,
23
23
  colors = props.colors,
24
+ dataset = props.dataset,
24
25
  sx = props.sx,
25
26
  tooltip = props.tooltip,
26
27
  axisHighlight = props.axisHighlight,
@@ -47,7 +48,8 @@ var BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
47
48
  scaleType: 'band',
48
49
  data: Array.from({
49
50
  length: Math.max.apply(Math, _toConsumableArray(series.map(function (s) {
50
- return s.data.length;
51
+ var _ref, _s$data;
52
+ return ((_ref = (_s$data = s.data) != null ? _s$data : dataset) != null ? _ref : []).length;
51
53
  })))
52
54
  }, function (_, index) {
53
55
  return index;
@@ -55,6 +57,7 @@ var BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
55
57
  }],
56
58
  yAxis: yAxis,
57
59
  colors: colors,
60
+ dataset: dataset,
58
61
  sx: sx,
59
62
  disableAxisListener: (tooltip == null ? void 0 : tooltip.trigger) !== 'axis' && (axisHighlight == null ? void 0 : axisHighlight.x) === 'none' && (axisHighlight == null ? void 0 : axisHighlight.y) === 'none',
60
63
  children: [/*#__PURE__*/_jsx("g", {
@@ -83,7 +86,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
83
86
  }),
84
87
  /**
85
88
  * Indicate which axis to display the bottom of the charts.
86
- * Can be a string (the id of the axis) or an object `ChartsXAxisProps`
89
+ * Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
87
90
  * @default xAxisIds[0] The id of the first provided axis
88
91
  */
89
92
  bottomAxis: PropTypes.oneOfType([PropTypes.shape({
@@ -105,12 +108,13 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
105
108
  * Color palette used to colorize multiple series.
106
109
  */
107
110
  colors: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.func]),
111
+ dataset: PropTypes.arrayOf(PropTypes.object),
108
112
  desc: PropTypes.string,
109
113
  disableAxisListener: PropTypes.bool,
110
114
  height: PropTypes.number,
111
115
  /**
112
116
  * Indicate which axis to display the left of the charts.
113
- * Can be a string (the id of the axis) or an object `ChartsYAxisProps`
117
+ * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
114
118
  * @default yAxisIds[0] The id of the first provided axis
115
119
  */
116
120
  leftAxis: PropTypes.oneOfType([PropTypes.shape({
@@ -150,7 +154,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
150
154
  }),
151
155
  /**
152
156
  * Indicate which axis to display the right of the charts.
153
- * Can be a string (the id of the axis) or an object `ChartsYAxisProps`
157
+ * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
154
158
  * @default null
155
159
  */
156
160
  rightAxis: PropTypes.oneOfType([PropTypes.shape({
@@ -168,7 +172,8 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
168
172
  }), PropTypes.string]),
169
173
  series: PropTypes.arrayOf(PropTypes.shape({
170
174
  color: PropTypes.string,
171
- data: PropTypes.arrayOf(PropTypes.number).isRequired,
175
+ data: PropTypes.arrayOf(PropTypes.number),
176
+ dataKey: PropTypes.string,
172
177
  highlightScope: PropTypes.shape({
173
178
  faded: PropTypes.oneOf(['global', 'none', 'series']),
174
179
  highlighted: PropTypes.oneOf(['item', 'none', 'series'])
@@ -193,7 +198,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
193
198
  }),
194
199
  /**
195
200
  * Indicate which axis to display the top of the charts.
196
- * Can be a string (the id of the axis) or an object `ChartsXAxisProps`
201
+ * Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
197
202
  * @default null
198
203
  */
199
204
  topAxis: PropTypes.oneOfType([PropTypes.shape({
@@ -220,15 +225,17 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
220
225
  axisId: PropTypes.string,
221
226
  classes: PropTypes.object,
222
227
  data: PropTypes.array,
228
+ dataKey: PropTypes.string,
223
229
  disableLine: PropTypes.bool,
224
230
  disableTicks: PropTypes.bool,
225
231
  fill: PropTypes.string,
232
+ hideTooltip: PropTypes.bool,
226
233
  id: PropTypes.string,
227
234
  label: PropTypes.string,
228
235
  labelFontSize: PropTypes.number,
229
- max: PropTypes.number,
236
+ max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
230
237
  maxTicks: PropTypes.number,
231
- min: PropTypes.number,
238
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
232
239
  minTicks: PropTypes.number,
233
240
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
234
241
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
@@ -242,15 +249,17 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
242
249
  axisId: PropTypes.string,
243
250
  classes: PropTypes.object,
244
251
  data: PropTypes.array,
252
+ dataKey: PropTypes.string,
245
253
  disableLine: PropTypes.bool,
246
254
  disableTicks: PropTypes.bool,
247
255
  fill: PropTypes.string,
256
+ hideTooltip: PropTypes.bool,
248
257
  id: PropTypes.string,
249
258
  label: PropTypes.string,
250
259
  labelFontSize: PropTypes.number,
251
- max: PropTypes.number,
260
+ max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
252
261
  maxTicks: PropTypes.number,
253
- min: PropTypes.number,
262
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
254
263
  minTicks: PropTypes.number,
255
264
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
256
265
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
@@ -4,21 +4,26 @@ 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
- var formatter = function formatter(params) {
7
+ var formatter = function formatter(params, dataset) {
8
8
  var seriesOrder = params.seriesOrder,
9
9
  series = params.series;
10
10
  var stackingGroups = getStackingGroups(params);
11
11
 
12
12
  // Create a data set with format adapted to d3
13
- var d3Dataset = [];
13
+ var d3Dataset = dataset != null ? dataset : [];
14
14
  seriesOrder.forEach(function (id) {
15
- series[id].data.forEach(function (value, index) {
16
- if (d3Dataset.length <= index) {
17
- d3Dataset.push(_defineProperty({}, id, value));
18
- } else {
19
- d3Dataset[index][id] = value;
20
- }
21
- });
15
+ var data = series[id].data;
16
+ if (data !== undefined) {
17
+ 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
+ });
24
+ } else if (dataset === undefined) {
25
+ throw new Error(["MUI: bar series with id='".concat(id, "' has no data."), 'Either provide a data property to the series or use the dataset prop.'].join('\n'));
26
+ }
22
27
  });
23
28
  var completedSeries = {};
24
29
  stackingGroups.forEach(function (stackingGroup) {
@@ -26,9 +31,17 @@ var formatter = function formatter(params) {
26
31
  stackingOffset = stackingGroup.stackingOffset,
27
32
  stackingOrder = stackingGroup.stackingOrder;
28
33
  // Get stacked values, and derive the domain
29
- var stackedSeries = d3Stack().keys(ids).order(stackingOrder).offset(stackingOffset)(d3Dataset);
34
+ var stackedSeries = d3Stack().keys(ids.map(function (id) {
35
+ // Use dataKey if needed and available
36
+ var dataKey = series[id].dataKey;
37
+ return series[id].data === undefined && dataKey !== undefined ? dataKey : id;
38
+ })).order(stackingOrder).offset(stackingOffset)(d3Dataset);
30
39
  ids.forEach(function (id, index) {
40
+ var dataKey = series[id].dataKey;
31
41
  completedSeries[id] = _extends({}, series[id], {
42
+ data: dataKey ? dataset.map(function (d) {
43
+ return d[dataKey];
44
+ }) : series[id].data,
32
45
  stackedData: stackedSeries[index].map(function (_ref) {
33
46
  var _ref2 = _slicedToArray(_ref, 2),
34
47
  a = _ref2[0],
@@ -15,6 +15,7 @@ export var ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContaine
15
15
  xAxis = props.xAxis,
16
16
  yAxis = props.yAxis,
17
17
  colors = props.colors,
18
+ dataset = props.dataset,
18
19
  sx = props.sx,
19
20
  title = props.title,
20
21
  desc = props.desc,
@@ -30,9 +31,11 @@ export var ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContaine
30
31
  children: /*#__PURE__*/_jsx(SeriesContextProvider, {
31
32
  series: series,
32
33
  colors: colors,
34
+ dataset: dataset,
33
35
  children: /*#__PURE__*/_jsx(CartesianContextProvider, {
34
36
  xAxis: xAxis,
35
37
  yAxis: yAxis,
38
+ dataset: dataset,
36
39
  children: /*#__PURE__*/_jsx(InteractionProvider, {
37
40
  children: /*#__PURE__*/_jsx(HighlightProvider, {
38
41
  children: /*#__PURE__*/_jsx(ChartsSurface, {
@@ -69,7 +69,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
69
69
  // ----------------------------------------------------------------------
70
70
  /**
71
71
  * Indicate which axis to display the bottom of the charts.
72
- * Can be a string (the id of the axis) or an object `ChartsXAxisProps`
72
+ * Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
73
73
  * @default xAxisIds[0] The id of the first provided axis
74
74
  */
75
75
  bottomAxis: PropTypes.oneOfType([PropTypes.shape({
@@ -87,7 +87,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
87
87
  }), PropTypes.string]),
88
88
  /**
89
89
  * Indicate which axis to display the left of the charts.
90
- * Can be a string (the id of the axis) or an object `ChartsYAxisProps`
90
+ * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
91
91
  * @default yAxisIds[0] The id of the first provided axis
92
92
  */
93
93
  leftAxis: PropTypes.oneOfType([PropTypes.shape({
@@ -105,7 +105,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
105
105
  }), PropTypes.string]),
106
106
  /**
107
107
  * Indicate which axis to display the right of the charts.
108
- * Can be a string (the id of the axis) or an object `ChartsYAxisProps`
108
+ * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
109
109
  * @default null
110
110
  */
111
111
  rightAxis: PropTypes.oneOfType([PropTypes.shape({
@@ -123,7 +123,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
123
123
  }), PropTypes.string]),
124
124
  /**
125
125
  * Indicate which axis to display the top of the charts.
126
- * Can be a string (the id of the axis) or an object `ChartsXAxisProps`
126
+ * Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
127
127
  * @default null
128
128
  */
129
129
  topAxis: PropTypes.oneOfType([PropTypes.shape({
@@ -24,7 +24,7 @@ export function DefaultChartsAxisContent(props) {
24
24
  variant: "outlined",
25
25
  className: classes.root,
26
26
  children: /*#__PURE__*/_jsxs(ChartsTooltipTable, {
27
- children: [axisValue != null && /*#__PURE__*/_jsx("thead", {
27
+ children: [axisValue != null && !axis.hideTooltip && /*#__PURE__*/_jsx("thead", {
28
28
  children: /*#__PURE__*/_jsx(ChartsTooltipRow, {
29
29
  children: /*#__PURE__*/_jsx(ChartsTooltipCell, {
30
30
  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
  var seriesData = React.useContext(SeriesContext).line;
11
12
  var axisData = React.useContext(CartesianContext);
12
13
  if (seriesData === undefined) {
@@ -20,7 +21,7 @@ export function AreaPlot() {
20
21
  yAxisIds = axisData.yAxisIds;
21
22
  var defaultXAxisId = xAxisIds[0];
22
23
  var defaultYAxisId = yAxisIds[0];
23
- return /*#__PURE__*/_jsx("g", {
24
+ return /*#__PURE__*/_jsx("g", _extends({}, props, {
24
25
  children: stackingGroups.flatMap(function (_ref) {
25
26
  var groupIds = _ref.ids;
26
27
  return groupIds.flatMap(function (seriesId) {
@@ -58,5 +59,5 @@ export function AreaPlot() {
58
59
  }, seriesId);
59
60
  });
60
61
  })
61
- });
62
+ }));
62
63
  }
@@ -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,
@@ -52,7 +53,8 @@ var LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
52
53
  scaleType: 'point',
53
54
  data: Array.from({
54
55
  length: Math.max.apply(Math, _toConsumableArray(series.map(function (s) {
55
- return s.data.length;
56
+ var _ref, _s$data;
57
+ return ((_ref = (_s$data = s.data) != null ? _s$data : dataset) != null ? _ref : []).length;
56
58
  })))
57
59
  }, function (_, index) {
58
60
  return index;
@@ -60,6 +62,7 @@ var LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
60
62
  }],
61
63
  yAxis: yAxis,
62
64
  colors: colors,
65
+ dataset: dataset,
63
66
  sx: sx,
64
67
  disableAxisListener: (tooltip == null ? void 0 : tooltip.trigger) !== 'axis' && (axisHighlight == null ? void 0 : axisHighlight.x) === 'none' && (axisHighlight == null ? void 0 : axisHighlight.y) === 'none',
65
68
  children: [/*#__PURE__*/_jsxs("g", {
@@ -86,7 +89,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
86
89
  }),
87
90
  /**
88
91
  * Indicate which axis to display the bottom of the charts.
89
- * Can be a string (the id of the axis) or an object `ChartsXAxisProps`
92
+ * Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
90
93
  * @default xAxisIds[0] The id of the first provided axis
91
94
  */
92
95
  bottomAxis: PropTypes.oneOfType([PropTypes.shape({
@@ -108,12 +111,13 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
108
111
  * Color palette used to colorize multiple series.
109
112
  */
110
113
  colors: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.func]),
114
+ dataset: PropTypes.arrayOf(PropTypes.object),
111
115
  desc: PropTypes.string,
112
116
  disableAxisListener: PropTypes.bool,
113
117
  height: PropTypes.number,
114
118
  /**
115
119
  * Indicate which axis to display the left of the charts.
116
- * Can be a string (the id of the axis) or an object `ChartsYAxisProps`
120
+ * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
117
121
  * @default yAxisIds[0] The id of the first provided axis
118
122
  */
119
123
  leftAxis: PropTypes.oneOfType([PropTypes.shape({
@@ -153,7 +157,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
153
157
  }),
154
158
  /**
155
159
  * Indicate which axis to display the right of the charts.
156
- * Can be a string (the id of the axis) or an object `ChartsYAxisProps`
160
+ * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
157
161
  * @default null
158
162
  */
159
163
  rightAxis: PropTypes.oneOfType([PropTypes.shape({
@@ -173,7 +177,8 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
173
177
  area: PropTypes.bool,
174
178
  color: PropTypes.string,
175
179
  curve: PropTypes.oneOf(['catmullRom', 'linear', 'monotoneX', 'monotoneY', 'natural', 'step', 'stepAfter', 'stepBefore']),
176
- data: PropTypes.arrayOf(PropTypes.number).isRequired,
180
+ data: PropTypes.arrayOf(PropTypes.number),
181
+ dataKey: PropTypes.string,
177
182
  highlightScope: PropTypes.shape({
178
183
  faded: PropTypes.oneOf(['global', 'none', 'series']),
179
184
  highlighted: PropTypes.oneOf(['item', 'none', 'series'])
@@ -198,7 +203,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
198
203
  }),
199
204
  /**
200
205
  * Indicate which axis to display the top of the charts.
201
- * Can be a string (the id of the axis) or an object `ChartsXAxisProps`
206
+ * Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
202
207
  * @default null
203
208
  */
204
209
  topAxis: PropTypes.oneOfType([PropTypes.shape({
@@ -225,15 +230,17 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
225
230
  axisId: PropTypes.string,
226
231
  classes: PropTypes.object,
227
232
  data: PropTypes.array,
233
+ dataKey: PropTypes.string,
228
234
  disableLine: PropTypes.bool,
229
235
  disableTicks: PropTypes.bool,
230
236
  fill: PropTypes.string,
237
+ hideTooltip: PropTypes.bool,
231
238
  id: PropTypes.string,
232
239
  label: PropTypes.string,
233
240
  labelFontSize: PropTypes.number,
234
- max: PropTypes.number,
241
+ max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
235
242
  maxTicks: PropTypes.number,
236
- min: PropTypes.number,
243
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
237
244
  minTicks: PropTypes.number,
238
245
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
239
246
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
@@ -247,15 +254,17 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
247
254
  axisId: PropTypes.string,
248
255
  classes: PropTypes.object,
249
256
  data: PropTypes.array,
257
+ dataKey: PropTypes.string,
250
258
  disableLine: PropTypes.bool,
251
259
  disableTicks: PropTypes.bool,
252
260
  fill: PropTypes.string,
261
+ hideTooltip: PropTypes.bool,
253
262
  id: PropTypes.string,
254
263
  label: PropTypes.string,
255
264
  labelFontSize: PropTypes.number,
256
- max: PropTypes.number,
265
+ max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
257
266
  maxTicks: PropTypes.number,
258
- min: PropTypes.number,
267
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
259
268
  minTicks: PropTypes.number,
260
269
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
261
270
  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
  var seriesData = React.useContext(SeriesContext).line;
11
12
  var axisData = React.useContext(CartesianContext);
12
13
  if (seriesData === undefined) {
@@ -20,7 +21,7 @@ export function LinePlot() {
20
21
  yAxisIds = axisData.yAxisIds;
21
22
  var defaultXAxisId = xAxisIds[0];
22
23
  var defaultYAxisId = yAxisIds[0];
23
- return /*#__PURE__*/_jsx("g", {
24
+ return /*#__PURE__*/_jsx("g", _extends({}, props, {
24
25
  children: stackingGroups.flatMap(function (_ref) {
25
26
  var groupIds = _ref.ids;
26
27
  return groupIds.flatMap(function (seriesId) {
@@ -56,5 +57,5 @@ export function LinePlot() {
56
57
  }, seriesId);
57
58
  });
58
59
  })
59
- });
60
+ }));
60
61
  }
@@ -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,3 +1,4 @@
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';
3
4
  import { SeriesContext } from '../context/SeriesContextProvider';
@@ -5,7 +6,7 @@ import { CartesianContext } from '../context/CartesianContextProvider';
5
6
  import { MarkElement } from './MarkElement';
6
7
  import { getValueToPositionMapper } from '../hooks/useScale';
7
8
  import { jsx as _jsx } from "react/jsx-runtime";
8
- export function MarkPlot() {
9
+ export function MarkPlot(props) {
9
10
  var seriesData = React.useContext(SeriesContext).line;
10
11
  var axisData = React.useContext(CartesianContext);
11
12
  if (seriesData === undefined) {
@@ -19,7 +20,7 @@ export function MarkPlot() {
19
20
  yAxisIds = axisData.yAxisIds;
20
21
  var defaultXAxisId = xAxisIds[0];
21
22
  var defaultYAxisId = yAxisIds[0];
22
- return /*#__PURE__*/_jsx("g", {
23
+ return /*#__PURE__*/_jsx("g", _extends({}, props, {
23
24
  children: stackingGroups.flatMap(function (_ref) {
24
25
  var groupIds = _ref.ids;
25
26
  return groupIds.flatMap(function (seriesId) {
@@ -71,5 +72,5 @@ export function MarkPlot() {
71
72
  });
72
73
  });
73
74
  })
74
- });
75
+ }));
75
76
  }
@@ -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],
@@ -94,7 +94,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
94
94
  }),
95
95
  /**
96
96
  * Indicate which axis to display the bottom of the charts.
97
- * Can be a string (the id of the axis) or an object `ChartsXAxisProps`
97
+ * Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
98
98
  * @default xAxisIds[0] The id of the first provided axis
99
99
  */
100
100
  bottomAxis: PropTypes.oneOfType([PropTypes.shape({
@@ -116,12 +116,13 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
116
116
  * Color palette used to colorize multiple series.
117
117
  */
118
118
  colors: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.func]),
119
+ dataset: PropTypes.arrayOf(PropTypes.object),
119
120
  desc: PropTypes.string,
120
121
  disableAxisListener: PropTypes.bool,
121
122
  height: PropTypes.number,
122
123
  /**
123
124
  * Indicate which axis to display the left of the charts.
124
- * Can be a string (the id of the axis) or an object `ChartsYAxisProps`
125
+ * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
125
126
  * @default yAxisIds[0] The id of the first provided axis
126
127
  */
127
128
  leftAxis: PropTypes.oneOfType([PropTypes.shape({
@@ -161,7 +162,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
161
162
  }),
162
163
  /**
163
164
  * Indicate which axis to display the right of the charts.
164
- * Can be a string (the id of the axis) or an object `ChartsYAxisProps`
165
+ * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
165
166
  * @default null
166
167
  */
167
168
  rightAxis: PropTypes.oneOfType([PropTypes.shape({
@@ -226,7 +227,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
226
227
  }),
227
228
  /**
228
229
  * Indicate which axis to display the top of the charts.
229
- * Can be a string (the id of the axis) or an object `ChartsXAxisProps`
230
+ * Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
230
231
  * @default null
231
232
  */
232
233
  topAxis: PropTypes.oneOfType([PropTypes.shape({
@@ -253,15 +254,17 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
253
254
  axisId: PropTypes.string,
254
255
  classes: PropTypes.object,
255
256
  data: PropTypes.array,
257
+ dataKey: PropTypes.string,
256
258
  disableLine: PropTypes.bool,
257
259
  disableTicks: PropTypes.bool,
258
260
  fill: PropTypes.string,
261
+ hideTooltip: PropTypes.bool,
259
262
  id: PropTypes.string,
260
263
  label: PropTypes.string,
261
264
  labelFontSize: PropTypes.number,
262
- max: PropTypes.number,
265
+ max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
263
266
  maxTicks: PropTypes.number,
264
- min: PropTypes.number,
267
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
265
268
  minTicks: PropTypes.number,
266
269
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
267
270
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
@@ -275,15 +278,17 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
275
278
  axisId: PropTypes.string,
276
279
  classes: PropTypes.object,
277
280
  data: PropTypes.array,
281
+ dataKey: PropTypes.string,
278
282
  disableLine: PropTypes.bool,
279
283
  disableTicks: PropTypes.bool,
280
284
  fill: PropTypes.string,
285
+ hideTooltip: PropTypes.bool,
281
286
  id: PropTypes.string,
282
287
  label: PropTypes.string,
283
288
  labelFontSize: PropTypes.number,
284
- max: PropTypes.number,
289
+ max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
285
290
  maxTicks: PropTypes.number,
286
- min: PropTypes.number,
291
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
287
292
  minTicks: PropTypes.number,
288
293
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
289
294
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),