@mui/x-charts 7.0.0-beta.1 → 7.0.0-beta.2
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 +10 -8
- package/BarChart/BarElement.d.ts +20 -13
- package/BarChart/BarElement.js +1 -0
- package/BarChart/BarPlot.d.ts +3 -5
- package/BarChart/BarPlot.js +9 -10
- package/CHANGELOG.md +159 -1
- package/ChartContainer/ChartContainer.js +6 -4
- package/ChartsAxis/ChartsAxis.js +4 -4
- package/ChartsLegend/ChartsLegend.d.ts +5 -54
- package/ChartsLegend/ChartsLegend.js +2 -307
- package/ChartsLegend/DefaultChartsLegend.d.ts +60 -0
- package/ChartsLegend/DefaultChartsLegend.js +294 -0
- package/ChartsLegend/index.d.ts +1 -0
- package/ChartsLegend/index.js +11 -0
- package/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
- package/ChartsReferenceLine/common.d.ts +2 -1
- package/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
- package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +1 -1
- package/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
- package/ChartsTooltip/utils.d.ts +1 -0
- package/ChartsTooltip/utils.js +7 -0
- package/ChartsXAxis/ChartsXAxis.js +13 -9
- package/ChartsYAxis/ChartsYAxis.js +1 -1
- package/LineChart/AnimatedArea.js +1 -1
- package/LineChart/AnimatedLine.js +1 -1
- package/LineChart/AreaElement.d.ts +2 -1
- package/LineChart/AreaElement.js +1 -1
- package/LineChart/LineChart.js +10 -8
- package/LineChart/LineElement.d.ts +2 -1
- package/LineChart/LineElement.js +1 -1
- package/LineChart/LineHighlightElement.d.ts +3 -2
- package/LineChart/LineHighlightElement.js +2 -1
- package/LineChart/MarkElement.d.ts +3 -2
- package/LineChart/MarkElement.js +1 -0
- package/PieChart/PieArc.d.ts +3 -2
- package/PieChart/PieArc.js +1 -0
- package/PieChart/PieArcLabel.d.ts +3 -2
- package/PieChart/PieArcLabel.js +1 -0
- package/PieChart/PieArcLabelPlot.js +1 -1
- package/PieChart/PieArcPlot.js +1 -1
- package/PieChart/PieChart.js +10 -8
- package/ResponsiveChartContainer/ResponsiveChartContainer.js +6 -4
- package/ScatterChart/ScatterChart.js +10 -8
- package/SparkLineChart/SparkLineChart.d.ts +1 -1
- package/SparkLineChart/SparkLineChart.js +5 -4
- package/context/CartesianContextProvider.js +8 -6
- package/esm/BarChart/BarChart.js +10 -8
- package/esm/BarChart/BarElement.js +1 -0
- package/esm/BarChart/BarPlot.js +8 -10
- package/esm/ChartContainer/ChartContainer.js +6 -4
- package/esm/ChartsAxis/ChartsAxis.js +4 -4
- package/esm/ChartsLegend/ChartsLegend.js +2 -307
- package/esm/ChartsLegend/DefaultChartsLegend.js +286 -0
- package/esm/ChartsLegend/index.js +1 -0
- package/esm/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
- package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -2
- package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
- package/esm/ChartsTooltip/utils.js +6 -0
- package/esm/ChartsXAxis/ChartsXAxis.js +13 -9
- package/esm/ChartsYAxis/ChartsYAxis.js +1 -1
- package/esm/LineChart/AnimatedArea.js +1 -1
- package/esm/LineChart/AnimatedLine.js +1 -1
- package/esm/LineChart/AreaElement.js +1 -1
- package/esm/LineChart/LineChart.js +10 -8
- package/esm/LineChart/LineElement.js +1 -1
- package/esm/LineChart/LineHighlightElement.js +2 -1
- package/esm/LineChart/MarkElement.js +1 -0
- package/esm/PieChart/PieArc.js +1 -0
- package/esm/PieChart/PieArcLabel.js +1 -0
- package/esm/PieChart/PieArcLabelPlot.js +1 -1
- package/esm/PieChart/PieArcPlot.js +1 -1
- package/esm/PieChart/PieChart.js +10 -8
- package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +6 -4
- package/esm/ScatterChart/ScatterChart.js +10 -8
- package/esm/SparkLineChart/SparkLineChart.js +5 -4
- package/esm/context/CartesianContextProvider.js +8 -6
- package/index.js +1 -1
- package/internals/defaultizeColor.d.ts +16 -16
- package/internals/defaultizeValueFormatter.d.ts +4 -7
- package/internals/stackSeries.d.ts +4 -7
- package/legacy/BarChart/BarChart.js +10 -8
- package/legacy/BarChart/BarElement.js +1 -0
- package/legacy/BarChart/BarPlot.js +10 -10
- package/legacy/ChartContainer/ChartContainer.js +6 -4
- package/legacy/ChartsAxis/ChartsAxis.js +4 -4
- package/legacy/ChartsLegend/ChartsLegend.js +2 -323
- package/legacy/ChartsLegend/DefaultChartsLegend.js +302 -0
- package/legacy/ChartsLegend/index.js +1 -0
- package/legacy/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
- package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
- package/legacy/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -2
- package/legacy/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
- package/legacy/ChartsTooltip/utils.js +6 -0
- package/legacy/ChartsXAxis/ChartsXAxis.js +12 -8
- package/legacy/ChartsYAxis/ChartsYAxis.js +1 -1
- package/legacy/LineChart/AnimatedArea.js +1 -1
- package/legacy/LineChart/AnimatedLine.js +1 -1
- package/legacy/LineChart/AreaElement.js +1 -1
- package/legacy/LineChart/LineChart.js +10 -8
- package/legacy/LineChart/LineElement.js +1 -1
- package/legacy/LineChart/LineHighlightElement.js +2 -1
- package/legacy/LineChart/MarkElement.js +1 -0
- package/legacy/PieChart/PieArc.js +1 -0
- package/legacy/PieChart/PieArcLabel.js +1 -0
- package/legacy/PieChart/PieArcLabelPlot.js +1 -1
- package/legacy/PieChart/PieArcPlot.js +1 -1
- package/legacy/PieChart/PieChart.js +10 -8
- package/legacy/ResponsiveChartContainer/ResponsiveChartContainer.js +6 -4
- package/legacy/ScatterChart/ScatterChart.js +10 -8
- package/legacy/SparkLineChart/SparkLineChart.js +6 -5
- package/legacy/context/CartesianContextProvider.js +8 -6
- package/legacy/index.js +1 -1
- package/models/axis.d.ts +7 -2
- package/models/seriesType/common.d.ts +2 -1
- package/models/seriesType/config.d.ts +7 -12
- package/models/seriesType/line.d.ts +2 -2
- package/models/seriesType/pie.d.ts +7 -3
- package/models/seriesType/scatter.d.ts +5 -2
- package/modern/BarChart/BarChart.js +10 -8
- package/modern/BarChart/BarElement.js +1 -0
- package/modern/BarChart/BarPlot.js +8 -10
- package/modern/ChartContainer/ChartContainer.js +6 -4
- package/modern/ChartsAxis/ChartsAxis.js +4 -4
- package/modern/ChartsLegend/ChartsLegend.js +2 -307
- package/modern/ChartsLegend/DefaultChartsLegend.js +286 -0
- package/modern/ChartsLegend/index.js +1 -0
- package/modern/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
- package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -2
- package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
- package/modern/ChartsTooltip/utils.js +6 -0
- package/modern/ChartsXAxis/ChartsXAxis.js +13 -9
- package/modern/ChartsYAxis/ChartsYAxis.js +1 -1
- package/modern/LineChart/AnimatedArea.js +1 -1
- package/modern/LineChart/AnimatedLine.js +1 -1
- package/modern/LineChart/AreaElement.js +1 -1
- package/modern/LineChart/LineChart.js +10 -8
- package/modern/LineChart/LineElement.js +1 -1
- package/modern/LineChart/LineHighlightElement.js +2 -1
- package/modern/LineChart/MarkElement.js +1 -0
- package/modern/PieChart/PieArc.js +1 -0
- package/modern/PieChart/PieArcLabel.js +1 -0
- package/modern/PieChart/PieArcLabelPlot.js +1 -1
- package/modern/PieChart/PieArcPlot.js +1 -1
- package/modern/PieChart/PieChart.js +10 -8
- package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +6 -4
- package/modern/ScatterChart/ScatterChart.js +10 -8
- package/modern/SparkLineChart/SparkLineChart.js +5 -4
- package/modern/context/CartesianContextProvider.js +8 -6
- package/modern/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,22 +1,15 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
-
var _excluded = ["rotate", "dominantBaseline"],
|
|
5
|
-
_excluded2 = ["label"];
|
|
6
2
|
import * as React from 'react';
|
|
7
3
|
import PropTypes from 'prop-types';
|
|
8
4
|
import { useSlotProps } from '@mui/base/utils';
|
|
9
|
-
import { NoSsr } from '@mui/base/NoSsr';
|
|
10
5
|
import { unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
11
|
-
import { useThemeProps, useTheme
|
|
6
|
+
import { useThemeProps, useTheme } from '@mui/material/styles';
|
|
12
7
|
import { DrawingContext } from '../context/DrawingProvider';
|
|
13
8
|
import { getSeriesToDisplay } from './utils';
|
|
14
9
|
import { SeriesContext } from '../context/SeriesContextProvider';
|
|
15
10
|
import { getLegendUtilityClass } from './chartsLegendClasses';
|
|
16
|
-
import {
|
|
17
|
-
import { getWordsByLines } from '../internals/getWordsByLines';
|
|
11
|
+
import { DefaultChartsLegend } from './DefaultChartsLegend';
|
|
18
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
20
13
|
var useUtilityClasses = function useUtilityClasses(ownerState) {
|
|
21
14
|
var classes = ownerState.classes,
|
|
22
15
|
direction = ownerState.direction;
|
|
@@ -28,13 +21,6 @@ var useUtilityClasses = function useUtilityClasses(ownerState) {
|
|
|
28
21
|
};
|
|
29
22
|
return composeClasses(slots, getLegendUtilityClass, classes);
|
|
30
23
|
};
|
|
31
|
-
export var ChartsLegendRoot = styled('g', {
|
|
32
|
-
name: 'MuiChartsLegend',
|
|
33
|
-
slot: 'Root',
|
|
34
|
-
overridesResolver: function overridesResolver(props, styles) {
|
|
35
|
-
return styles.root;
|
|
36
|
-
}
|
|
37
|
-
})({});
|
|
38
24
|
var defaultProps = {
|
|
39
25
|
position: {
|
|
40
26
|
horizontal: 'middle',
|
|
@@ -42,313 +28,6 @@ var defaultProps = {
|
|
|
42
28
|
},
|
|
43
29
|
direction: 'row'
|
|
44
30
|
};
|
|
45
|
-
/**
|
|
46
|
-
* Transforms number or partial padding object to a defaultized padding object.
|
|
47
|
-
*/
|
|
48
|
-
var getStandardizedPadding = function getStandardizedPadding(padding) {
|
|
49
|
-
if (typeof padding === 'number') {
|
|
50
|
-
return {
|
|
51
|
-
left: padding,
|
|
52
|
-
right: padding,
|
|
53
|
-
top: padding,
|
|
54
|
-
bottom: padding
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
return _extends({
|
|
58
|
-
left: 0,
|
|
59
|
-
right: 0,
|
|
60
|
-
top: 0,
|
|
61
|
-
bottom: 0
|
|
62
|
-
}, padding);
|
|
63
|
-
};
|
|
64
|
-
function DefaultChartsLegend(props) {
|
|
65
|
-
var hidden = props.hidden,
|
|
66
|
-
position = props.position,
|
|
67
|
-
direction = props.direction,
|
|
68
|
-
seriesToDisplay = props.seriesToDisplay,
|
|
69
|
-
drawingArea = props.drawingArea,
|
|
70
|
-
classes = props.classes,
|
|
71
|
-
_props$itemMarkWidth = props.itemMarkWidth,
|
|
72
|
-
itemMarkWidth = _props$itemMarkWidth === void 0 ? 20 : _props$itemMarkWidth,
|
|
73
|
-
_props$itemMarkHeight = props.itemMarkHeight,
|
|
74
|
-
itemMarkHeight = _props$itemMarkHeight === void 0 ? 20 : _props$itemMarkHeight,
|
|
75
|
-
_props$markGap = props.markGap,
|
|
76
|
-
markGap = _props$markGap === void 0 ? 5 : _props$markGap,
|
|
77
|
-
_props$itemGap = props.itemGap,
|
|
78
|
-
itemGap = _props$itemGap === void 0 ? 10 : _props$itemGap,
|
|
79
|
-
_props$padding = props.padding,
|
|
80
|
-
paddingProps = _props$padding === void 0 ? 10 : _props$padding,
|
|
81
|
-
inLabelStyle = props.labelStyle;
|
|
82
|
-
var theme = useTheme();
|
|
83
|
-
var labelStyle = React.useMemo(function () {
|
|
84
|
-
return _extends({}, theme.typography.subtitle1, {
|
|
85
|
-
color: 'inherit',
|
|
86
|
-
dominantBaseline: 'central',
|
|
87
|
-
textAnchor: 'start',
|
|
88
|
-
fill: (theme.vars || theme).palette.text.primary,
|
|
89
|
-
lineHeight: 1
|
|
90
|
-
}, inLabelStyle);
|
|
91
|
-
},
|
|
92
|
-
// To say to TS that the dominantBaseline and textAnchor are correct
|
|
93
|
-
[inLabelStyle, theme]);
|
|
94
|
-
var padding = React.useMemo(function () {
|
|
95
|
-
return getStandardizedPadding(paddingProps);
|
|
96
|
-
}, [paddingProps]);
|
|
97
|
-
var getItemSpace = React.useCallback(function (label) {
|
|
98
|
-
var inStyle = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
99
|
-
var rotate = inStyle.rotate,
|
|
100
|
-
dominantBaseline = inStyle.dominantBaseline,
|
|
101
|
-
style = _objectWithoutProperties(inStyle, _excluded);
|
|
102
|
-
var linesSize = getWordsByLines({
|
|
103
|
-
style: style,
|
|
104
|
-
needsComputation: true,
|
|
105
|
-
text: label
|
|
106
|
-
});
|
|
107
|
-
var innerSize = {
|
|
108
|
-
innerWidth: itemMarkWidth + markGap + Math.max.apply(Math, _toConsumableArray(linesSize.map(function (size) {
|
|
109
|
-
return size.width;
|
|
110
|
-
}))),
|
|
111
|
-
innerHeight: Math.max(itemMarkHeight, linesSize.length * linesSize[0].height)
|
|
112
|
-
};
|
|
113
|
-
return _extends({}, innerSize, {
|
|
114
|
-
outerWidth: innerSize.innerWidth + itemGap,
|
|
115
|
-
outerHeight: innerSize.innerHeight + itemGap
|
|
116
|
-
});
|
|
117
|
-
}, [itemGap, itemMarkHeight, itemMarkWidth, markGap]);
|
|
118
|
-
var totalWidth = drawingArea.left + drawingArea.width + drawingArea.right;
|
|
119
|
-
var totalHeight = drawingArea.top + drawingArea.height + drawingArea.bottom;
|
|
120
|
-
var availableWidth = totalWidth - padding.left - padding.right;
|
|
121
|
-
var availableHeight = totalHeight - padding.top - padding.bottom;
|
|
122
|
-
var seriesWithPosition = React.useMemo(function () {
|
|
123
|
-
// Start at 0, 0. Will be modified later by padding and position.
|
|
124
|
-
var x = 0;
|
|
125
|
-
var y = 0;
|
|
126
|
-
|
|
127
|
-
// total values used to align legend later.
|
|
128
|
-
var totalWidthUsed = 0;
|
|
129
|
-
var totalHeightUsed = 0;
|
|
130
|
-
var rowIndex = 0;
|
|
131
|
-
var rowMaxHeight = [0];
|
|
132
|
-
var seriesWithRawPosition = seriesToDisplay.map(function (_ref) {
|
|
133
|
-
var label = _ref.label,
|
|
134
|
-
other = _objectWithoutProperties(_ref, _excluded2);
|
|
135
|
-
var itemSpace = getItemSpace(label, labelStyle);
|
|
136
|
-
var rep = _extends({}, other, {
|
|
137
|
-
label: label,
|
|
138
|
-
positionX: x,
|
|
139
|
-
positionY: y,
|
|
140
|
-
innerHeight: itemSpace.innerHeight,
|
|
141
|
-
innerWidth: itemSpace.innerWidth,
|
|
142
|
-
outerHeight: itemSpace.outerHeight,
|
|
143
|
-
outerWidth: itemSpace.outerWidth,
|
|
144
|
-
rowIndex: rowIndex
|
|
145
|
-
});
|
|
146
|
-
if (direction === 'row') {
|
|
147
|
-
if (x + itemSpace.innerWidth > availableWidth) {
|
|
148
|
-
// This legend item would create overflow along the x-axis, so we start a new row.
|
|
149
|
-
x = 0;
|
|
150
|
-
y += rowMaxHeight[rowIndex];
|
|
151
|
-
rowIndex += 1;
|
|
152
|
-
if (rowMaxHeight.length <= rowIndex) {
|
|
153
|
-
rowMaxHeight.push(0);
|
|
154
|
-
}
|
|
155
|
-
rep.positionX = x;
|
|
156
|
-
rep.positionY = y;
|
|
157
|
-
rep.rowIndex = rowIndex;
|
|
158
|
-
}
|
|
159
|
-
totalWidthUsed = Math.max(totalWidthUsed, x + itemSpace.outerWidth);
|
|
160
|
-
totalHeightUsed = Math.max(totalHeightUsed, y + itemSpace.outerHeight);
|
|
161
|
-
rowMaxHeight[rowIndex] = Math.max(rowMaxHeight[rowIndex], itemSpace.outerHeight);
|
|
162
|
-
x += itemSpace.outerWidth;
|
|
163
|
-
}
|
|
164
|
-
if (direction === 'column') {
|
|
165
|
-
if (y + itemSpace.innerHeight > availableHeight) {
|
|
166
|
-
// This legend item would create overflow along the y-axis, so we start a new column.
|
|
167
|
-
x = totalWidthUsed + itemGap;
|
|
168
|
-
y = 0;
|
|
169
|
-
rowIndex = 0;
|
|
170
|
-
rep.positionX = x;
|
|
171
|
-
rep.positionY = y;
|
|
172
|
-
rep.rowIndex = rowIndex;
|
|
173
|
-
}
|
|
174
|
-
if (rowMaxHeight.length <= rowIndex) {
|
|
175
|
-
rowMaxHeight.push(0);
|
|
176
|
-
}
|
|
177
|
-
totalWidthUsed = Math.max(totalWidthUsed, x + itemSpace.outerWidth);
|
|
178
|
-
totalHeightUsed = Math.max(totalHeightUsed, y + itemSpace.outerHeight);
|
|
179
|
-
rowIndex += 1;
|
|
180
|
-
y += itemSpace.outerHeight;
|
|
181
|
-
}
|
|
182
|
-
return rep;
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
// Move the legend according to padding and position
|
|
186
|
-
var gapX = 0;
|
|
187
|
-
var gapY = 0;
|
|
188
|
-
switch (position.horizontal) {
|
|
189
|
-
case 'left':
|
|
190
|
-
gapX = padding.left;
|
|
191
|
-
break;
|
|
192
|
-
case 'right':
|
|
193
|
-
gapX = totalWidth - padding.right - totalWidthUsed;
|
|
194
|
-
break;
|
|
195
|
-
default:
|
|
196
|
-
gapX = (totalWidth - totalWidthUsed) / 2;
|
|
197
|
-
break;
|
|
198
|
-
}
|
|
199
|
-
switch (position.vertical) {
|
|
200
|
-
case 'top':
|
|
201
|
-
gapY = padding.top;
|
|
202
|
-
break;
|
|
203
|
-
case 'bottom':
|
|
204
|
-
gapY = totalHeight - padding.bottom - totalHeightUsed;
|
|
205
|
-
break;
|
|
206
|
-
default:
|
|
207
|
-
gapY = (totalHeight - totalHeightUsed) / 2;
|
|
208
|
-
break;
|
|
209
|
-
}
|
|
210
|
-
return seriesWithRawPosition.map(function (item) {
|
|
211
|
-
return _extends({}, item, {
|
|
212
|
-
// Add the gap due to the position
|
|
213
|
-
positionX: item.positionX + gapX,
|
|
214
|
-
// Add the gap due to the position
|
|
215
|
-
positionY: item.positionY + gapY + (direction === 'row' ? rowMaxHeight[item.rowIndex] / 2 // Get the center of the entire row
|
|
216
|
-
: item.outerHeight / 2) // Get the center of the item
|
|
217
|
-
});
|
|
218
|
-
});
|
|
219
|
-
}, [seriesToDisplay, position.horizontal, position.vertical, getItemSpace, labelStyle, direction, availableWidth, availableHeight, itemGap, padding.left, padding.right, padding.top, padding.bottom, totalWidth, totalHeight]);
|
|
220
|
-
if (hidden) {
|
|
221
|
-
return null;
|
|
222
|
-
}
|
|
223
|
-
return /*#__PURE__*/_jsx(NoSsr, {
|
|
224
|
-
children: /*#__PURE__*/_jsx(ChartsLegendRoot, {
|
|
225
|
-
className: classes.root,
|
|
226
|
-
children: seriesWithPosition.map(function (_ref2) {
|
|
227
|
-
var id = _ref2.id,
|
|
228
|
-
label = _ref2.label,
|
|
229
|
-
color = _ref2.color,
|
|
230
|
-
positionX = _ref2.positionX,
|
|
231
|
-
positionY = _ref2.positionY;
|
|
232
|
-
return /*#__PURE__*/_jsxs("g", {
|
|
233
|
-
className: classes.series,
|
|
234
|
-
transform: "translate(".concat(positionX, " ").concat(positionY, ")"),
|
|
235
|
-
children: [/*#__PURE__*/_jsx("rect", {
|
|
236
|
-
className: classes.mark,
|
|
237
|
-
y: -itemMarkHeight / 2,
|
|
238
|
-
width: itemMarkWidth,
|
|
239
|
-
height: itemMarkHeight,
|
|
240
|
-
fill: color
|
|
241
|
-
}), /*#__PURE__*/_jsx(ChartsText, {
|
|
242
|
-
style: labelStyle,
|
|
243
|
-
text: label,
|
|
244
|
-
x: itemMarkWidth + markGap,
|
|
245
|
-
y: 0
|
|
246
|
-
})]
|
|
247
|
-
}, id);
|
|
248
|
-
})
|
|
249
|
-
})
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
process.env.NODE_ENV !== "production" ? DefaultChartsLegend.propTypes = {
|
|
253
|
-
// ----------------------------- Warning --------------------------------
|
|
254
|
-
// | These PropTypes are generated from the TypeScript type definitions |
|
|
255
|
-
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
256
|
-
// ----------------------------------------------------------------------
|
|
257
|
-
/**
|
|
258
|
-
* Override or extend the styles applied to the component.
|
|
259
|
-
*/
|
|
260
|
-
classes: PropTypes.object.isRequired,
|
|
261
|
-
/**
|
|
262
|
-
* The direction of the legend layout.
|
|
263
|
-
* The default depends on the chart.
|
|
264
|
-
*/
|
|
265
|
-
direction: PropTypes.oneOf(['column', 'row']).isRequired,
|
|
266
|
-
drawingArea: PropTypes.shape({
|
|
267
|
-
bottom: PropTypes.number.isRequired,
|
|
268
|
-
height: PropTypes.number.isRequired,
|
|
269
|
-
left: PropTypes.number.isRequired,
|
|
270
|
-
right: PropTypes.number.isRequired,
|
|
271
|
-
top: PropTypes.number.isRequired,
|
|
272
|
-
width: PropTypes.number.isRequired
|
|
273
|
-
}).isRequired,
|
|
274
|
-
/**
|
|
275
|
-
* Set to true to hide the legend.
|
|
276
|
-
*/
|
|
277
|
-
hidden: PropTypes.bool,
|
|
278
|
-
/**
|
|
279
|
-
* Space between two legend items (in px).
|
|
280
|
-
* @default 10
|
|
281
|
-
*/
|
|
282
|
-
itemGap: PropTypes.number,
|
|
283
|
-
/**
|
|
284
|
-
* Height of the item mark (in px).
|
|
285
|
-
* @default 20
|
|
286
|
-
*/
|
|
287
|
-
itemMarkHeight: PropTypes.number,
|
|
288
|
-
/**
|
|
289
|
-
* Width of the item mark (in px).
|
|
290
|
-
* @default 20
|
|
291
|
-
*/
|
|
292
|
-
itemMarkWidth: PropTypes.number,
|
|
293
|
-
/**
|
|
294
|
-
* Style applied to legend labels.
|
|
295
|
-
* @default theme.typography.subtitle1
|
|
296
|
-
*/
|
|
297
|
-
labelStyle: PropTypes.object,
|
|
298
|
-
/**
|
|
299
|
-
* Space between the mark and the label (in px).
|
|
300
|
-
* @default 5
|
|
301
|
-
*/
|
|
302
|
-
markGap: PropTypes.number,
|
|
303
|
-
/**
|
|
304
|
-
* Legend padding (in px).
|
|
305
|
-
* Can either be a single number, or an object with top, left, bottom, right properties.
|
|
306
|
-
* @default 0
|
|
307
|
-
*/
|
|
308
|
-
padding: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
|
|
309
|
-
bottom: PropTypes.number,
|
|
310
|
-
left: PropTypes.number,
|
|
311
|
-
right: PropTypes.number,
|
|
312
|
-
top: PropTypes.number
|
|
313
|
-
})]),
|
|
314
|
-
position: PropTypes.shape({
|
|
315
|
-
horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
|
|
316
|
-
vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
|
|
317
|
-
}).isRequired,
|
|
318
|
-
series: PropTypes.shape({
|
|
319
|
-
bar: PropTypes.shape({
|
|
320
|
-
series: PropTypes.object.isRequired,
|
|
321
|
-
seriesOrder: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
322
|
-
stackingGroups: PropTypes.arrayOf(PropTypes.shape({
|
|
323
|
-
ids: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
324
|
-
stackingOffset: PropTypes.func.isRequired,
|
|
325
|
-
stackingOrder: PropTypes.func.isRequired
|
|
326
|
-
})).isRequired
|
|
327
|
-
}),
|
|
328
|
-
line: PropTypes.shape({
|
|
329
|
-
series: PropTypes.object.isRequired,
|
|
330
|
-
seriesOrder: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
331
|
-
stackingGroups: PropTypes.arrayOf(PropTypes.shape({
|
|
332
|
-
ids: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
333
|
-
stackingOffset: PropTypes.func.isRequired,
|
|
334
|
-
stackingOrder: PropTypes.func.isRequired
|
|
335
|
-
})).isRequired
|
|
336
|
-
}),
|
|
337
|
-
pie: PropTypes.shape({
|
|
338
|
-
series: PropTypes.object.isRequired,
|
|
339
|
-
seriesOrder: PropTypes.arrayOf(PropTypes.string).isRequired
|
|
340
|
-
}),
|
|
341
|
-
scatter: PropTypes.shape({
|
|
342
|
-
series: PropTypes.object.isRequired,
|
|
343
|
-
seriesOrder: PropTypes.arrayOf(PropTypes.string).isRequired
|
|
344
|
-
})
|
|
345
|
-
}).isRequired,
|
|
346
|
-
seriesToDisplay: PropTypes.arrayOf(PropTypes.shape({
|
|
347
|
-
color: PropTypes.string.isRequired,
|
|
348
|
-
id: PropTypes.string.isRequired,
|
|
349
|
-
label: PropTypes.string.isRequired
|
|
350
|
-
})).isRequired
|
|
351
|
-
} : void 0;
|
|
352
31
|
function ChartsLegend(inProps) {
|
|
353
32
|
var _slots$legend;
|
|
354
33
|
var props = useThemeProps({
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
var _excluded = ["rotate", "dominantBaseline"],
|
|
5
|
+
_excluded2 = ["label"];
|
|
6
|
+
import * as React from 'react';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import { NoSsr } from '@mui/base/NoSsr';
|
|
9
|
+
import { useTheme, styled } from '@mui/material/styles';
|
|
10
|
+
import { ChartsText } from '../ChartsText';
|
|
11
|
+
import { getWordsByLines } from '../internals/getWordsByLines';
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
export var ChartsLegendRoot = styled('g', {
|
|
15
|
+
name: 'MuiChartsLegend',
|
|
16
|
+
slot: 'Root',
|
|
17
|
+
overridesResolver: function overridesResolver(props, styles) {
|
|
18
|
+
return styles.root;
|
|
19
|
+
}
|
|
20
|
+
})({});
|
|
21
|
+
/**
|
|
22
|
+
* Transforms number or partial padding object to a defaultized padding object.
|
|
23
|
+
*/
|
|
24
|
+
var getStandardizedPadding = function getStandardizedPadding(padding) {
|
|
25
|
+
if (typeof padding === 'number') {
|
|
26
|
+
return {
|
|
27
|
+
left: padding,
|
|
28
|
+
right: padding,
|
|
29
|
+
top: padding,
|
|
30
|
+
bottom: padding
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return _extends({
|
|
34
|
+
left: 0,
|
|
35
|
+
right: 0,
|
|
36
|
+
top: 0,
|
|
37
|
+
bottom: 0
|
|
38
|
+
}, padding);
|
|
39
|
+
};
|
|
40
|
+
function DefaultChartsLegend(props) {
|
|
41
|
+
var hidden = props.hidden,
|
|
42
|
+
position = props.position,
|
|
43
|
+
direction = props.direction,
|
|
44
|
+
seriesToDisplay = props.seriesToDisplay,
|
|
45
|
+
drawingArea = props.drawingArea,
|
|
46
|
+
classes = props.classes,
|
|
47
|
+
_props$itemMarkWidth = props.itemMarkWidth,
|
|
48
|
+
itemMarkWidth = _props$itemMarkWidth === void 0 ? 20 : _props$itemMarkWidth,
|
|
49
|
+
_props$itemMarkHeight = props.itemMarkHeight,
|
|
50
|
+
itemMarkHeight = _props$itemMarkHeight === void 0 ? 20 : _props$itemMarkHeight,
|
|
51
|
+
_props$markGap = props.markGap,
|
|
52
|
+
markGap = _props$markGap === void 0 ? 5 : _props$markGap,
|
|
53
|
+
_props$itemGap = props.itemGap,
|
|
54
|
+
itemGap = _props$itemGap === void 0 ? 10 : _props$itemGap,
|
|
55
|
+
_props$padding = props.padding,
|
|
56
|
+
paddingProps = _props$padding === void 0 ? 10 : _props$padding,
|
|
57
|
+
inLabelStyle = props.labelStyle;
|
|
58
|
+
var theme = useTheme();
|
|
59
|
+
var labelStyle = React.useMemo(function () {
|
|
60
|
+
return _extends({}, theme.typography.subtitle1, {
|
|
61
|
+
color: 'inherit',
|
|
62
|
+
dominantBaseline: 'central',
|
|
63
|
+
textAnchor: 'start',
|
|
64
|
+
fill: (theme.vars || theme).palette.text.primary,
|
|
65
|
+
lineHeight: 1
|
|
66
|
+
}, inLabelStyle);
|
|
67
|
+
},
|
|
68
|
+
// To say to TS that the dominantBaseline and textAnchor are correct
|
|
69
|
+
[inLabelStyle, theme]);
|
|
70
|
+
var padding = React.useMemo(function () {
|
|
71
|
+
return getStandardizedPadding(paddingProps);
|
|
72
|
+
}, [paddingProps]);
|
|
73
|
+
var getItemSpace = React.useCallback(function (label) {
|
|
74
|
+
var inStyle = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
75
|
+
var rotate = inStyle.rotate,
|
|
76
|
+
dominantBaseline = inStyle.dominantBaseline,
|
|
77
|
+
style = _objectWithoutProperties(inStyle, _excluded);
|
|
78
|
+
var linesSize = getWordsByLines({
|
|
79
|
+
style: style,
|
|
80
|
+
needsComputation: true,
|
|
81
|
+
text: label
|
|
82
|
+
});
|
|
83
|
+
var innerSize = {
|
|
84
|
+
innerWidth: itemMarkWidth + markGap + Math.max.apply(Math, _toConsumableArray(linesSize.map(function (size) {
|
|
85
|
+
return size.width;
|
|
86
|
+
}))),
|
|
87
|
+
innerHeight: Math.max(itemMarkHeight, linesSize.length * linesSize[0].height)
|
|
88
|
+
};
|
|
89
|
+
return _extends({}, innerSize, {
|
|
90
|
+
outerWidth: innerSize.innerWidth + itemGap,
|
|
91
|
+
outerHeight: innerSize.innerHeight + itemGap
|
|
92
|
+
});
|
|
93
|
+
}, [itemGap, itemMarkHeight, itemMarkWidth, markGap]);
|
|
94
|
+
var totalWidth = drawingArea.left + drawingArea.width + drawingArea.right;
|
|
95
|
+
var totalHeight = drawingArea.top + drawingArea.height + drawingArea.bottom;
|
|
96
|
+
var availableWidth = totalWidth - padding.left - padding.right;
|
|
97
|
+
var availableHeight = totalHeight - padding.top - padding.bottom;
|
|
98
|
+
var seriesWithPosition = React.useMemo(function () {
|
|
99
|
+
// Start at 0, 0. Will be modified later by padding and position.
|
|
100
|
+
var x = 0;
|
|
101
|
+
var y = 0;
|
|
102
|
+
|
|
103
|
+
// total values used to align legend later.
|
|
104
|
+
var totalWidthUsed = 0;
|
|
105
|
+
var totalHeightUsed = 0;
|
|
106
|
+
var rowIndex = 0;
|
|
107
|
+
var rowMaxHeight = [0];
|
|
108
|
+
var seriesWithRawPosition = seriesToDisplay.map(function (_ref) {
|
|
109
|
+
var label = _ref.label,
|
|
110
|
+
other = _objectWithoutProperties(_ref, _excluded2);
|
|
111
|
+
var itemSpace = getItemSpace(label, labelStyle);
|
|
112
|
+
var rep = _extends({}, other, {
|
|
113
|
+
label: label,
|
|
114
|
+
positionX: x,
|
|
115
|
+
positionY: y,
|
|
116
|
+
innerHeight: itemSpace.innerHeight,
|
|
117
|
+
innerWidth: itemSpace.innerWidth,
|
|
118
|
+
outerHeight: itemSpace.outerHeight,
|
|
119
|
+
outerWidth: itemSpace.outerWidth,
|
|
120
|
+
rowIndex: rowIndex
|
|
121
|
+
});
|
|
122
|
+
if (direction === 'row') {
|
|
123
|
+
if (x + itemSpace.innerWidth > availableWidth) {
|
|
124
|
+
// This legend item would create overflow along the x-axis, so we start a new row.
|
|
125
|
+
x = 0;
|
|
126
|
+
y += rowMaxHeight[rowIndex];
|
|
127
|
+
rowIndex += 1;
|
|
128
|
+
if (rowMaxHeight.length <= rowIndex) {
|
|
129
|
+
rowMaxHeight.push(0);
|
|
130
|
+
}
|
|
131
|
+
rep.positionX = x;
|
|
132
|
+
rep.positionY = y;
|
|
133
|
+
rep.rowIndex = rowIndex;
|
|
134
|
+
}
|
|
135
|
+
totalWidthUsed = Math.max(totalWidthUsed, x + itemSpace.outerWidth);
|
|
136
|
+
totalHeightUsed = Math.max(totalHeightUsed, y + itemSpace.outerHeight);
|
|
137
|
+
rowMaxHeight[rowIndex] = Math.max(rowMaxHeight[rowIndex], itemSpace.outerHeight);
|
|
138
|
+
x += itemSpace.outerWidth;
|
|
139
|
+
}
|
|
140
|
+
if (direction === 'column') {
|
|
141
|
+
if (y + itemSpace.innerHeight > availableHeight) {
|
|
142
|
+
// This legend item would create overflow along the y-axis, so we start a new column.
|
|
143
|
+
x = totalWidthUsed + itemGap;
|
|
144
|
+
y = 0;
|
|
145
|
+
rowIndex = 0;
|
|
146
|
+
rep.positionX = x;
|
|
147
|
+
rep.positionY = y;
|
|
148
|
+
rep.rowIndex = rowIndex;
|
|
149
|
+
}
|
|
150
|
+
if (rowMaxHeight.length <= rowIndex) {
|
|
151
|
+
rowMaxHeight.push(0);
|
|
152
|
+
}
|
|
153
|
+
totalWidthUsed = Math.max(totalWidthUsed, x + itemSpace.outerWidth);
|
|
154
|
+
totalHeightUsed = Math.max(totalHeightUsed, y + itemSpace.outerHeight);
|
|
155
|
+
rowIndex += 1;
|
|
156
|
+
y += itemSpace.outerHeight;
|
|
157
|
+
}
|
|
158
|
+
return rep;
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
// Move the legend according to padding and position
|
|
162
|
+
var gapX = 0;
|
|
163
|
+
var gapY = 0;
|
|
164
|
+
switch (position.horizontal) {
|
|
165
|
+
case 'left':
|
|
166
|
+
gapX = padding.left;
|
|
167
|
+
break;
|
|
168
|
+
case 'right':
|
|
169
|
+
gapX = totalWidth - padding.right - totalWidthUsed;
|
|
170
|
+
break;
|
|
171
|
+
default:
|
|
172
|
+
gapX = (totalWidth - totalWidthUsed) / 2;
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
switch (position.vertical) {
|
|
176
|
+
case 'top':
|
|
177
|
+
gapY = padding.top;
|
|
178
|
+
break;
|
|
179
|
+
case 'bottom':
|
|
180
|
+
gapY = totalHeight - padding.bottom - totalHeightUsed;
|
|
181
|
+
break;
|
|
182
|
+
default:
|
|
183
|
+
gapY = (totalHeight - totalHeightUsed) / 2;
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
return seriesWithRawPosition.map(function (item) {
|
|
187
|
+
return _extends({}, item, {
|
|
188
|
+
// Add the gap due to the position
|
|
189
|
+
positionX: item.positionX + gapX,
|
|
190
|
+
// Add the gap due to the position
|
|
191
|
+
positionY: item.positionY + gapY + (direction === 'row' ? rowMaxHeight[item.rowIndex] / 2 // Get the center of the entire row
|
|
192
|
+
: item.outerHeight / 2) // Get the center of the item
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
}, [seriesToDisplay, position.horizontal, position.vertical, getItemSpace, labelStyle, direction, availableWidth, availableHeight, itemGap, padding.left, padding.right, padding.top, padding.bottom, totalWidth, totalHeight]);
|
|
196
|
+
if (hidden) {
|
|
197
|
+
return null;
|
|
198
|
+
}
|
|
199
|
+
return /*#__PURE__*/_jsx(NoSsr, {
|
|
200
|
+
children: /*#__PURE__*/_jsx(ChartsLegendRoot, {
|
|
201
|
+
className: classes.root,
|
|
202
|
+
children: seriesWithPosition.map(function (_ref2) {
|
|
203
|
+
var id = _ref2.id,
|
|
204
|
+
label = _ref2.label,
|
|
205
|
+
color = _ref2.color,
|
|
206
|
+
positionX = _ref2.positionX,
|
|
207
|
+
positionY = _ref2.positionY;
|
|
208
|
+
return /*#__PURE__*/_jsxs("g", {
|
|
209
|
+
className: classes.series,
|
|
210
|
+
transform: "translate(".concat(positionX, " ").concat(positionY, ")"),
|
|
211
|
+
children: [/*#__PURE__*/_jsx("rect", {
|
|
212
|
+
className: classes.mark,
|
|
213
|
+
y: -itemMarkHeight / 2,
|
|
214
|
+
width: itemMarkWidth,
|
|
215
|
+
height: itemMarkHeight,
|
|
216
|
+
fill: color
|
|
217
|
+
}), /*#__PURE__*/_jsx(ChartsText, {
|
|
218
|
+
style: labelStyle,
|
|
219
|
+
text: label,
|
|
220
|
+
x: itemMarkWidth + markGap,
|
|
221
|
+
y: 0
|
|
222
|
+
})]
|
|
223
|
+
}, id);
|
|
224
|
+
})
|
|
225
|
+
})
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
process.env.NODE_ENV !== "production" ? DefaultChartsLegend.propTypes = {
|
|
229
|
+
// ----------------------------- Warning --------------------------------
|
|
230
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
231
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
232
|
+
// ----------------------------------------------------------------------
|
|
233
|
+
/**
|
|
234
|
+
* Override or extend the styles applied to the component.
|
|
235
|
+
*/
|
|
236
|
+
classes: PropTypes.object.isRequired,
|
|
237
|
+
/**
|
|
238
|
+
* The direction of the legend layout.
|
|
239
|
+
* The default depends on the chart.
|
|
240
|
+
*/
|
|
241
|
+
direction: PropTypes.oneOf(['column', 'row']).isRequired,
|
|
242
|
+
drawingArea: PropTypes.shape({
|
|
243
|
+
bottom: PropTypes.number.isRequired,
|
|
244
|
+
height: PropTypes.number.isRequired,
|
|
245
|
+
left: PropTypes.number.isRequired,
|
|
246
|
+
right: PropTypes.number.isRequired,
|
|
247
|
+
top: PropTypes.number.isRequired,
|
|
248
|
+
width: PropTypes.number.isRequired
|
|
249
|
+
}).isRequired,
|
|
250
|
+
/**
|
|
251
|
+
* Set to true to hide the legend.
|
|
252
|
+
* @default false
|
|
253
|
+
*/
|
|
254
|
+
hidden: PropTypes.bool,
|
|
255
|
+
/**
|
|
256
|
+
* Space between two legend items (in px).
|
|
257
|
+
* @default 10
|
|
258
|
+
*/
|
|
259
|
+
itemGap: PropTypes.number,
|
|
260
|
+
/**
|
|
261
|
+
* Height of the item mark (in px).
|
|
262
|
+
* @default 20
|
|
263
|
+
*/
|
|
264
|
+
itemMarkHeight: PropTypes.number,
|
|
265
|
+
/**
|
|
266
|
+
* Width of the item mark (in px).
|
|
267
|
+
* @default 20
|
|
268
|
+
*/
|
|
269
|
+
itemMarkWidth: PropTypes.number,
|
|
270
|
+
/**
|
|
271
|
+
* Style applied to legend labels.
|
|
272
|
+
* @default theme.typography.subtitle1
|
|
273
|
+
*/
|
|
274
|
+
labelStyle: PropTypes.object,
|
|
275
|
+
/**
|
|
276
|
+
* Space between the mark and the label (in px).
|
|
277
|
+
* @default 5
|
|
278
|
+
*/
|
|
279
|
+
markGap: PropTypes.number,
|
|
280
|
+
/**
|
|
281
|
+
* Legend padding (in px).
|
|
282
|
+
* Can either be a single number, or an object with top, left, bottom, right properties.
|
|
283
|
+
* @default 10
|
|
284
|
+
*/
|
|
285
|
+
padding: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
|
|
286
|
+
bottom: PropTypes.number,
|
|
287
|
+
left: PropTypes.number,
|
|
288
|
+
right: PropTypes.number,
|
|
289
|
+
top: PropTypes.number
|
|
290
|
+
})]),
|
|
291
|
+
position: PropTypes.shape({
|
|
292
|
+
horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
|
|
293
|
+
vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
|
|
294
|
+
}).isRequired,
|
|
295
|
+
series: PropTypes.object.isRequired,
|
|
296
|
+
seriesToDisplay: PropTypes.arrayOf(PropTypes.shape({
|
|
297
|
+
color: PropTypes.string.isRequired,
|
|
298
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
299
|
+
label: PropTypes.string.isRequired
|
|
300
|
+
})).isRequired
|
|
301
|
+
} : void 0;
|
|
302
|
+
export { DefaultChartsLegend };
|
|
@@ -8,7 +8,7 @@ function ChartsReferenceLine(props) {
|
|
|
8
8
|
var x = props.x,
|
|
9
9
|
y = props.y;
|
|
10
10
|
if (x !== undefined && y !== undefined) {
|
|
11
|
-
throw new Error('MUI X Charts: The ChartsReferenceLine
|
|
11
|
+
throw new Error('MUI X Charts: The ChartsReferenceLine cannot have both `x` and `y` props set.');
|
|
12
12
|
}
|
|
13
13
|
if (x === undefined && y === undefined) {
|
|
14
14
|
throw new Error('MUI X Charts: The ChartsReferenceLine should have a value in `x` or `y` prop.');
|
|
@@ -27,7 +27,7 @@ process.env.NODE_ENV !== "production" ? ChartsReferenceLine.propTypes = {
|
|
|
27
27
|
* The id of the axis used for the reference value.
|
|
28
28
|
* @default The `id` of the first defined axis.
|
|
29
29
|
*/
|
|
30
|
-
axisId: PropTypes.string,
|
|
30
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
31
31
|
/**
|
|
32
32
|
* Override or extend the styles applied to the component.
|
|
33
33
|
*/
|
|
@@ -37,7 +37,7 @@ process.env.NODE_ENV !== "production" ? ChartsItemTooltipContent.propTypes = {
|
|
|
37
37
|
classes: PropTypes.object,
|
|
38
38
|
itemData: PropTypes.shape({
|
|
39
39
|
dataIndex: PropTypes.number,
|
|
40
|
-
seriesId: PropTypes.string.isRequired,
|
|
40
|
+
seriesId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
41
41
|
type: PropTypes.oneOf(['bar', 'line', 'pie', 'scatter']).isRequired
|
|
42
42
|
}),
|
|
43
43
|
series: PropTypes.object,
|
|
@@ -45,7 +45,7 @@ process.env.NODE_ENV !== "production" ? ChartsItemTooltipContent.propTypes = {
|
|
|
45
45
|
}),
|
|
46
46
|
itemData: PropTypes.shape({
|
|
47
47
|
dataIndex: PropTypes.number,
|
|
48
|
-
seriesId: PropTypes.string.isRequired,
|
|
48
|
+
seriesId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
49
49
|
type: PropTypes.oneOf(['bar', 'line', 'pie', 'scatter']).isRequired
|
|
50
50
|
}).isRequired,
|
|
51
51
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|