@mui/x-charts 6.0.0-alpha.5 → 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.
- package/BarChart/BarChart.js +14 -6
- package/BarChart/formatter.js +23 -12
- package/CHANGELOG.md +92 -0
- package/ChartContainer/index.js +3 -0
- package/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
- package/LineChart/AreaPlot.d.ts +1 -1
- package/LineChart/AreaPlot.js +4 -3
- package/LineChart/LineChart.js +14 -6
- package/LineChart/LinePlot.d.ts +1 -1
- package/LineChart/LinePlot.js +4 -3
- package/LineChart/MarkElement.js +1 -1
- package/LineChart/MarkPlot.d.ts +1 -1
- package/LineChart/MarkPlot.js +5 -3
- package/LineChart/formatter.js +23 -12
- package/PieChart/PieChart.js +9 -4
- package/ScatterChart/ScatterChart.js +9 -4
- package/SparkLineChart/SparkLineChart.d.ts +55 -0
- package/SparkLineChart/SparkLineChart.js +195 -0
- package/SparkLineChart/index.d.ts +1 -0
- package/SparkLineChart/index.js +12 -0
- package/SparkLineChart/package.json +6 -0
- package/context/CartesianContextProvider.d.ts +3 -1
- package/context/CartesianContextProvider.js +36 -6
- package/context/SeriesContextProvider.d.ts +3 -2
- package/context/SeriesContextProvider.js +5 -3
- package/esm/BarChart/BarChart.js +17 -6
- package/esm/BarChart/formatter.js +23 -12
- package/esm/ChartContainer/index.js +3 -0
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
- package/esm/LineChart/AreaPlot.js +4 -3
- package/esm/LineChart/LineChart.js +17 -6
- package/esm/LineChart/LinePlot.js +4 -3
- package/esm/LineChart/MarkElement.js +1 -1
- package/esm/LineChart/MarkPlot.js +4 -3
- package/esm/LineChart/formatter.js +23 -13
- package/esm/PieChart/PieChart.js +9 -4
- package/esm/ScatterChart/ScatterChart.js +9 -4
- package/esm/SparkLineChart/SparkLineChart.js +187 -0
- package/esm/SparkLineChart/index.js +1 -0
- package/esm/context/CartesianContextProvider.js +36 -6
- package/esm/context/SeriesContextProvider.js +5 -3
- package/esm/index.js +1 -0
- package/esm/models/index.js +3 -1
- package/index.d.ts +1 -0
- package/index.js +12 -1
- package/internals/defaultizeColor.d.ts +4 -2
- package/legacy/BarChart/BarChart.js +15 -6
- package/legacy/BarChart/formatter.js +23 -10
- package/legacy/ChartContainer/index.js +3 -0
- package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
- package/legacy/LineChart/AreaPlot.js +4 -3
- package/legacy/LineChart/LineChart.js +15 -6
- package/legacy/LineChart/LinePlot.js +4 -3
- package/legacy/LineChart/MarkElement.js +1 -1
- package/legacy/LineChart/MarkPlot.js +4 -3
- package/legacy/LineChart/formatter.js +23 -11
- package/legacy/PieChart/PieChart.js +9 -4
- package/legacy/ScatterChart/ScatterChart.js +9 -4
- package/legacy/SparkLineChart/SparkLineChart.js +191 -0
- package/legacy/SparkLineChart/index.js +1 -0
- package/legacy/context/CartesianContextProvider.js +45 -7
- package/legacy/context/SeriesContextProvider.js +6 -4
- package/legacy/index.js +2 -1
- package/legacy/models/index.js +3 -1
- package/models/axis.d.ts +10 -2
- package/models/index.d.ts +2 -0
- package/models/index.js +11 -0
- package/models/seriesType/bar.d.ts +8 -1
- package/models/seriesType/common.d.ts +2 -2
- package/models/seriesType/config.d.ts +4 -1
- package/models/seriesType/line.d.ts +8 -1
- package/modern/BarChart/BarChart.js +14 -6
- package/modern/BarChart/formatter.js +23 -12
- package/modern/ChartContainer/index.js +3 -0
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
- package/modern/LineChart/AreaPlot.js +4 -3
- package/modern/LineChart/LineChart.js +14 -6
- package/modern/LineChart/LinePlot.js +4 -3
- package/modern/LineChart/MarkElement.js +1 -1
- package/modern/LineChart/MarkPlot.js +4 -3
- package/modern/LineChart/formatter.js +23 -13
- package/modern/PieChart/PieChart.js +9 -4
- package/modern/ScatterChart/ScatterChart.js +9 -4
- package/modern/SparkLineChart/SparkLineChart.js +187 -0
- package/modern/SparkLineChart/index.js +1 -0
- package/modern/context/CartesianContextProvider.js +36 -6
- package/modern/context/SeriesContextProvider.js +5 -3
- package/modern/index.js +2 -1
- package/modern/models/index.js +3 -1
- package/package.json +3 -1
|
@@ -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
|
|
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
|
|
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
|
-
|
|
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", {
|
|
@@ -105,6 +108,7 @@ 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,
|
|
@@ -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)
|
|
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'])
|
|
@@ -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
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
|
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, {
|
|
@@ -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
|
-
|
|
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", {
|
|
@@ -108,6 +111,7 @@ 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,
|
|
@@ -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)
|
|
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'])
|
|
@@ -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:
|
|
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
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
|
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],
|
|
@@ -116,6 +116,7 @@ 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,
|
|
@@ -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']),
|
|
@@ -86,6 +86,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
86
86
|
* Color palette used to colorize multiple series.
|
|
87
87
|
*/
|
|
88
88
|
colors: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.func]),
|
|
89
|
+
dataset: PropTypes.arrayOf(PropTypes.object),
|
|
89
90
|
desc: PropTypes.string,
|
|
90
91
|
disableAxisListener: PropTypes.bool,
|
|
91
92
|
height: PropTypes.number,
|
|
@@ -203,15 +204,17 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
203
204
|
axisId: PropTypes.string,
|
|
204
205
|
classes: PropTypes.object,
|
|
205
206
|
data: PropTypes.array,
|
|
207
|
+
dataKey: PropTypes.string,
|
|
206
208
|
disableLine: PropTypes.bool,
|
|
207
209
|
disableTicks: PropTypes.bool,
|
|
208
210
|
fill: PropTypes.string,
|
|
211
|
+
hideTooltip: PropTypes.bool,
|
|
209
212
|
id: PropTypes.string,
|
|
210
213
|
label: PropTypes.string,
|
|
211
214
|
labelFontSize: PropTypes.number,
|
|
212
|
-
max: PropTypes.number,
|
|
215
|
+
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
213
216
|
maxTicks: PropTypes.number,
|
|
214
|
-
min: PropTypes.number,
|
|
217
|
+
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
215
218
|
minTicks: PropTypes.number,
|
|
216
219
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
217
220
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
@@ -225,15 +228,17 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
225
228
|
axisId: PropTypes.string,
|
|
226
229
|
classes: PropTypes.object,
|
|
227
230
|
data: PropTypes.array,
|
|
231
|
+
dataKey: PropTypes.string,
|
|
228
232
|
disableLine: PropTypes.bool,
|
|
229
233
|
disableTicks: PropTypes.bool,
|
|
230
234
|
fill: PropTypes.string,
|
|
235
|
+
hideTooltip: PropTypes.bool,
|
|
231
236
|
id: PropTypes.string,
|
|
232
237
|
label: PropTypes.string,
|
|
233
238
|
labelFontSize: PropTypes.number,
|
|
234
|
-
max: PropTypes.number,
|
|
239
|
+
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
235
240
|
maxTicks: PropTypes.number,
|
|
236
|
-
min: PropTypes.number,
|
|
241
|
+
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
237
242
|
minTicks: PropTypes.number,
|
|
238
243
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
239
244
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|