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