@mui/x-charts 6.0.0-alpha.5 → 6.0.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BarChart/BarChart.d.ts +18 -2
- package/BarChart/BarChart.js +74 -17
- package/BarChart/BarElement.d.ts +22 -0
- package/BarChart/BarElement.js +21 -10
- package/BarChart/BarPlot.d.ts +14 -1
- package/BarChart/BarPlot.js +23 -4
- package/BarChart/formatter.js +23 -12
- package/CHANGELOG.md +154 -0
- package/ChartContainer/index.js +3 -0
- package/ChartsAxis/ChartsAxis.d.ts +11 -1
- package/ChartsAxis/ChartsAxis.js +51 -6
- package/ChartsLegend/ChartsLegend.d.ts +25 -2
- package/ChartsLegend/ChartsLegend.js +49 -17
- package/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
- package/ChartsTooltip/ChartsTooltipTable.d.ts +2 -9
- package/ChartsXAxis/ChartsXAxis.js +44 -9
- package/ChartsYAxis/ChartsYAxis.js +44 -9
- package/LineChart/AreaElement.d.ts +22 -0
- package/LineChart/AreaElement.js +31 -11
- package/LineChart/AreaPlot.d.ts +14 -1
- package/LineChart/AreaPlot.js +32 -5
- package/LineChart/LineChart.d.ts +20 -2
- package/LineChart/LineChart.js +76 -16
- package/LineChart/LineElement.d.ts +22 -0
- package/LineChart/LineElement.js +31 -10
- package/LineChart/LinePlot.d.ts +14 -1
- package/LineChart/LinePlot.js +38 -6
- package/LineChart/MarkElement.js +1 -1
- package/LineChart/MarkPlot.d.ts +24 -1
- package/LineChart/MarkPlot.js +30 -6
- package/LineChart/formatter.js +23 -12
- package/PieChart/PieArcLabel.js +0 -1
- package/PieChart/PieChart.d.ts +14 -2
- package/PieChart/PieChart.js +60 -13
- package/PieChart/PiePlot.d.ts +27 -1
- package/PieChart/PiePlot.js +29 -6
- package/ScatterChart/ScatterChart.d.ts +18 -2
- package/ScatterChart/ScatterChart.js +64 -13
- package/ScatterChart/ScatterPlot.d.ts +24 -1
- package/ScatterChart/ScatterPlot.js +28 -4
- package/SparkLineChart/SparkLineChart.d.ts +73 -0
- package/SparkLineChart/SparkLineChart.js +218 -0
- package/SparkLineChart/index.d.ts +1 -0
- package/SparkLineChart/index.js +12 -0
- package/SparkLineChart/package.json +6 -0
- package/colorPalettes/colorPalettes.js +2 -2
- package/context/CartesianContextProvider.d.ts +3 -1
- package/context/CartesianContextProvider.js +50 -14
- package/context/SeriesContextProvider.d.ts +3 -2
- package/context/SeriesContextProvider.js +5 -3
- package/esm/BarChart/BarChart.js +77 -17
- package/esm/BarChart/BarElement.js +21 -11
- package/esm/BarChart/BarPlot.js +23 -4
- package/esm/BarChart/formatter.js +23 -12
- package/esm/ChartContainer/index.js +3 -0
- package/esm/ChartsAxis/ChartsAxis.js +51 -6
- package/esm/ChartsLegend/ChartsLegend.js +47 -14
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
- package/esm/ChartsXAxis/ChartsXAxis.js +45 -9
- package/esm/ChartsYAxis/ChartsYAxis.js +45 -9
- package/esm/LineChart/AreaElement.js +31 -11
- package/esm/LineChart/AreaPlot.js +33 -5
- package/esm/LineChart/LineChart.js +79 -16
- package/esm/LineChart/LineElement.js +31 -11
- package/esm/LineChart/LinePlot.js +45 -9
- package/esm/LineChart/MarkElement.js +1 -1
- package/esm/LineChart/MarkPlot.js +31 -6
- package/esm/LineChart/formatter.js +23 -13
- package/esm/PieChart/PieArcLabel.js +0 -1
- package/esm/PieChart/PieChart.js +60 -13
- package/esm/PieChart/PiePlot.js +31 -6
- package/esm/ScatterChart/ScatterChart.js +64 -13
- package/esm/ScatterChart/ScatterPlot.js +29 -4
- package/esm/SparkLineChart/SparkLineChart.js +210 -0
- package/esm/SparkLineChart/index.js +1 -0
- package/esm/colorPalettes/colorPalettes.js +2 -2
- package/esm/context/CartesianContextProvider.js +50 -14
- package/esm/context/SeriesContextProvider.js +5 -3
- package/esm/hooks/useTicks.js +9 -6
- package/esm/index.js +1 -0
- package/esm/internals/components/AxisSharedComponents.js +10 -10
- package/esm/models/index.js +3 -1
- package/hooks/useTicks.d.ts +20 -5
- package/hooks/useTicks.js +9 -6
- package/index.d.ts +1 -0
- package/index.js +12 -1
- package/internals/components/AxisSharedComponents.d.ts +4 -4
- package/internals/components/AxisSharedComponents.js +15 -15
- package/internals/defaultizeColor.d.ts +4 -2
- package/legacy/BarChart/BarChart.js +75 -17
- package/legacy/BarChart/BarElement.js +20 -10
- package/legacy/BarChart/BarPlot.js +23 -4
- package/legacy/BarChart/formatter.js +23 -10
- package/legacy/ChartContainer/index.js +3 -0
- package/legacy/ChartsAxis/ChartsAxis.js +51 -6
- package/legacy/ChartsLegend/ChartsLegend.js +46 -15
- package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
- package/legacy/ChartsXAxis/ChartsXAxis.js +45 -9
- package/legacy/ChartsYAxis/ChartsYAxis.js +45 -9
- package/legacy/LineChart/AreaElement.js +30 -10
- package/legacy/LineChart/AreaPlot.js +31 -5
- package/legacy/LineChart/LineChart.js +77 -16
- package/legacy/LineChart/LineElement.js +30 -10
- package/legacy/LineChart/LinePlot.js +38 -6
- package/legacy/LineChart/MarkElement.js +1 -1
- package/legacy/LineChart/MarkPlot.js +29 -6
- package/legacy/LineChart/formatter.js +23 -11
- package/legacy/PieChart/PieArcLabel.js +0 -1
- package/legacy/PieChart/PieChart.js +60 -13
- package/legacy/PieChart/PiePlot.js +29 -6
- package/legacy/ScatterChart/ScatterChart.js +64 -13
- package/legacy/ScatterChart/ScatterPlot.js +27 -4
- package/legacy/SparkLineChart/SparkLineChart.js +214 -0
- package/legacy/SparkLineChart/index.js +1 -0
- package/legacy/colorPalettes/colorPalettes.js +2 -2
- package/legacy/context/CartesianContextProvider.js +59 -15
- package/legacy/context/SeriesContextProvider.js +6 -4
- package/legacy/hooks/useTicks.js +9 -9
- package/legacy/index.js +2 -1
- package/legacy/internals/components/AxisSharedComponents.js +10 -10
- package/legacy/models/index.js +3 -1
- package/models/axis.d.ts +34 -3
- 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 +74 -17
- package/modern/BarChart/BarElement.js +20 -11
- package/modern/BarChart/BarPlot.js +23 -4
- package/modern/BarChart/formatter.js +23 -12
- package/modern/ChartContainer/index.js +3 -0
- package/modern/ChartsAxis/ChartsAxis.js +51 -6
- package/modern/ChartsLegend/ChartsLegend.js +46 -14
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
- package/modern/ChartsXAxis/ChartsXAxis.js +44 -9
- package/modern/ChartsYAxis/ChartsYAxis.js +44 -9
- package/modern/LineChart/AreaElement.js +30 -11
- package/modern/LineChart/AreaPlot.js +33 -5
- package/modern/LineChart/LineChart.js +76 -16
- package/modern/LineChart/LineElement.js +30 -11
- package/modern/LineChart/LinePlot.js +39 -6
- package/modern/LineChart/MarkElement.js +1 -1
- package/modern/LineChart/MarkPlot.js +30 -6
- package/modern/LineChart/formatter.js +23 -13
- package/modern/PieChart/PieArcLabel.js +0 -1
- package/modern/PieChart/PieChart.js +60 -13
- package/modern/PieChart/PiePlot.js +30 -6
- package/modern/ScatterChart/ScatterChart.js +64 -13
- package/modern/ScatterChart/ScatterPlot.js +28 -4
- package/modern/SparkLineChart/SparkLineChart.js +210 -0
- package/modern/SparkLineChart/index.js +1 -0
- package/modern/colorPalettes/colorPalettes.js +2 -2
- package/modern/context/CartesianContextProvider.js +50 -14
- package/modern/context/SeriesContextProvider.js +5 -3
- package/modern/hooks/useTicks.js +9 -6
- package/modern/index.js +2 -1
- package/modern/internals/components/AxisSharedComponents.js +10 -10
- package/modern/models/index.js +3 -1
- package/package.json +4 -2
- package/themeAugmentation/components.d.ts +0 -10
- package/themeAugmentation/overrides.d.ts +0 -2
|
@@ -23,6 +23,7 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
|
|
|
23
23
|
height,
|
|
24
24
|
margin,
|
|
25
25
|
colors,
|
|
26
|
+
dataset,
|
|
26
27
|
sx,
|
|
27
28
|
tooltip,
|
|
28
29
|
axisHighlight = {
|
|
@@ -33,7 +34,9 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
|
|
|
33
34
|
leftAxis,
|
|
34
35
|
rightAxis,
|
|
35
36
|
bottomAxis,
|
|
36
|
-
children
|
|
37
|
+
children,
|
|
38
|
+
slots,
|
|
39
|
+
slotProps
|
|
37
40
|
} = props;
|
|
38
41
|
const id = useId();
|
|
39
42
|
const clipPathId = `${id}-clip-path`;
|
|
@@ -49,22 +52,40 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
|
|
|
49
52
|
id: DEFAULT_X_AXIS_KEY,
|
|
50
53
|
scaleType: 'point',
|
|
51
54
|
data: Array.from({
|
|
52
|
-
length: Math.max(...series.map(s =>
|
|
55
|
+
length: Math.max(...series.map(s => {
|
|
56
|
+
var _ref, _s$data;
|
|
57
|
+
return ((_ref = (_s$data = s.data) != null ? _s$data : dataset) != null ? _ref : []).length;
|
|
58
|
+
}))
|
|
53
59
|
}, (_, index) => index)
|
|
54
60
|
}],
|
|
55
61
|
yAxis: yAxis,
|
|
56
62
|
colors: colors,
|
|
63
|
+
dataset: dataset,
|
|
57
64
|
sx: sx,
|
|
58
65
|
disableAxisListener: (tooltip == null ? void 0 : tooltip.trigger) !== 'axis' && (axisHighlight == null ? void 0 : axisHighlight.x) === 'none' && (axisHighlight == null ? void 0 : axisHighlight.y) === 'none',
|
|
59
66
|
children: [/*#__PURE__*/_jsxs("g", {
|
|
60
67
|
clipPath: `url(#${clipPathId})`,
|
|
61
|
-
children: [/*#__PURE__*/_jsx(AreaPlot, {
|
|
68
|
+
children: [/*#__PURE__*/_jsx(AreaPlot, {
|
|
69
|
+
slots: slots,
|
|
70
|
+
slotProps: slotProps
|
|
71
|
+
}), /*#__PURE__*/_jsx(LinePlot, {
|
|
72
|
+
slots: slots,
|
|
73
|
+
slotProps: slotProps
|
|
74
|
+
})]
|
|
62
75
|
}), /*#__PURE__*/_jsx(ChartsAxis, {
|
|
63
76
|
topAxis: topAxis,
|
|
64
77
|
leftAxis: leftAxis,
|
|
65
78
|
rightAxis: rightAxis,
|
|
66
|
-
bottomAxis: bottomAxis
|
|
67
|
-
|
|
79
|
+
bottomAxis: bottomAxis,
|
|
80
|
+
slots: slots,
|
|
81
|
+
slotProps: slotProps
|
|
82
|
+
}), /*#__PURE__*/_jsx(MarkPlot, {
|
|
83
|
+
slots: slots,
|
|
84
|
+
slotProps: slotProps
|
|
85
|
+
}), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend, {
|
|
86
|
+
slots: slots,
|
|
87
|
+
slotProps: slotProps
|
|
88
|
+
})), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlight)), /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip)), /*#__PURE__*/_jsx(ChartsClipPath, {
|
|
68
89
|
id: clipPathId
|
|
69
90
|
}), children]
|
|
70
91
|
});
|
|
@@ -92,8 +113,13 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
92
113
|
label: PropTypes.string,
|
|
93
114
|
labelFontSize: PropTypes.number,
|
|
94
115
|
position: PropTypes.oneOf(['bottom', 'top']),
|
|
116
|
+
slotProps: PropTypes.object,
|
|
117
|
+
slots: PropTypes.object,
|
|
95
118
|
stroke: PropTypes.string,
|
|
96
119
|
tickFontSize: PropTypes.number,
|
|
120
|
+
tickMaxStep: PropTypes.number,
|
|
121
|
+
tickMinStep: PropTypes.number,
|
|
122
|
+
tickNumber: PropTypes.number,
|
|
97
123
|
tickSize: PropTypes.number
|
|
98
124
|
}), PropTypes.string]),
|
|
99
125
|
children: PropTypes.node,
|
|
@@ -102,6 +128,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
102
128
|
* Color palette used to colorize multiple series.
|
|
103
129
|
*/
|
|
104
130
|
colors: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.func]),
|
|
131
|
+
dataset: PropTypes.arrayOf(PropTypes.object),
|
|
105
132
|
desc: PropTypes.string,
|
|
106
133
|
disableAxisListener: PropTypes.bool,
|
|
107
134
|
height: PropTypes.number,
|
|
@@ -119,8 +146,13 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
119
146
|
label: PropTypes.string,
|
|
120
147
|
labelFontSize: PropTypes.number,
|
|
121
148
|
position: PropTypes.oneOf(['left', 'right']),
|
|
149
|
+
slotProps: PropTypes.object,
|
|
150
|
+
slots: PropTypes.object,
|
|
122
151
|
stroke: PropTypes.string,
|
|
123
152
|
tickFontSize: PropTypes.number,
|
|
153
|
+
tickMaxStep: PropTypes.number,
|
|
154
|
+
tickMinStep: PropTypes.number,
|
|
155
|
+
tickNumber: PropTypes.number,
|
|
124
156
|
tickSize: PropTypes.number
|
|
125
157
|
}), PropTypes.string]),
|
|
126
158
|
legend: PropTypes.shape({
|
|
@@ -137,6 +169,8 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
137
169
|
horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
|
|
138
170
|
vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
|
|
139
171
|
}),
|
|
172
|
+
slotProps: PropTypes.object,
|
|
173
|
+
slots: PropTypes.object,
|
|
140
174
|
spacing: PropTypes.number
|
|
141
175
|
}),
|
|
142
176
|
margin: PropTypes.shape({
|
|
@@ -159,15 +193,21 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
159
193
|
label: PropTypes.string,
|
|
160
194
|
labelFontSize: PropTypes.number,
|
|
161
195
|
position: PropTypes.oneOf(['left', 'right']),
|
|
196
|
+
slotProps: PropTypes.object,
|
|
197
|
+
slots: PropTypes.object,
|
|
162
198
|
stroke: PropTypes.string,
|
|
163
199
|
tickFontSize: PropTypes.number,
|
|
200
|
+
tickMaxStep: PropTypes.number,
|
|
201
|
+
tickMinStep: PropTypes.number,
|
|
202
|
+
tickNumber: PropTypes.number,
|
|
164
203
|
tickSize: PropTypes.number
|
|
165
204
|
}), PropTypes.string]),
|
|
166
205
|
series: PropTypes.arrayOf(PropTypes.shape({
|
|
167
206
|
area: PropTypes.bool,
|
|
168
207
|
color: PropTypes.string,
|
|
169
208
|
curve: PropTypes.oneOf(['catmullRom', 'linear', 'monotoneX', 'monotoneY', 'natural', 'step', 'stepAfter', 'stepBefore']),
|
|
170
|
-
data: PropTypes.arrayOf(PropTypes.number)
|
|
209
|
+
data: PropTypes.arrayOf(PropTypes.number),
|
|
210
|
+
dataKey: PropTypes.string,
|
|
171
211
|
highlightScope: PropTypes.shape({
|
|
172
212
|
faded: PropTypes.oneOf(['global', 'none', 'series']),
|
|
173
213
|
highlighted: PropTypes.oneOf(['item', 'none', 'series'])
|
|
@@ -182,6 +222,16 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
182
222
|
xAxisKey: PropTypes.string,
|
|
183
223
|
yAxisKey: PropTypes.string
|
|
184
224
|
})).isRequired,
|
|
225
|
+
/**
|
|
226
|
+
* The props used for each component slot.
|
|
227
|
+
* @default {}
|
|
228
|
+
*/
|
|
229
|
+
slotProps: PropTypes.object,
|
|
230
|
+
/**
|
|
231
|
+
* Overridable component slots.
|
|
232
|
+
* @default {}
|
|
233
|
+
*/
|
|
234
|
+
slots: PropTypes.object,
|
|
185
235
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
186
236
|
title: PropTypes.string,
|
|
187
237
|
tooltip: PropTypes.shape({
|
|
@@ -204,8 +254,13 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
204
254
|
label: PropTypes.string,
|
|
205
255
|
labelFontSize: PropTypes.number,
|
|
206
256
|
position: PropTypes.oneOf(['bottom', 'top']),
|
|
257
|
+
slotProps: PropTypes.object,
|
|
258
|
+
slots: PropTypes.object,
|
|
207
259
|
stroke: PropTypes.string,
|
|
208
260
|
tickFontSize: PropTypes.number,
|
|
261
|
+
tickMaxStep: PropTypes.number,
|
|
262
|
+
tickMinStep: PropTypes.number,
|
|
263
|
+
tickNumber: PropTypes.number,
|
|
209
264
|
tickSize: PropTypes.number
|
|
210
265
|
}), PropTypes.string]),
|
|
211
266
|
viewBox: PropTypes.shape({
|
|
@@ -219,44 +274,52 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
219
274
|
axisId: PropTypes.string,
|
|
220
275
|
classes: PropTypes.object,
|
|
221
276
|
data: PropTypes.array,
|
|
277
|
+
dataKey: PropTypes.string,
|
|
222
278
|
disableLine: PropTypes.bool,
|
|
223
279
|
disableTicks: PropTypes.bool,
|
|
224
280
|
fill: PropTypes.string,
|
|
281
|
+
hideTooltip: PropTypes.bool,
|
|
225
282
|
id: PropTypes.string,
|
|
226
283
|
label: PropTypes.string,
|
|
227
284
|
labelFontSize: PropTypes.number,
|
|
228
|
-
max: PropTypes.number,
|
|
229
|
-
|
|
230
|
-
min: PropTypes.number,
|
|
231
|
-
minTicks: PropTypes.number,
|
|
285
|
+
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
286
|
+
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
232
287
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
233
288
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
289
|
+
slotProps: PropTypes.object,
|
|
290
|
+
slots: PropTypes.object,
|
|
234
291
|
stroke: PropTypes.string,
|
|
235
292
|
tickFontSize: PropTypes.number,
|
|
293
|
+
tickMaxStep: PropTypes.number,
|
|
294
|
+
tickMinStep: PropTypes.number,
|
|
295
|
+
tickNumber: PropTypes.number,
|
|
236
296
|
tickSize: PropTypes.number,
|
|
237
|
-
tickSpacing: PropTypes.number,
|
|
238
297
|
valueFormatter: PropTypes.func
|
|
239
298
|
})),
|
|
240
299
|
yAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
241
300
|
axisId: PropTypes.string,
|
|
242
301
|
classes: PropTypes.object,
|
|
243
302
|
data: PropTypes.array,
|
|
303
|
+
dataKey: PropTypes.string,
|
|
244
304
|
disableLine: PropTypes.bool,
|
|
245
305
|
disableTicks: PropTypes.bool,
|
|
246
306
|
fill: PropTypes.string,
|
|
307
|
+
hideTooltip: PropTypes.bool,
|
|
247
308
|
id: PropTypes.string,
|
|
248
309
|
label: PropTypes.string,
|
|
249
310
|
labelFontSize: PropTypes.number,
|
|
250
|
-
max: PropTypes.number,
|
|
251
|
-
|
|
252
|
-
min: PropTypes.number,
|
|
253
|
-
minTicks: PropTypes.number,
|
|
311
|
+
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
312
|
+
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
254
313
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
255
314
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
315
|
+
slotProps: PropTypes.object,
|
|
316
|
+
slots: PropTypes.object,
|
|
256
317
|
stroke: PropTypes.string,
|
|
257
318
|
tickFontSize: PropTypes.number,
|
|
319
|
+
tickMaxStep: PropTypes.number,
|
|
320
|
+
tickMinStep: PropTypes.number,
|
|
321
|
+
tickNumber: PropTypes.number,
|
|
258
322
|
tickSize: PropTypes.number,
|
|
259
|
-
tickSpacing: PropTypes.number,
|
|
260
323
|
valueFormatter: PropTypes.func
|
|
261
324
|
}))
|
|
262
325
|
} : void 0;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["id", "classes", "color", "highlightScope"];
|
|
3
|
+
const _excluded = ["id", "classes", "color", "highlightScope", "slots", "slotProps"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { color as d3Color } from 'd3-color';
|
|
7
7
|
import composeClasses from '@mui/utils/composeClasses';
|
|
8
|
+
import { useSlotProps } from '@mui/base/utils';
|
|
8
9
|
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
9
10
|
import { styled } from '@mui/material/styles';
|
|
10
11
|
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
@@ -27,7 +28,7 @@ const useUtilityClasses = ownerState => {
|
|
|
27
28
|
};
|
|
28
29
|
return composeClasses(slots, getLineElementUtilityClass, classes);
|
|
29
30
|
};
|
|
30
|
-
const LineElementPath = styled('path', {
|
|
31
|
+
export const LineElementPath = styled('path', {
|
|
31
32
|
name: 'MuiLineElement',
|
|
32
33
|
slot: 'Root',
|
|
33
34
|
overridesResolver: (_, styles) => styles.root
|
|
@@ -57,11 +58,14 @@ LineElementPath.propTypes = {
|
|
|
57
58
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
58
59
|
};
|
|
59
60
|
function LineElement(props) {
|
|
61
|
+
var _slots$line;
|
|
60
62
|
const {
|
|
61
63
|
id,
|
|
62
64
|
classes: innerClasses,
|
|
63
65
|
color,
|
|
64
|
-
highlightScope
|
|
66
|
+
highlightScope,
|
|
67
|
+
slots,
|
|
68
|
+
slotProps
|
|
65
69
|
} = props,
|
|
66
70
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
67
71
|
const getInteractionItemProps = useInteractionItemProps(highlightScope);
|
|
@@ -84,13 +88,19 @@ function LineElement(props) {
|
|
|
84
88
|
isHighlighted
|
|
85
89
|
};
|
|
86
90
|
const classes = useUtilityClasses(ownerState);
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
const Line = (_slots$line = slots == null ? void 0 : slots.line) != null ? _slots$line : LineElementPath;
|
|
92
|
+
const lineProps = useSlotProps({
|
|
93
|
+
elementType: Line,
|
|
94
|
+
externalSlotProps: slotProps == null ? void 0 : slotProps.line,
|
|
95
|
+
additionalProps: _extends({}, other, getInteractionItemProps({
|
|
96
|
+
type: 'line',
|
|
97
|
+
seriesId: id
|
|
98
|
+
}), {
|
|
99
|
+
className: classes.root
|
|
100
|
+
}),
|
|
101
|
+
ownerState
|
|
102
|
+
});
|
|
103
|
+
return /*#__PURE__*/_jsx(Line, _extends({}, lineProps));
|
|
94
104
|
}
|
|
95
105
|
process.env.NODE_ENV !== "production" ? LineElement.propTypes = {
|
|
96
106
|
// ----------------------------- Warning --------------------------------
|
|
@@ -101,6 +111,16 @@ process.env.NODE_ENV !== "production" ? LineElement.propTypes = {
|
|
|
101
111
|
highlightScope: PropTypes.shape({
|
|
102
112
|
faded: PropTypes.oneOf(['global', 'none', 'series']),
|
|
103
113
|
highlighted: PropTypes.oneOf(['item', 'none', 'series'])
|
|
104
|
-
})
|
|
114
|
+
}),
|
|
115
|
+
/**
|
|
116
|
+
* The props used for each component slot.
|
|
117
|
+
* @default {}
|
|
118
|
+
*/
|
|
119
|
+
slotProps: PropTypes.object,
|
|
120
|
+
/**
|
|
121
|
+
* Overridable component slots.
|
|
122
|
+
* @default {}
|
|
123
|
+
*/
|
|
124
|
+
slots: PropTypes.object
|
|
105
125
|
} : void 0;
|
|
106
126
|
export { LineElement };
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["slots", "slotProps"];
|
|
1
4
|
import * as React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
2
6
|
import { line as d3Line } from 'd3-shape';
|
|
3
7
|
import { SeriesContext } from '../context/SeriesContextProvider';
|
|
4
8
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
@@ -6,7 +10,12 @@ import { LineElement } from './LineElement';
|
|
|
6
10
|
import { getValueToPositionMapper } from '../hooks/useScale';
|
|
7
11
|
import getCurveFactory from '../internals/getCurve';
|
|
8
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
-
|
|
13
|
+
function LinePlot(props) {
|
|
14
|
+
const {
|
|
15
|
+
slots,
|
|
16
|
+
slotProps
|
|
17
|
+
} = props,
|
|
18
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
10
19
|
const seriesData = React.useContext(SeriesContext).line;
|
|
11
20
|
const axisData = React.useContext(CartesianContext);
|
|
12
21
|
if (seriesData === undefined) {
|
|
@@ -24,7 +33,7 @@ export function LinePlot() {
|
|
|
24
33
|
} = axisData;
|
|
25
34
|
const defaultXAxisId = xAxisIds[0];
|
|
26
35
|
const defaultYAxisId = yAxisIds[0];
|
|
27
|
-
return /*#__PURE__*/_jsx("g", {
|
|
36
|
+
return /*#__PURE__*/_jsx("g", _extends({}, other, {
|
|
28
37
|
children: stackingGroups.flatMap(({
|
|
29
38
|
ids: groupIds
|
|
30
39
|
}) => {
|
|
@@ -41,18 +50,45 @@ export function LinePlot() {
|
|
|
41
50
|
throw new Error(`Axis of id "${xAxisKey}" should have data property to be able to display a line plot`);
|
|
42
51
|
}
|
|
43
52
|
const linePath = d3Line().x(d => xScale(d.x)).y(d => yScale(d.y[1]));
|
|
53
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
54
|
+
if (xData.length !== stackedData.length) {
|
|
55
|
+
throw new Error(`MUI: data length of the x axis (${xData.length} items) does not match length of series (${stackedData.length} items)`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
44
58
|
const curve = getCurveFactory(series[seriesId].curve);
|
|
45
|
-
const d3Data = xData == null ? void 0 : xData.map((x, index) =>
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
59
|
+
const d3Data = xData == null ? void 0 : xData.map((x, index) => {
|
|
60
|
+
var _stackedData$index;
|
|
61
|
+
return {
|
|
62
|
+
x,
|
|
63
|
+
y: (_stackedData$index = stackedData[index]) != null ? _stackedData$index : [0, 0]
|
|
64
|
+
};
|
|
65
|
+
});
|
|
49
66
|
return /*#__PURE__*/_jsx(LineElement, {
|
|
50
67
|
id: seriesId,
|
|
51
68
|
d: linePath.curve(curve)(d3Data) || undefined,
|
|
52
69
|
color: series[seriesId].color,
|
|
53
|
-
highlightScope: series[seriesId].highlightScope
|
|
70
|
+
highlightScope: series[seriesId].highlightScope,
|
|
71
|
+
slots: slots,
|
|
72
|
+
slotProps: slotProps
|
|
54
73
|
}, seriesId);
|
|
55
74
|
});
|
|
56
75
|
})
|
|
57
|
-
});
|
|
58
|
-
}
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
78
|
+
process.env.NODE_ENV !== "production" ? LinePlot.propTypes = {
|
|
79
|
+
// ----------------------------- Warning --------------------------------
|
|
80
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
81
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
82
|
+
// ----------------------------------------------------------------------
|
|
83
|
+
/**
|
|
84
|
+
* The props used for each component slot.
|
|
85
|
+
* @default {}
|
|
86
|
+
*/
|
|
87
|
+
slotProps: PropTypes.object,
|
|
88
|
+
/**
|
|
89
|
+
* Overridable component slots.
|
|
90
|
+
* @default {}
|
|
91
|
+
*/
|
|
92
|
+
slots: PropTypes.object
|
|
93
|
+
} : void 0;
|
|
94
|
+
export { LinePlot };
|
|
@@ -38,7 +38,7 @@ const MarkElementPath = styled('path', {
|
|
|
38
38
|
}) => ({
|
|
39
39
|
transform: `translate(${ownerState.x}px, ${ownerState.y}px)`,
|
|
40
40
|
transformOrigin: `${ownerState.x}px ${ownerState.y}px`,
|
|
41
|
-
fill:
|
|
41
|
+
fill: theme.palette.background.paper,
|
|
42
42
|
stroke: ownerState.color,
|
|
43
43
|
strokeWidth: 2,
|
|
44
44
|
'&.MuiMarkElement-highlighted': {
|
|
@@ -1,12 +1,20 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
1
2
|
import * as React from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
2
4
|
import { SeriesContext } from '../context/SeriesContextProvider';
|
|
3
5
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
4
6
|
import { MarkElement } from './MarkElement';
|
|
5
7
|
import { getValueToPositionMapper } from '../hooks/useScale';
|
|
6
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
-
|
|
9
|
+
function MarkPlot(props) {
|
|
10
|
+
var _slots$mark;
|
|
11
|
+
const {
|
|
12
|
+
slots,
|
|
13
|
+
slotProps
|
|
14
|
+
} = props;
|
|
8
15
|
const seriesData = React.useContext(SeriesContext).line;
|
|
9
16
|
const axisData = React.useContext(CartesianContext);
|
|
17
|
+
const Mark = (_slots$mark = slots == null ? void 0 : slots.mark) != null ? _slots$mark : MarkElement;
|
|
10
18
|
if (seriesData === undefined) {
|
|
11
19
|
return null;
|
|
12
20
|
}
|
|
@@ -22,7 +30,7 @@ export function MarkPlot() {
|
|
|
22
30
|
} = axisData;
|
|
23
31
|
const defaultXAxisId = xAxisIds[0];
|
|
24
32
|
const defaultYAxisId = yAxisIds[0];
|
|
25
|
-
return /*#__PURE__*/_jsx("g", {
|
|
33
|
+
return /*#__PURE__*/_jsx("g", _extends({}, props, {
|
|
26
34
|
children: stackingGroups.flatMap(({
|
|
27
35
|
ids: groupIds
|
|
28
36
|
}) => {
|
|
@@ -63,7 +71,7 @@ export function MarkPlot() {
|
|
|
63
71
|
x,
|
|
64
72
|
y,
|
|
65
73
|
index
|
|
66
|
-
}) => /*#__PURE__*/_jsx(
|
|
74
|
+
}) => /*#__PURE__*/_jsx(Mark, _extends({
|
|
67
75
|
id: seriesId,
|
|
68
76
|
dataIndex: index,
|
|
69
77
|
shape: "circle",
|
|
@@ -71,8 +79,25 @@ export function MarkPlot() {
|
|
|
71
79
|
x: x,
|
|
72
80
|
y: y,
|
|
73
81
|
highlightScope: series[seriesId].highlightScope
|
|
74
|
-
}, `${seriesId}-${index}`));
|
|
82
|
+
}, slotProps == null ? void 0 : slotProps.mark), `${seriesId}-${index}`));
|
|
75
83
|
});
|
|
76
84
|
})
|
|
77
|
-
});
|
|
78
|
-
}
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
87
|
+
process.env.NODE_ENV !== "production" ? MarkPlot.propTypes = {
|
|
88
|
+
// ----------------------------- Warning --------------------------------
|
|
89
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
90
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
91
|
+
// ----------------------------------------------------------------------
|
|
92
|
+
/**
|
|
93
|
+
* The props used for each component slot.
|
|
94
|
+
* @default {}
|
|
95
|
+
*/
|
|
96
|
+
slotProps: PropTypes.object,
|
|
97
|
+
/**
|
|
98
|
+
* Overridable component slots.
|
|
99
|
+
* @default {}
|
|
100
|
+
*/
|
|
101
|
+
slots: PropTypes.object
|
|
102
|
+
} : void 0;
|
|
103
|
+
export { MarkPlot };
|
|
@@ -2,9 +2,8 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import { stack as d3Stack } from 'd3-shape';
|
|
3
3
|
import { getStackingGroups } from '../internals/stackSeries';
|
|
4
4
|
import defaultizeValueFormatter from '../internals/defaultizeValueFormatter';
|
|
5
|
-
|
|
6
5
|
// For now it's a copy past of bar charts formatter, but maybe will diverge later
|
|
7
|
-
const formatter = params => {
|
|
6
|
+
const formatter = (params, dataset) => {
|
|
8
7
|
const {
|
|
9
8
|
seriesOrder,
|
|
10
9
|
series
|
|
@@ -12,17 +11,22 @@ const formatter = params => {
|
|
|
12
11
|
const stackingGroups = getStackingGroups(params);
|
|
13
12
|
|
|
14
13
|
// Create a data set with format adapted to d3
|
|
15
|
-
const d3Dataset = [];
|
|
14
|
+
const d3Dataset = dataset != null ? dataset : [];
|
|
16
15
|
seriesOrder.forEach(id => {
|
|
17
|
-
series[id].data
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
const data = series[id].data;
|
|
17
|
+
if (data !== undefined) {
|
|
18
|
+
data.forEach((value, index) => {
|
|
19
|
+
if (d3Dataset.length <= index) {
|
|
20
|
+
d3Dataset.push({
|
|
21
|
+
[id]: value
|
|
22
|
+
});
|
|
23
|
+
} else {
|
|
24
|
+
d3Dataset[index][id] = value;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
} else if (dataset === undefined) {
|
|
28
|
+
throw new Error([`MUI: line series with id='${id}' has no data.`, 'Either provide a data property to the series or use the dataset prop.'].join('\n'));
|
|
29
|
+
}
|
|
26
30
|
});
|
|
27
31
|
const completedSeries = {};
|
|
28
32
|
stackingGroups.forEach(stackingGroup => {
|
|
@@ -32,9 +36,15 @@ const formatter = params => {
|
|
|
32
36
|
stackingOrder,
|
|
33
37
|
stackingOffset
|
|
34
38
|
} = stackingGroup;
|
|
35
|
-
const stackedSeries = d3Stack().keys(ids
|
|
39
|
+
const stackedSeries = d3Stack().keys(ids.map(id => {
|
|
40
|
+
// Use dataKey if needed and available
|
|
41
|
+
const dataKey = series[id].dataKey;
|
|
42
|
+
return series[id].data === undefined && dataKey !== undefined ? dataKey : id;
|
|
43
|
+
})).order(stackingOrder).offset(stackingOffset)(d3Dataset);
|
|
36
44
|
ids.forEach((id, index) => {
|
|
45
|
+
const dataKey = series[id].dataKey;
|
|
37
46
|
completedSeries[id] = _extends({}, series[id], {
|
|
47
|
+
data: dataKey ? dataset.map(d => d[dataKey]) : series[id].data,
|
|
38
48
|
stackedData: stackedSeries[index].map(([a, b]) => [a, b])
|
|
39
49
|
});
|
|
40
50
|
});
|