@mui/x-charts 6.0.0-alpha.16 → 6.0.0-alpha.17
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/formatter.js +1 -1
- package/CHANGELOG.md +66 -0
- package/ChartsTooltip/ChartsAxisTooltipContent.js +27 -21
- package/LineChart/AreaPlot.js +11 -5
- package/LineChart/LineHighlightPlot.js +2 -1
- package/LineChart/LinePlot.js +10 -9
- package/LineChart/MarkPlot.js +28 -7
- package/LineChart/formatter.js +4 -3
- package/esm/BarChart/formatter.js +1 -1
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +27 -21
- package/esm/LineChart/AreaPlot.js +13 -6
- package/esm/LineChart/LineHighlightPlot.js +2 -1
- package/esm/LineChart/LinePlot.js +13 -14
- package/esm/LineChart/MarkPlot.js +28 -7
- package/esm/LineChart/formatter.js +7 -3
- package/esm/internals/components/ChartsText.js +2 -0
- package/index.js +1 -1
- package/internals/components/ChartsText.js +2 -0
- package/internals/defaultizeColor.d.ts +1 -1
- package/legacy/BarChart/formatter.js +1 -1
- package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +5 -1
- package/legacy/LineChart/AreaPlot.js +16 -7
- package/legacy/LineChart/LineHighlightPlot.js +2 -1
- package/legacy/LineChart/LinePlot.js +15 -12
- package/legacy/LineChart/MarkPlot.js +27 -7
- package/legacy/LineChart/formatter.js +7 -3
- package/legacy/index.js +1 -1
- package/legacy/internals/components/ChartsText.js +2 -0
- package/models/seriesType/line.d.ts +1 -1
- package/modern/BarChart/formatter.js +1 -1
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +27 -21
- package/modern/LineChart/AreaPlot.js +11 -5
- package/modern/LineChart/LineHighlightPlot.js +2 -1
- package/modern/LineChart/LinePlot.js +10 -9
- package/modern/LineChart/MarkPlot.js +28 -7
- package/modern/LineChart/formatter.js +4 -3
- package/modern/index.js +1 -1
- package/modern/internals/components/ChartsText.js +2 -0
- package/package.json +1 -1
package/BarChart/formatter.js
CHANGED
|
@@ -60,7 +60,7 @@ const formatter = (params, dataset) => {
|
|
|
60
60
|
return {
|
|
61
61
|
seriesOrder,
|
|
62
62
|
stackingGroups,
|
|
63
|
-
series: (0, _defaultizeValueFormatter.default)(completedSeries, v => v
|
|
63
|
+
series: (0, _defaultizeValueFormatter.default)(completedSeries, v => v?.toLocaleString())
|
|
64
64
|
};
|
|
65
65
|
};
|
|
66
66
|
var _default = exports.default = formatter;
|
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,72 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 6.17.0
|
|
7
|
+
|
|
8
|
+
_Oct 27, 2023_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 9 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- 🎁 The Tree View package is now officially stable!
|
|
13
|
+
|
|
14
|
+

|
|
15
|
+
|
|
16
|
+
- ✨ Improve the handling of non-numeric values by Data Grid aggregation
|
|
17
|
+
- 🚀 Support lines with different domains on the line charts
|
|
18
|
+
- 🐞 Bugfixes
|
|
19
|
+
- 📚 Documentation improvements
|
|
20
|
+
|
|
21
|
+
### Data Grid
|
|
22
|
+
|
|
23
|
+
#### `@mui/x-data-grid@6.17.0`
|
|
24
|
+
|
|
25
|
+
- [DataGrid] Allow custom debounce time for row positions calculation (#10708) @cherniavskii
|
|
26
|
+
- [DataGrid] Persist stable row index for focused row (#10674) @cherniavskii
|
|
27
|
+
|
|
28
|
+
#### `@mui/x-data-grid-pro@6.17.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
29
|
+
|
|
30
|
+
Same changes as in `@mui/x-data-grid@6.17.0`, plus:
|
|
31
|
+
|
|
32
|
+
- [DataGridPro] Fix `undefined` values passed to `valueFormatter` for tree leaf nodes (#10748) @cherniavskii
|
|
33
|
+
|
|
34
|
+
#### `@mui/x-data-grid-premium@6.17.0` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
35
|
+
|
|
36
|
+
Same changes as in `@mui/x-data-grid-pro@6.17.0`, plus:
|
|
37
|
+
|
|
38
|
+
- [DataGridPremium] Fix `avg` aggregation to ignore non-numeric values (#10787) @cherniavskii
|
|
39
|
+
- [DataGridPremium] Fix `size` aggregation to ignore `undefined` values (#10745) @cherniavskii
|
|
40
|
+
- [DataGridPremium] Fix `sum` aggregation to ignore non-numeric values (#10730) @cherniavskii
|
|
41
|
+
- [DataGridPremium] Fix cell selection throwing index error on second page and beyond (#10784) @MBilalShafi
|
|
42
|
+
|
|
43
|
+
### Date Pickers
|
|
44
|
+
|
|
45
|
+
#### `@mui/x-date-pickers@6.17.0`
|
|
46
|
+
|
|
47
|
+
- [fields] POC: Use `contentEditable` on `FakeTextField` (#10779) @flaviendelangle
|
|
48
|
+
- [pickers] Fix weekday label localization (#10809) @LukasTy
|
|
49
|
+
|
|
50
|
+
#### `@mui/x-date-pickers-pro@6.17.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
51
|
+
|
|
52
|
+
Same changes as in `@mui/x-date-pickers@6.17.0`.
|
|
53
|
+
|
|
54
|
+
### Charts / `@mui/x-charts@6.0.0-alpha.17`
|
|
55
|
+
|
|
56
|
+
- [charts] Fix text position in Safari (#10815) @lhilgert9
|
|
57
|
+
- [charts] Support lines with different domains (#10801) @alexfauquette
|
|
58
|
+
|
|
59
|
+
### Tree View / `@mui/x-tree-view@6.17.0`
|
|
60
|
+
|
|
61
|
+
No change
|
|
62
|
+
|
|
63
|
+
### Docs
|
|
64
|
+
|
|
65
|
+
- [docs] Correct editing related props' description (#10798) @MBilalShafi
|
|
66
|
+
- [docs] Fix RTL data grid demo (#10728) @oliviertassinari
|
|
67
|
+
- [docs] Fix unclosed warning (#10796) @flaviendelangle
|
|
68
|
+
- [docs] Improve performance of `Save and restore the state from external storage` recipe (#10811) @michelengelen
|
|
69
|
+
|
|
70
|
+
- [test] Add missing type on `cleanText` utility function (#10780) @flaviendelangle
|
|
71
|
+
|
|
6
72
|
## 6.16.3
|
|
7
73
|
|
|
8
74
|
_Oct 20, 2023_
|
|
@@ -49,27 +49,33 @@ function DefaultChartsAxisContent(props) {
|
|
|
49
49
|
label,
|
|
50
50
|
valueFormatter,
|
|
51
51
|
data
|
|
52
|
-
}) =>
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
52
|
+
}) => {
|
|
53
|
+
const formattedValue = valueFormatter(data[dataIndex]);
|
|
54
|
+
if (formattedValue == null) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ChartsTooltipTable.ChartsTooltipRow, {
|
|
58
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsTooltipTable.ChartsTooltipCell, {
|
|
59
|
+
className: classes.markCell,
|
|
60
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsTooltipTable.ChartsTooltipMark, {
|
|
61
|
+
ownerState: {
|
|
62
|
+
color
|
|
63
|
+
},
|
|
64
|
+
boxShadow: 1
|
|
65
|
+
})
|
|
66
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsTooltipTable.ChartsTooltipCell, {
|
|
67
|
+
className: classes.labelCell,
|
|
68
|
+
children: label ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
69
|
+
children: label
|
|
70
|
+
}) : null
|
|
71
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsTooltipTable.ChartsTooltipCell, {
|
|
72
|
+
className: classes.valueCell,
|
|
73
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
74
|
+
children: formattedValue
|
|
75
|
+
})
|
|
76
|
+
})]
|
|
77
|
+
}, id);
|
|
78
|
+
})
|
|
73
79
|
})]
|
|
74
80
|
})
|
|
75
81
|
});
|
package/LineChart/AreaPlot.js
CHANGED
|
@@ -61,20 +61,26 @@ function AreaPlot(props) {
|
|
|
61
61
|
const {
|
|
62
62
|
xAxisKey = defaultXAxisId,
|
|
63
63
|
yAxisKey = defaultYAxisId,
|
|
64
|
-
stackedData
|
|
64
|
+
stackedData,
|
|
65
|
+
data
|
|
65
66
|
} = series[seriesId];
|
|
66
67
|
const xScale = (0, _useScale.getValueToPositionMapper)(xAxis[xAxisKey].scale);
|
|
67
68
|
const yScale = yAxis[yAxisKey].scale;
|
|
68
69
|
const xData = xAxis[xAxisKey].data;
|
|
69
|
-
if (
|
|
70
|
-
|
|
70
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
71
|
+
if (xData === undefined) {
|
|
72
|
+
throw new Error(`Axis of id "${xAxisKey}" should have data property to be able to display a line plot.`);
|
|
73
|
+
}
|
|
74
|
+
if (xData.length < stackedData.length) {
|
|
75
|
+
throw new Error(`MUI: data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items)`);
|
|
76
|
+
}
|
|
71
77
|
}
|
|
72
|
-
const areaPath = (0, _d3Shape.area)().x(d => xScale(d.x)).y0(d => yScale(d.y[0])).y1(d => yScale(d.y[1]));
|
|
78
|
+
const areaPath = (0, _d3Shape.area)().x(d => xScale(d.x)).defined((_, i) => data[i] != null).y0(d => d.y && yScale(d.y[0])).y1(d => d.y && yScale(d.y[1]));
|
|
73
79
|
const curve = (0, _getCurve.default)(series[seriesId].curve);
|
|
74
80
|
const d3Data = xData?.map((x, index) => ({
|
|
75
81
|
x,
|
|
76
82
|
y: stackedData[index]
|
|
77
|
-
}));
|
|
83
|
+
})) ?? [];
|
|
78
84
|
return !!series[seriesId].area && /*#__PURE__*/(0, _jsxRuntime.jsx)(_AreaElement.AreaElement, {
|
|
79
85
|
id: seriesId,
|
|
80
86
|
d: areaPath.curve(curve)(d3Data) || undefined,
|
|
@@ -68,9 +68,10 @@ function LineHighlightPlot(props) {
|
|
|
68
68
|
xAxisKey = defaultXAxisId,
|
|
69
69
|
yAxisKey = defaultYAxisId,
|
|
70
70
|
stackedData,
|
|
71
|
+
data,
|
|
71
72
|
disableHighlight
|
|
72
73
|
} = series[seriesId];
|
|
73
|
-
if (disableHighlight) {
|
|
74
|
+
if (disableHighlight || data[highlightedIndex] == null) {
|
|
74
75
|
return null;
|
|
75
76
|
}
|
|
76
77
|
const xScale = (0, _useScale.getValueToPositionMapper)(xAxis[xAxisKey].scale);
|
package/LineChart/LinePlot.js
CHANGED
|
@@ -60,25 +60,26 @@ function LinePlot(props) {
|
|
|
60
60
|
const {
|
|
61
61
|
xAxisKey = defaultXAxisId,
|
|
62
62
|
yAxisKey = defaultYAxisId,
|
|
63
|
-
stackedData
|
|
63
|
+
stackedData,
|
|
64
|
+
data
|
|
64
65
|
} = series[seriesId];
|
|
65
66
|
const xScale = (0, _useScale.getValueToPositionMapper)(xAxis[xAxisKey].scale);
|
|
66
67
|
const yScale = yAxis[yAxisKey].scale;
|
|
67
68
|
const xData = xAxis[xAxisKey].data;
|
|
68
|
-
if (xData === undefined) {
|
|
69
|
-
throw new Error(`Axis of id "${xAxisKey}" should have data property to be able to display a line plot`);
|
|
70
|
-
}
|
|
71
|
-
const linePath = (0, _d3Shape.line)().x(d => xScale(d.x)).y(d => yScale(d.y[1]));
|
|
72
69
|
if (process.env.NODE_ENV !== 'production') {
|
|
73
|
-
if (xData
|
|
74
|
-
throw new Error(`
|
|
70
|
+
if (xData === undefined) {
|
|
71
|
+
throw new Error(`Axis of id "${xAxisKey}" should have data property to be able to display a line plot`);
|
|
72
|
+
}
|
|
73
|
+
if (xData.length < stackedData.length) {
|
|
74
|
+
throw new Error(`MUI: data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items)`);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
+
const linePath = (0, _d3Shape.line)().x(d => xScale(d.x)).defined((_, i) => data[i] != null).y(d => yScale(d.y[1]));
|
|
77
78
|
const curve = (0, _getCurve.default)(series[seriesId].curve);
|
|
78
79
|
const d3Data = xData?.map((x, index) => ({
|
|
79
80
|
x,
|
|
80
|
-
y: stackedData[index]
|
|
81
|
-
}));
|
|
81
|
+
y: stackedData[index]
|
|
82
|
+
})) ?? [];
|
|
82
83
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_LineElement.LineElement, {
|
|
83
84
|
id: seriesId,
|
|
84
85
|
d: linePath.curve(curve)(d3Data) || undefined,
|
package/LineChart/MarkPlot.js
CHANGED
|
@@ -60,6 +60,7 @@ function MarkPlot(props) {
|
|
|
60
60
|
xAxisKey = defaultXAxisId,
|
|
61
61
|
yAxisKey = defaultYAxisId,
|
|
62
62
|
stackedData,
|
|
63
|
+
data,
|
|
63
64
|
showMark = true
|
|
64
65
|
} = series[seriesId];
|
|
65
66
|
if (showMark === false) {
|
|
@@ -86,28 +87,48 @@ function MarkPlot(props) {
|
|
|
86
87
|
throw new Error(`Axis of id "${xAxisKey}" should have data property to be able to display a line plot`);
|
|
87
88
|
}
|
|
88
89
|
return xData?.map((x, index) => {
|
|
89
|
-
const
|
|
90
|
+
const value = data[index] == null ? null : stackedData[index][1];
|
|
90
91
|
return {
|
|
91
92
|
x: xScale(x),
|
|
92
|
-
y: yScale(
|
|
93
|
+
y: value === null ? null : yScale(value),
|
|
93
94
|
position: x,
|
|
94
|
-
value
|
|
95
|
+
value,
|
|
95
96
|
index
|
|
96
97
|
};
|
|
97
|
-
}).filter(
|
|
98
|
+
}).filter(({
|
|
98
99
|
x,
|
|
99
100
|
y,
|
|
100
101
|
index,
|
|
101
102
|
position,
|
|
102
103
|
value
|
|
103
104
|
}) => {
|
|
104
|
-
|
|
105
|
+
if (value === null || y === null) {
|
|
106
|
+
// Remove missing data point
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
if (!isInRange({
|
|
110
|
+
x,
|
|
111
|
+
y
|
|
112
|
+
})) {
|
|
113
|
+
// Remove out of range
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
if (showMark === true) {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
return showMark({
|
|
105
120
|
x,
|
|
106
121
|
y,
|
|
107
122
|
index,
|
|
108
123
|
position,
|
|
109
124
|
value
|
|
110
|
-
})
|
|
125
|
+
});
|
|
126
|
+
}).map(({
|
|
127
|
+
x,
|
|
128
|
+
y,
|
|
129
|
+
index
|
|
130
|
+
}) => {
|
|
131
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Mark, (0, _extends2.default)({
|
|
111
132
|
id: seriesId,
|
|
112
133
|
dataIndex: index,
|
|
113
134
|
shape: "circle",
|
|
@@ -115,7 +136,7 @@ function MarkPlot(props) {
|
|
|
115
136
|
x: x,
|
|
116
137
|
y: y,
|
|
117
138
|
highlightScope: series[seriesId].highlightScope
|
|
118
|
-
}, slotProps?.mark), `${seriesId}-${index}`)
|
|
139
|
+
}, slotProps?.mark), `${seriesId}-${index}`);
|
|
119
140
|
});
|
|
120
141
|
});
|
|
121
142
|
})
|
package/LineChart/formatter.js
CHANGED
|
@@ -31,7 +31,7 @@ const formatter = (params, dataset) => {
|
|
|
31
31
|
d3Dataset[index][id] = value;
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
|
-
} else if (dataset === undefined) {
|
|
34
|
+
} else if (dataset === undefined && process.env.NODE_ENV !== 'production') {
|
|
35
35
|
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'));
|
|
36
36
|
}
|
|
37
37
|
});
|
|
@@ -47,7 +47,8 @@ const formatter = (params, dataset) => {
|
|
|
47
47
|
// Use dataKey if needed and available
|
|
48
48
|
const dataKey = series[id].dataKey;
|
|
49
49
|
return series[id].data === undefined && dataKey !== undefined ? dataKey : id;
|
|
50
|
-
})).
|
|
50
|
+
})).value((d, key) => d[key] ?? 0) // defaultize null value to 0
|
|
51
|
+
.order(stackingOrder).offset(stackingOffset)(d3Dataset);
|
|
51
52
|
ids.forEach((id, index) => {
|
|
52
53
|
const dataKey = series[id].dataKey;
|
|
53
54
|
completedSeries[id] = (0, _extends2.default)({}, series[id], {
|
|
@@ -59,7 +60,7 @@ const formatter = (params, dataset) => {
|
|
|
59
60
|
return {
|
|
60
61
|
seriesOrder,
|
|
61
62
|
stackingGroups,
|
|
62
|
-
series: (0, _defaultizeValueFormatter.default)(completedSeries, v => v
|
|
63
|
+
series: (0, _defaultizeValueFormatter.default)(completedSeries, v => v?.toLocaleString())
|
|
63
64
|
};
|
|
64
65
|
};
|
|
65
66
|
var _default = exports.default = formatter;
|
|
@@ -53,7 +53,7 @@ const formatter = (params, dataset) => {
|
|
|
53
53
|
return {
|
|
54
54
|
seriesOrder,
|
|
55
55
|
stackingGroups,
|
|
56
|
-
series: defaultizeValueFormatter(completedSeries, v => v.toLocaleString())
|
|
56
|
+
series: defaultizeValueFormatter(completedSeries, v => v == null ? void 0 : v.toLocaleString())
|
|
57
57
|
};
|
|
58
58
|
};
|
|
59
59
|
export default formatter;
|
|
@@ -41,27 +41,33 @@ export function DefaultChartsAxisContent(props) {
|
|
|
41
41
|
label,
|
|
42
42
|
valueFormatter,
|
|
43
43
|
data
|
|
44
|
-
}) =>
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
44
|
+
}) => {
|
|
45
|
+
const formattedValue = valueFormatter(data[dataIndex]);
|
|
46
|
+
if (formattedValue == null) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
return /*#__PURE__*/_jsxs(ChartsTooltipRow, {
|
|
50
|
+
children: [/*#__PURE__*/_jsx(ChartsTooltipCell, {
|
|
51
|
+
className: classes.markCell,
|
|
52
|
+
children: /*#__PURE__*/_jsx(ChartsTooltipMark, {
|
|
53
|
+
ownerState: {
|
|
54
|
+
color
|
|
55
|
+
},
|
|
56
|
+
boxShadow: 1
|
|
57
|
+
})
|
|
58
|
+
}), /*#__PURE__*/_jsx(ChartsTooltipCell, {
|
|
59
|
+
className: classes.labelCell,
|
|
60
|
+
children: label ? /*#__PURE__*/_jsx(Typography, {
|
|
61
|
+
children: label
|
|
62
|
+
}) : null
|
|
63
|
+
}), /*#__PURE__*/_jsx(ChartsTooltipCell, {
|
|
64
|
+
className: classes.valueCell,
|
|
65
|
+
children: /*#__PURE__*/_jsx(Typography, {
|
|
66
|
+
children: formattedValue
|
|
67
|
+
})
|
|
68
|
+
})]
|
|
69
|
+
}, id);
|
|
70
|
+
})
|
|
65
71
|
})]
|
|
66
72
|
})
|
|
67
73
|
});
|
|
@@ -49,23 +49,30 @@ function AreaPlot(props) {
|
|
|
49
49
|
ids: groupIds
|
|
50
50
|
}) => {
|
|
51
51
|
return groupIds.flatMap(seriesId => {
|
|
52
|
+
var _xData$map;
|
|
52
53
|
const {
|
|
53
54
|
xAxisKey = defaultXAxisId,
|
|
54
55
|
yAxisKey = defaultYAxisId,
|
|
55
|
-
stackedData
|
|
56
|
+
stackedData,
|
|
57
|
+
data
|
|
56
58
|
} = series[seriesId];
|
|
57
59
|
const xScale = getValueToPositionMapper(xAxis[xAxisKey].scale);
|
|
58
60
|
const yScale = yAxis[yAxisKey].scale;
|
|
59
61
|
const xData = xAxis[xAxisKey].data;
|
|
60
|
-
if (
|
|
61
|
-
|
|
62
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
63
|
+
if (xData === undefined) {
|
|
64
|
+
throw new Error(`Axis of id "${xAxisKey}" should have data property to be able to display a line plot.`);
|
|
65
|
+
}
|
|
66
|
+
if (xData.length < stackedData.length) {
|
|
67
|
+
throw new Error(`MUI: data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items)`);
|
|
68
|
+
}
|
|
62
69
|
}
|
|
63
|
-
const areaPath = d3Area().x(d => xScale(d.x)).y0(d => yScale(d.y[0])).y1(d => yScale(d.y[1]));
|
|
70
|
+
const areaPath = d3Area().x(d => xScale(d.x)).defined((_, i) => data[i] != null).y0(d => d.y && yScale(d.y[0])).y1(d => d.y && yScale(d.y[1]));
|
|
64
71
|
const curve = getCurveFactory(series[seriesId].curve);
|
|
65
|
-
const d3Data = xData == null ? void 0 : xData.map((x, index) => ({
|
|
72
|
+
const d3Data = (_xData$map = xData == null ? void 0 : xData.map((x, index) => ({
|
|
66
73
|
x,
|
|
67
74
|
y: stackedData[index]
|
|
68
|
-
}));
|
|
75
|
+
}))) != null ? _xData$map : [];
|
|
69
76
|
return !!series[seriesId].area && /*#__PURE__*/_jsx(AreaElement, {
|
|
70
77
|
id: seriesId,
|
|
71
78
|
d: areaPath.curve(curve)(d3Data) || undefined,
|
|
@@ -60,9 +60,10 @@ function LineHighlightPlot(props) {
|
|
|
60
60
|
xAxisKey = defaultXAxisId,
|
|
61
61
|
yAxisKey = defaultYAxisId,
|
|
62
62
|
stackedData,
|
|
63
|
+
data,
|
|
63
64
|
disableHighlight
|
|
64
65
|
} = series[seriesId];
|
|
65
|
-
if (disableHighlight) {
|
|
66
|
+
if (disableHighlight || data[highlightedIndex] == null) {
|
|
66
67
|
return null;
|
|
67
68
|
}
|
|
68
69
|
const xScale = getValueToPositionMapper(xAxis[xAxisKey].scale);
|
|
@@ -48,31 +48,30 @@ function LinePlot(props) {
|
|
|
48
48
|
ids: groupIds
|
|
49
49
|
}) => {
|
|
50
50
|
return groupIds.flatMap(seriesId => {
|
|
51
|
+
var _xData$map;
|
|
51
52
|
const {
|
|
52
53
|
xAxisKey = defaultXAxisId,
|
|
53
54
|
yAxisKey = defaultYAxisId,
|
|
54
|
-
stackedData
|
|
55
|
+
stackedData,
|
|
56
|
+
data
|
|
55
57
|
} = series[seriesId];
|
|
56
58
|
const xScale = getValueToPositionMapper(xAxis[xAxisKey].scale);
|
|
57
59
|
const yScale = yAxis[yAxisKey].scale;
|
|
58
60
|
const xData = xAxis[xAxisKey].data;
|
|
59
|
-
if (xData === undefined) {
|
|
60
|
-
throw new Error(`Axis of id "${xAxisKey}" should have data property to be able to display a line plot`);
|
|
61
|
-
}
|
|
62
|
-
const linePath = d3Line().x(d => xScale(d.x)).y(d => yScale(d.y[1]));
|
|
63
61
|
if (process.env.NODE_ENV !== 'production') {
|
|
64
|
-
if (xData
|
|
65
|
-
throw new Error(`
|
|
62
|
+
if (xData === undefined) {
|
|
63
|
+
throw new Error(`Axis of id "${xAxisKey}" should have data property to be able to display a line plot`);
|
|
64
|
+
}
|
|
65
|
+
if (xData.length < stackedData.length) {
|
|
66
|
+
throw new Error(`MUI: data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items)`);
|
|
66
67
|
}
|
|
67
68
|
}
|
|
69
|
+
const linePath = d3Line().x(d => xScale(d.x)).defined((_, i) => data[i] != null).y(d => yScale(d.y[1]));
|
|
68
70
|
const curve = getCurveFactory(series[seriesId].curve);
|
|
69
|
-
const d3Data = xData == null ? void 0 : xData.map((x, index) => {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
y: (_stackedData$index = stackedData[index]) != null ? _stackedData$index : [0, 0]
|
|
74
|
-
};
|
|
75
|
-
});
|
|
71
|
+
const d3Data = (_xData$map = xData == null ? void 0 : xData.map((x, index) => ({
|
|
72
|
+
x,
|
|
73
|
+
y: stackedData[index]
|
|
74
|
+
}))) != null ? _xData$map : [];
|
|
76
75
|
return /*#__PURE__*/_jsx(LineElement, {
|
|
77
76
|
id: seriesId,
|
|
78
77
|
d: linePath.curve(curve)(d3Data) || undefined,
|
|
@@ -52,6 +52,7 @@ function MarkPlot(props) {
|
|
|
52
52
|
xAxisKey = defaultXAxisId,
|
|
53
53
|
yAxisKey = defaultYAxisId,
|
|
54
54
|
stackedData,
|
|
55
|
+
data,
|
|
55
56
|
showMark = true
|
|
56
57
|
} = series[seriesId];
|
|
57
58
|
if (showMark === false) {
|
|
@@ -78,28 +79,48 @@ function MarkPlot(props) {
|
|
|
78
79
|
throw new Error(`Axis of id "${xAxisKey}" should have data property to be able to display a line plot`);
|
|
79
80
|
}
|
|
80
81
|
return xData == null ? void 0 : xData.map((x, index) => {
|
|
81
|
-
const
|
|
82
|
+
const value = data[index] == null ? null : stackedData[index][1];
|
|
82
83
|
return {
|
|
83
84
|
x: xScale(x),
|
|
84
|
-
y: yScale(
|
|
85
|
+
y: value === null ? null : yScale(value),
|
|
85
86
|
position: x,
|
|
86
|
-
value
|
|
87
|
+
value,
|
|
87
88
|
index
|
|
88
89
|
};
|
|
89
|
-
}).filter(
|
|
90
|
+
}).filter(({
|
|
90
91
|
x,
|
|
91
92
|
y,
|
|
92
93
|
index,
|
|
93
94
|
position,
|
|
94
95
|
value
|
|
95
96
|
}) => {
|
|
96
|
-
|
|
97
|
+
if (value === null || y === null) {
|
|
98
|
+
// Remove missing data point
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
if (!isInRange({
|
|
102
|
+
x,
|
|
103
|
+
y
|
|
104
|
+
})) {
|
|
105
|
+
// Remove out of range
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
if (showMark === true) {
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
return showMark({
|
|
97
112
|
x,
|
|
98
113
|
y,
|
|
99
114
|
index,
|
|
100
115
|
position,
|
|
101
116
|
value
|
|
102
|
-
})
|
|
117
|
+
});
|
|
118
|
+
}).map(({
|
|
119
|
+
x,
|
|
120
|
+
y,
|
|
121
|
+
index
|
|
122
|
+
}) => {
|
|
123
|
+
return /*#__PURE__*/_jsx(Mark, _extends({
|
|
103
124
|
id: seriesId,
|
|
104
125
|
dataIndex: index,
|
|
105
126
|
shape: "circle",
|
|
@@ -107,7 +128,7 @@ function MarkPlot(props) {
|
|
|
107
128
|
x: x,
|
|
108
129
|
y: y,
|
|
109
130
|
highlightScope: series[seriesId].highlightScope
|
|
110
|
-
}, slotProps == null ? void 0 : slotProps.mark), `${seriesId}-${index}`)
|
|
131
|
+
}, slotProps == null ? void 0 : slotProps.mark), `${seriesId}-${index}`);
|
|
111
132
|
});
|
|
112
133
|
});
|
|
113
134
|
})
|
|
@@ -24,7 +24,7 @@ const formatter = (params, dataset) => {
|
|
|
24
24
|
d3Dataset[index][id] = value;
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
|
-
} else if (dataset === undefined) {
|
|
27
|
+
} else if (dataset === undefined && process.env.NODE_ENV !== 'production') {
|
|
28
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
29
|
}
|
|
30
30
|
});
|
|
@@ -40,7 +40,11 @@ const formatter = (params, dataset) => {
|
|
|
40
40
|
// Use dataKey if needed and available
|
|
41
41
|
const dataKey = series[id].dataKey;
|
|
42
42
|
return series[id].data === undefined && dataKey !== undefined ? dataKey : id;
|
|
43
|
-
})).
|
|
43
|
+
})).value((d, key) => {
|
|
44
|
+
var _d$key;
|
|
45
|
+
return (_d$key = d[key]) != null ? _d$key : 0;
|
|
46
|
+
}) // defaultize null value to 0
|
|
47
|
+
.order(stackingOrder).offset(stackingOffset)(d3Dataset);
|
|
44
48
|
ids.forEach((id, index) => {
|
|
45
49
|
const dataKey = series[id].dataKey;
|
|
46
50
|
completedSeries[id] = _extends({}, series[id], {
|
|
@@ -52,7 +56,7 @@ const formatter = (params, dataset) => {
|
|
|
52
56
|
return {
|
|
53
57
|
seriesOrder,
|
|
54
58
|
stackingGroups,
|
|
55
|
-
series: defaultizeValueFormatter(completedSeries, v => v.toLocaleString())
|
|
59
|
+
series: defaultizeValueFormatter(completedSeries, v => v == null ? void 0 : v.toLocaleString())
|
|
56
60
|
};
|
|
57
61
|
};
|
|
58
62
|
export default formatter;
|
|
@@ -69,6 +69,8 @@ export function ChartsText(props) {
|
|
|
69
69
|
children: wordsByLines.map((line, index) => /*#__PURE__*/_jsx("tspan", {
|
|
70
70
|
x: x,
|
|
71
71
|
dy: `${index === 0 ? startDy : wordsByLines[0].height}px`,
|
|
72
|
+
dominantBaseline: dominantBaseline // Propagated to fix Safari issue: https://github.com/mui/mui-x/issues/10808
|
|
73
|
+
,
|
|
72
74
|
children: line.text
|
|
73
75
|
}, index))
|
|
74
76
|
}));
|
package/index.js
CHANGED
|
@@ -79,6 +79,8 @@ function ChartsText(props) {
|
|
|
79
79
|
children: wordsByLines.map((line, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)("tspan", {
|
|
80
80
|
x: x,
|
|
81
81
|
dy: `${index === 0 ? startDy : wordsByLines[0].height}px`,
|
|
82
|
+
dominantBaseline: dominantBaseline // Propagated to fix Safari issue: https://github.com/mui/mui-x/issues/10808
|
|
83
|
+
,
|
|
82
84
|
children: line.text
|
|
83
85
|
}, index))
|
|
84
86
|
}));
|
|
@@ -51,7 +51,7 @@ export declare function defaultizeColor(series: AllSeriesType, seriesIndex: numb
|
|
|
51
51
|
stackOrder?: "reverse" | "none" | "appearance" | "ascending" | "descending" | "insideOut" | undefined;
|
|
52
52
|
} | {
|
|
53
53
|
type: "line";
|
|
54
|
-
data?: number[] | undefined;
|
|
54
|
+
data?: (number | null)[] | undefined;
|
|
55
55
|
dataKey?: string | undefined;
|
|
56
56
|
stack?: string | undefined;
|
|
57
57
|
area?: boolean | undefined;
|
|
@@ -57,7 +57,7 @@ var formatter = function formatter(params, dataset) {
|
|
|
57
57
|
seriesOrder: seriesOrder,
|
|
58
58
|
stackingGroups: stackingGroups,
|
|
59
59
|
series: defaultizeValueFormatter(completedSeries, function (v) {
|
|
60
|
-
return v.toLocaleString();
|
|
60
|
+
return v == null ? void 0 : v.toLocaleString();
|
|
61
61
|
})
|
|
62
62
|
};
|
|
63
63
|
};
|
|
@@ -41,6 +41,10 @@ export function DefaultChartsAxisContent(props) {
|
|
|
41
41
|
label = _ref.label,
|
|
42
42
|
valueFormatter = _ref.valueFormatter,
|
|
43
43
|
data = _ref.data;
|
|
44
|
+
var formattedValue = valueFormatter(data[dataIndex]);
|
|
45
|
+
if (formattedValue == null) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
44
48
|
return /*#__PURE__*/_jsxs(ChartsTooltipRow, {
|
|
45
49
|
children: [/*#__PURE__*/_jsx(ChartsTooltipCell, {
|
|
46
50
|
className: classes.markCell,
|
|
@@ -58,7 +62,7 @@ export function DefaultChartsAxisContent(props) {
|
|
|
58
62
|
}), /*#__PURE__*/_jsx(ChartsTooltipCell, {
|
|
59
63
|
className: classes.valueCell,
|
|
60
64
|
children: /*#__PURE__*/_jsx(Typography, {
|
|
61
|
-
children:
|
|
65
|
+
children: formattedValue
|
|
62
66
|
})
|
|
63
67
|
})]
|
|
64
68
|
}, id);
|
|
@@ -42,32 +42,41 @@ function AreaPlot(props) {
|
|
|
42
42
|
children: stackingGroups.flatMap(function (_ref) {
|
|
43
43
|
var groupIds = _ref.ids;
|
|
44
44
|
return groupIds.flatMap(function (seriesId) {
|
|
45
|
+
var _xData$map;
|
|
45
46
|
var _series$seriesId = series[seriesId],
|
|
46
47
|
_series$seriesId$xAxi = _series$seriesId.xAxisKey,
|
|
47
48
|
xAxisKey = _series$seriesId$xAxi === void 0 ? defaultXAxisId : _series$seriesId$xAxi,
|
|
48
49
|
_series$seriesId$yAxi = _series$seriesId.yAxisKey,
|
|
49
50
|
yAxisKey = _series$seriesId$yAxi === void 0 ? defaultYAxisId : _series$seriesId$yAxi,
|
|
50
|
-
stackedData = _series$seriesId.stackedData
|
|
51
|
+
stackedData = _series$seriesId.stackedData,
|
|
52
|
+
data = _series$seriesId.data;
|
|
51
53
|
var xScale = getValueToPositionMapper(xAxis[xAxisKey].scale);
|
|
52
54
|
var yScale = yAxis[yAxisKey].scale;
|
|
53
55
|
var xData = xAxis[xAxisKey].data;
|
|
54
|
-
if (
|
|
55
|
-
|
|
56
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
57
|
+
if (xData === undefined) {
|
|
58
|
+
throw new Error("Axis of id \"".concat(xAxisKey, "\" should have data property to be able to display a line plot."));
|
|
59
|
+
}
|
|
60
|
+
if (xData.length < stackedData.length) {
|
|
61
|
+
throw new Error("MUI: data length of the x axis (".concat(xData.length, " items) is lower than the length of series (").concat(stackedData.length, " items)"));
|
|
62
|
+
}
|
|
56
63
|
}
|
|
57
64
|
var areaPath = d3Area().x(function (d) {
|
|
58
65
|
return xScale(d.x);
|
|
66
|
+
}).defined(function (_, i) {
|
|
67
|
+
return data[i] != null;
|
|
59
68
|
}).y0(function (d) {
|
|
60
|
-
return yScale(d.y[0]);
|
|
69
|
+
return d.y && yScale(d.y[0]);
|
|
61
70
|
}).y1(function (d) {
|
|
62
|
-
return yScale(d.y[1]);
|
|
71
|
+
return d.y && yScale(d.y[1]);
|
|
63
72
|
});
|
|
64
73
|
var curve = getCurveFactory(series[seriesId].curve);
|
|
65
|
-
var d3Data = xData == null ? void 0 : xData.map(function (x, index) {
|
|
74
|
+
var d3Data = (_xData$map = xData == null ? void 0 : xData.map(function (x, index) {
|
|
66
75
|
return {
|
|
67
76
|
x: x,
|
|
68
77
|
y: stackedData[index]
|
|
69
78
|
};
|
|
70
|
-
});
|
|
79
|
+
})) != null ? _xData$map : [];
|
|
71
80
|
return !!series[seriesId].area && /*#__PURE__*/_jsx(AreaElement, {
|
|
72
81
|
id: seriesId,
|
|
73
82
|
d: areaPath.curve(curve)(d3Data) || undefined,
|
|
@@ -54,8 +54,9 @@ function LineHighlightPlot(props) {
|
|
|
54
54
|
_series$seriesId$yAxi = _series$seriesId.yAxisKey,
|
|
55
55
|
yAxisKey = _series$seriesId$yAxi === void 0 ? defaultYAxisId : _series$seriesId$yAxi,
|
|
56
56
|
stackedData = _series$seriesId.stackedData,
|
|
57
|
+
data = _series$seriesId.data,
|
|
57
58
|
disableHighlight = _series$seriesId.disableHighlight;
|
|
58
|
-
if (disableHighlight) {
|
|
59
|
+
if (disableHighlight || data[highlightedIndex] == null) {
|
|
59
60
|
return null;
|
|
60
61
|
}
|
|
61
62
|
var xScale = getValueToPositionMapper(xAxis[xAxisKey].scale);
|
|
@@ -41,36 +41,39 @@ function LinePlot(props) {
|
|
|
41
41
|
children: stackingGroups.flatMap(function (_ref) {
|
|
42
42
|
var groupIds = _ref.ids;
|
|
43
43
|
return groupIds.flatMap(function (seriesId) {
|
|
44
|
+
var _xData$map;
|
|
44
45
|
var _series$seriesId = series[seriesId],
|
|
45
46
|
_series$seriesId$xAxi = _series$seriesId.xAxisKey,
|
|
46
47
|
xAxisKey = _series$seriesId$xAxi === void 0 ? defaultXAxisId : _series$seriesId$xAxi,
|
|
47
48
|
_series$seriesId$yAxi = _series$seriesId.yAxisKey,
|
|
48
49
|
yAxisKey = _series$seriesId$yAxi === void 0 ? defaultYAxisId : _series$seriesId$yAxi,
|
|
49
|
-
stackedData = _series$seriesId.stackedData
|
|
50
|
+
stackedData = _series$seriesId.stackedData,
|
|
51
|
+
data = _series$seriesId.data;
|
|
50
52
|
var xScale = getValueToPositionMapper(xAxis[xAxisKey].scale);
|
|
51
53
|
var yScale = yAxis[yAxisKey].scale;
|
|
52
54
|
var xData = xAxis[xAxisKey].data;
|
|
53
|
-
if (
|
|
54
|
-
|
|
55
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
56
|
+
if (xData === undefined) {
|
|
57
|
+
throw new Error("Axis of id \"".concat(xAxisKey, "\" should have data property to be able to display a line plot"));
|
|
58
|
+
}
|
|
59
|
+
if (xData.length < stackedData.length) {
|
|
60
|
+
throw new Error("MUI: data length of the x axis (".concat(xData.length, " items) is lower than the length of series (").concat(stackedData.length, " items)"));
|
|
61
|
+
}
|
|
55
62
|
}
|
|
56
63
|
var linePath = d3Line().x(function (d) {
|
|
57
64
|
return xScale(d.x);
|
|
65
|
+
}).defined(function (_, i) {
|
|
66
|
+
return data[i] != null;
|
|
58
67
|
}).y(function (d) {
|
|
59
68
|
return yScale(d.y[1]);
|
|
60
69
|
});
|
|
61
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
62
|
-
if (xData.length !== stackedData.length) {
|
|
63
|
-
throw new Error("MUI: data length of the x axis (".concat(xData.length, " items) does not match length of series (").concat(stackedData.length, " items)"));
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
70
|
var curve = getCurveFactory(series[seriesId].curve);
|
|
67
|
-
var d3Data = xData == null ? void 0 : xData.map(function (x, index) {
|
|
68
|
-
var _stackedData$index;
|
|
71
|
+
var d3Data = (_xData$map = xData == null ? void 0 : xData.map(function (x, index) {
|
|
69
72
|
return {
|
|
70
73
|
x: x,
|
|
71
|
-
y:
|
|
74
|
+
y: stackedData[index]
|
|
72
75
|
};
|
|
73
|
-
});
|
|
76
|
+
})) != null ? _xData$map : [];
|
|
74
77
|
return /*#__PURE__*/_jsx(LineElement, {
|
|
75
78
|
id: seriesId,
|
|
76
79
|
d: linePath.curve(curve)(d3Data) || undefined,
|
|
@@ -48,6 +48,7 @@ function MarkPlot(props) {
|
|
|
48
48
|
_series$seriesId$yAxi = _series$seriesId.yAxisKey,
|
|
49
49
|
yAxisKey = _series$seriesId$yAxi === void 0 ? defaultYAxisId : _series$seriesId$yAxi,
|
|
50
50
|
stackedData = _series$seriesId.stackedData,
|
|
51
|
+
data = _series$seriesId.data,
|
|
51
52
|
_series$seriesId$show = _series$seriesId.showMark,
|
|
52
53
|
showMark = _series$seriesId$show === void 0 ? true : _series$seriesId$show;
|
|
53
54
|
if (showMark === false) {
|
|
@@ -73,27 +74,46 @@ function MarkPlot(props) {
|
|
|
73
74
|
throw new Error("Axis of id \"".concat(xAxisKey, "\" should have data property to be able to display a line plot"));
|
|
74
75
|
}
|
|
75
76
|
return xData == null ? void 0 : xData.map(function (x, index) {
|
|
76
|
-
var
|
|
77
|
+
var value = data[index] == null ? null : stackedData[index][1];
|
|
77
78
|
return {
|
|
78
79
|
x: xScale(x),
|
|
79
|
-
y: yScale(
|
|
80
|
+
y: value === null ? null : yScale(value),
|
|
80
81
|
position: x,
|
|
81
|
-
value:
|
|
82
|
+
value: value,
|
|
82
83
|
index: index
|
|
83
84
|
};
|
|
84
|
-
}).filter(
|
|
85
|
+
}).filter(function (_ref3) {
|
|
85
86
|
var x = _ref3.x,
|
|
86
87
|
y = _ref3.y,
|
|
87
88
|
index = _ref3.index,
|
|
88
89
|
position = _ref3.position,
|
|
89
90
|
value = _ref3.value;
|
|
90
|
-
|
|
91
|
+
if (value === null || y === null) {
|
|
92
|
+
// Remove missing data point
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
if (!isInRange({
|
|
96
|
+
x: x,
|
|
97
|
+
y: y
|
|
98
|
+
})) {
|
|
99
|
+
// Remove out of range
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
if (showMark === true) {
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
return showMark({
|
|
91
106
|
x: x,
|
|
92
107
|
y: y,
|
|
93
108
|
index: index,
|
|
94
109
|
position: position,
|
|
95
110
|
value: value
|
|
96
|
-
})
|
|
111
|
+
});
|
|
112
|
+
}).map(function (_ref4) {
|
|
113
|
+
var x = _ref4.x,
|
|
114
|
+
y = _ref4.y,
|
|
115
|
+
index = _ref4.index;
|
|
116
|
+
return /*#__PURE__*/_jsx(Mark, _extends({
|
|
97
117
|
id: seriesId,
|
|
98
118
|
dataIndex: index,
|
|
99
119
|
shape: "circle",
|
|
@@ -101,7 +121,7 @@ function MarkPlot(props) {
|
|
|
101
121
|
x: x,
|
|
102
122
|
y: y,
|
|
103
123
|
highlightScope: series[seriesId].highlightScope
|
|
104
|
-
}, slotProps == null ? void 0 : slotProps.mark), "".concat(seriesId, "-").concat(index))
|
|
124
|
+
}, slotProps == null ? void 0 : slotProps.mark), "".concat(seriesId, "-").concat(index));
|
|
105
125
|
});
|
|
106
126
|
});
|
|
107
127
|
})
|
|
@@ -22,7 +22,7 @@ var formatter = function formatter(params, dataset) {
|
|
|
22
22
|
d3Dataset[index][id] = value;
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
|
-
} else if (dataset === undefined) {
|
|
25
|
+
} else if (dataset === undefined && process.env.NODE_ENV !== 'production') {
|
|
26
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
27
|
}
|
|
28
28
|
});
|
|
@@ -36,7 +36,11 @@ var formatter = function formatter(params, dataset) {
|
|
|
36
36
|
// Use dataKey if needed and available
|
|
37
37
|
var dataKey = series[id].dataKey;
|
|
38
38
|
return series[id].data === undefined && dataKey !== undefined ? dataKey : id;
|
|
39
|
-
})).
|
|
39
|
+
})).value(function (d, key) {
|
|
40
|
+
var _d$key;
|
|
41
|
+
return (_d$key = d[key]) != null ? _d$key : 0;
|
|
42
|
+
}) // defaultize null value to 0
|
|
43
|
+
.order(stackingOrder).offset(stackingOffset)(d3Dataset);
|
|
40
44
|
ids.forEach(function (id, index) {
|
|
41
45
|
var dataKey = series[id].dataKey;
|
|
42
46
|
completedSeries[id] = _extends({}, series[id], {
|
|
@@ -56,7 +60,7 @@ var formatter = function formatter(params, dataset) {
|
|
|
56
60
|
seriesOrder: seriesOrder,
|
|
57
61
|
stackingGroups: stackingGroups,
|
|
58
62
|
series: defaultizeValueFormatter(completedSeries, function (v) {
|
|
59
|
-
return v.toLocaleString();
|
|
63
|
+
return v == null ? void 0 : v.toLocaleString();
|
|
60
64
|
})
|
|
61
65
|
};
|
|
62
66
|
};
|
package/legacy/index.js
CHANGED
|
@@ -70,6 +70,8 @@ export function ChartsText(props) {
|
|
|
70
70
|
return /*#__PURE__*/_jsx("tspan", {
|
|
71
71
|
x: x,
|
|
72
72
|
dy: "".concat(index === 0 ? startDy : wordsByLines[0].height, "px"),
|
|
73
|
+
dominantBaseline: dominantBaseline // Propagated to fix Safari issue: https://github.com/mui/mui-x/issues/10808
|
|
74
|
+
,
|
|
73
75
|
children: line.text
|
|
74
76
|
}, index);
|
|
75
77
|
})
|
|
@@ -53,7 +53,7 @@ const formatter = (params, dataset) => {
|
|
|
53
53
|
return {
|
|
54
54
|
seriesOrder,
|
|
55
55
|
stackingGroups,
|
|
56
|
-
series: defaultizeValueFormatter(completedSeries, v => v
|
|
56
|
+
series: defaultizeValueFormatter(completedSeries, v => v?.toLocaleString())
|
|
57
57
|
};
|
|
58
58
|
};
|
|
59
59
|
export default formatter;
|
|
@@ -40,27 +40,33 @@ export function DefaultChartsAxisContent(props) {
|
|
|
40
40
|
label,
|
|
41
41
|
valueFormatter,
|
|
42
42
|
data
|
|
43
|
-
}) =>
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
43
|
+
}) => {
|
|
44
|
+
const formattedValue = valueFormatter(data[dataIndex]);
|
|
45
|
+
if (formattedValue == null) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
return /*#__PURE__*/_jsxs(ChartsTooltipRow, {
|
|
49
|
+
children: [/*#__PURE__*/_jsx(ChartsTooltipCell, {
|
|
50
|
+
className: classes.markCell,
|
|
51
|
+
children: /*#__PURE__*/_jsx(ChartsTooltipMark, {
|
|
52
|
+
ownerState: {
|
|
53
|
+
color
|
|
54
|
+
},
|
|
55
|
+
boxShadow: 1
|
|
56
|
+
})
|
|
57
|
+
}), /*#__PURE__*/_jsx(ChartsTooltipCell, {
|
|
58
|
+
className: classes.labelCell,
|
|
59
|
+
children: label ? /*#__PURE__*/_jsx(Typography, {
|
|
60
|
+
children: label
|
|
61
|
+
}) : null
|
|
62
|
+
}), /*#__PURE__*/_jsx(ChartsTooltipCell, {
|
|
63
|
+
className: classes.valueCell,
|
|
64
|
+
children: /*#__PURE__*/_jsx(Typography, {
|
|
65
|
+
children: formattedValue
|
|
66
|
+
})
|
|
67
|
+
})]
|
|
68
|
+
}, id);
|
|
69
|
+
})
|
|
64
70
|
})]
|
|
65
71
|
})
|
|
66
72
|
});
|
|
@@ -52,20 +52,26 @@ function AreaPlot(props) {
|
|
|
52
52
|
const {
|
|
53
53
|
xAxisKey = defaultXAxisId,
|
|
54
54
|
yAxisKey = defaultYAxisId,
|
|
55
|
-
stackedData
|
|
55
|
+
stackedData,
|
|
56
|
+
data
|
|
56
57
|
} = series[seriesId];
|
|
57
58
|
const xScale = getValueToPositionMapper(xAxis[xAxisKey].scale);
|
|
58
59
|
const yScale = yAxis[yAxisKey].scale;
|
|
59
60
|
const xData = xAxis[xAxisKey].data;
|
|
60
|
-
if (
|
|
61
|
-
|
|
61
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
62
|
+
if (xData === undefined) {
|
|
63
|
+
throw new Error(`Axis of id "${xAxisKey}" should have data property to be able to display a line plot.`);
|
|
64
|
+
}
|
|
65
|
+
if (xData.length < stackedData.length) {
|
|
66
|
+
throw new Error(`MUI: data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items)`);
|
|
67
|
+
}
|
|
62
68
|
}
|
|
63
|
-
const areaPath = d3Area().x(d => xScale(d.x)).y0(d => yScale(d.y[0])).y1(d => yScale(d.y[1]));
|
|
69
|
+
const areaPath = d3Area().x(d => xScale(d.x)).defined((_, i) => data[i] != null).y0(d => d.y && yScale(d.y[0])).y1(d => d.y && yScale(d.y[1]));
|
|
64
70
|
const curve = getCurveFactory(series[seriesId].curve);
|
|
65
71
|
const d3Data = xData?.map((x, index) => ({
|
|
66
72
|
x,
|
|
67
73
|
y: stackedData[index]
|
|
68
|
-
}));
|
|
74
|
+
})) ?? [];
|
|
69
75
|
return !!series[seriesId].area && /*#__PURE__*/_jsx(AreaElement, {
|
|
70
76
|
id: seriesId,
|
|
71
77
|
d: areaPath.curve(curve)(d3Data) || undefined,
|
|
@@ -59,9 +59,10 @@ function LineHighlightPlot(props) {
|
|
|
59
59
|
xAxisKey = defaultXAxisId,
|
|
60
60
|
yAxisKey = defaultYAxisId,
|
|
61
61
|
stackedData,
|
|
62
|
+
data,
|
|
62
63
|
disableHighlight
|
|
63
64
|
} = series[seriesId];
|
|
64
|
-
if (disableHighlight) {
|
|
65
|
+
if (disableHighlight || data[highlightedIndex] == null) {
|
|
65
66
|
return null;
|
|
66
67
|
}
|
|
67
68
|
const xScale = getValueToPositionMapper(xAxis[xAxisKey].scale);
|
|
@@ -51,25 +51,26 @@ function LinePlot(props) {
|
|
|
51
51
|
const {
|
|
52
52
|
xAxisKey = defaultXAxisId,
|
|
53
53
|
yAxisKey = defaultYAxisId,
|
|
54
|
-
stackedData
|
|
54
|
+
stackedData,
|
|
55
|
+
data
|
|
55
56
|
} = series[seriesId];
|
|
56
57
|
const xScale = getValueToPositionMapper(xAxis[xAxisKey].scale);
|
|
57
58
|
const yScale = yAxis[yAxisKey].scale;
|
|
58
59
|
const xData = xAxis[xAxisKey].data;
|
|
59
|
-
if (xData === undefined) {
|
|
60
|
-
throw new Error(`Axis of id "${xAxisKey}" should have data property to be able to display a line plot`);
|
|
61
|
-
}
|
|
62
|
-
const linePath = d3Line().x(d => xScale(d.x)).y(d => yScale(d.y[1]));
|
|
63
60
|
if (process.env.NODE_ENV !== 'production') {
|
|
64
|
-
if (xData
|
|
65
|
-
throw new Error(`
|
|
61
|
+
if (xData === undefined) {
|
|
62
|
+
throw new Error(`Axis of id "${xAxisKey}" should have data property to be able to display a line plot`);
|
|
63
|
+
}
|
|
64
|
+
if (xData.length < stackedData.length) {
|
|
65
|
+
throw new Error(`MUI: data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items)`);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
+
const linePath = d3Line().x(d => xScale(d.x)).defined((_, i) => data[i] != null).y(d => yScale(d.y[1]));
|
|
68
69
|
const curve = getCurveFactory(series[seriesId].curve);
|
|
69
70
|
const d3Data = xData?.map((x, index) => ({
|
|
70
71
|
x,
|
|
71
|
-
y: stackedData[index]
|
|
72
|
-
}));
|
|
72
|
+
y: stackedData[index]
|
|
73
|
+
})) ?? [];
|
|
73
74
|
return /*#__PURE__*/_jsx(LineElement, {
|
|
74
75
|
id: seriesId,
|
|
75
76
|
d: linePath.curve(curve)(d3Data) || undefined,
|
|
@@ -51,6 +51,7 @@ function MarkPlot(props) {
|
|
|
51
51
|
xAxisKey = defaultXAxisId,
|
|
52
52
|
yAxisKey = defaultYAxisId,
|
|
53
53
|
stackedData,
|
|
54
|
+
data,
|
|
54
55
|
showMark = true
|
|
55
56
|
} = series[seriesId];
|
|
56
57
|
if (showMark === false) {
|
|
@@ -77,28 +78,48 @@ function MarkPlot(props) {
|
|
|
77
78
|
throw new Error(`Axis of id "${xAxisKey}" should have data property to be able to display a line plot`);
|
|
78
79
|
}
|
|
79
80
|
return xData?.map((x, index) => {
|
|
80
|
-
const
|
|
81
|
+
const value = data[index] == null ? null : stackedData[index][1];
|
|
81
82
|
return {
|
|
82
83
|
x: xScale(x),
|
|
83
|
-
y: yScale(
|
|
84
|
+
y: value === null ? null : yScale(value),
|
|
84
85
|
position: x,
|
|
85
|
-
value
|
|
86
|
+
value,
|
|
86
87
|
index
|
|
87
88
|
};
|
|
88
|
-
}).filter(
|
|
89
|
+
}).filter(({
|
|
89
90
|
x,
|
|
90
91
|
y,
|
|
91
92
|
index,
|
|
92
93
|
position,
|
|
93
94
|
value
|
|
94
95
|
}) => {
|
|
95
|
-
|
|
96
|
+
if (value === null || y === null) {
|
|
97
|
+
// Remove missing data point
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
if (!isInRange({
|
|
101
|
+
x,
|
|
102
|
+
y
|
|
103
|
+
})) {
|
|
104
|
+
// Remove out of range
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
if (showMark === true) {
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
return showMark({
|
|
96
111
|
x,
|
|
97
112
|
y,
|
|
98
113
|
index,
|
|
99
114
|
position,
|
|
100
115
|
value
|
|
101
|
-
})
|
|
116
|
+
});
|
|
117
|
+
}).map(({
|
|
118
|
+
x,
|
|
119
|
+
y,
|
|
120
|
+
index
|
|
121
|
+
}) => {
|
|
122
|
+
return /*#__PURE__*/_jsx(Mark, _extends({
|
|
102
123
|
id: seriesId,
|
|
103
124
|
dataIndex: index,
|
|
104
125
|
shape: "circle",
|
|
@@ -106,7 +127,7 @@ function MarkPlot(props) {
|
|
|
106
127
|
x: x,
|
|
107
128
|
y: y,
|
|
108
129
|
highlightScope: series[seriesId].highlightScope
|
|
109
|
-
}, slotProps?.mark), `${seriesId}-${index}`)
|
|
130
|
+
}, slotProps?.mark), `${seriesId}-${index}`);
|
|
110
131
|
});
|
|
111
132
|
});
|
|
112
133
|
})
|
|
@@ -24,7 +24,7 @@ const formatter = (params, dataset) => {
|
|
|
24
24
|
d3Dataset[index][id] = value;
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
|
-
} else if (dataset === undefined) {
|
|
27
|
+
} else if (dataset === undefined && process.env.NODE_ENV !== 'production') {
|
|
28
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
29
|
}
|
|
30
30
|
});
|
|
@@ -40,7 +40,8 @@ const formatter = (params, dataset) => {
|
|
|
40
40
|
// Use dataKey if needed and available
|
|
41
41
|
const dataKey = series[id].dataKey;
|
|
42
42
|
return series[id].data === undefined && dataKey !== undefined ? dataKey : id;
|
|
43
|
-
})).
|
|
43
|
+
})).value((d, key) => d[key] ?? 0) // defaultize null value to 0
|
|
44
|
+
.order(stackingOrder).offset(stackingOffset)(d3Dataset);
|
|
44
45
|
ids.forEach((id, index) => {
|
|
45
46
|
const dataKey = series[id].dataKey;
|
|
46
47
|
completedSeries[id] = _extends({}, series[id], {
|
|
@@ -52,7 +53,7 @@ const formatter = (params, dataset) => {
|
|
|
52
53
|
return {
|
|
53
54
|
seriesOrder,
|
|
54
55
|
stackingGroups,
|
|
55
|
-
series: defaultizeValueFormatter(completedSeries, v => v
|
|
56
|
+
series: defaultizeValueFormatter(completedSeries, v => v?.toLocaleString())
|
|
56
57
|
};
|
|
57
58
|
};
|
|
58
59
|
export default formatter;
|
package/modern/index.js
CHANGED
|
@@ -69,6 +69,8 @@ export function ChartsText(props) {
|
|
|
69
69
|
children: wordsByLines.map((line, index) => /*#__PURE__*/_jsx("tspan", {
|
|
70
70
|
x: x,
|
|
71
71
|
dy: `${index === 0 ? startDy : wordsByLines[0].height}px`,
|
|
72
|
+
dominantBaseline: dominantBaseline // Propagated to fix Safari issue: https://github.com/mui/mui-x/issues/10808
|
|
73
|
+
,
|
|
72
74
|
children: line.text
|
|
73
75
|
}, index))
|
|
74
76
|
}));
|