@mui/x-charts 7.4.0 → 7.5.0
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 +11 -10
- package/BarChart/BarElement.d.ts +10 -5
- package/BarChart/BarElement.js +3 -2
- package/BarChart/legend.js +13 -6
- package/CHANGELOG.md +93 -0
- package/ChartContainer/ChartContainer.js +10 -10
- package/ChartsOverlay/ChartsLoadingOverlay.js +3 -3
- package/ChartsOverlay/ChartsNoDataOverlay.js +2 -2
- package/ChartsOverlay/ChartsOverlay.d.ts +9 -0
- package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +4 -2
- package/ChartsTooltip/DefaultChartsItemTooltipContent.js +7 -3
- package/ChartsTooltip/utils.js +13 -8
- package/ChartsXAxis/ChartsXAxis.js +1 -2
- package/ChartsYAxis/ChartsYAxis.js +2 -2
- package/LineChart/AreaElement.d.ts +1 -1
- package/LineChart/AreaElement.js +3 -3
- package/LineChart/AreaPlot.js +3 -2
- package/LineChart/LineChart.js +11 -10
- package/LineChart/LineElement.d.ts +1 -1
- package/LineChart/LineElement.js +3 -3
- package/LineChart/LineHighlightElement.d.ts +1 -1
- package/LineChart/MarkElement.d.ts +1 -1
- package/LineChart/legend.js +13 -6
- package/PieChart/PieArc.d.ts +1 -1
- package/PieChart/PieArcLabel.d.ts +1 -1
- package/PieChart/PieArcLabel.js +3 -1
- package/PieChart/PieArcLabelPlot.js +14 -5
- package/PieChart/PieArcPlot.js +1 -1
- package/PieChart/PieChart.js +11 -10
- package/PieChart/formatter.js +4 -1
- package/PieChart/legend.js +15 -5
- package/ResponsiveChartContainer/ResponsiveChartContainer.js +10 -10
- package/ScatterChart/ScatterChart.js +16 -15
- package/ScatterChart/legend.js +13 -6
- package/SparkLineChart/SparkLineChart.js +5 -5
- package/context/ZAxisContextProvider.js +5 -5
- package/esm/BarChart/BarChart.js +11 -10
- package/esm/BarChart/BarElement.js +3 -2
- package/esm/BarChart/legend.js +13 -6
- package/esm/ChartContainer/ChartContainer.js +10 -10
- package/esm/ChartsOverlay/ChartsLoadingOverlay.js +3 -3
- package/esm/ChartsOverlay/ChartsNoDataOverlay.js +2 -2
- package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +4 -2
- package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +7 -3
- package/esm/ChartsTooltip/utils.js +13 -8
- package/esm/ChartsXAxis/ChartsXAxis.js +1 -2
- package/esm/ChartsYAxis/ChartsYAxis.js +2 -2
- package/esm/LineChart/AreaElement.js +3 -3
- package/esm/LineChart/AreaPlot.js +3 -2
- package/esm/LineChart/LineChart.js +11 -10
- package/esm/LineChart/LineElement.js +3 -3
- package/esm/LineChart/legend.js +13 -6
- package/esm/PieChart/PieArcLabel.js +3 -1
- package/esm/PieChart/PieArcLabelPlot.js +14 -5
- package/esm/PieChart/PieArcPlot.js +1 -1
- package/esm/PieChart/PieChart.js +11 -10
- package/esm/PieChart/formatter.js +4 -1
- package/esm/PieChart/legend.js +15 -5
- package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +10 -10
- package/esm/ScatterChart/ScatterChart.js +16 -15
- package/esm/ScatterChart/legend.js +13 -6
- package/esm/SparkLineChart/SparkLineChart.js +5 -5
- package/esm/context/ZAxisContextProvider.js +5 -5
- package/esm/hooks/useAxisEvents.js +12 -7
- package/esm/internals/getLabel.js +3 -0
- package/hooks/useAxisEvents.js +12 -7
- package/index.js +1 -1
- package/internals/defaultizeColor.d.ts +7 -5
- package/internals/getLabel.d.ts +1 -0
- package/internals/getLabel.js +9 -0
- package/internals/utils.d.ts +1 -1
- package/models/seriesType/bar.d.ts +4 -1
- package/models/seriesType/line.d.ts +4 -1
- package/models/seriesType/pie.d.ts +9 -4
- package/models/seriesType/scatter.d.ts +4 -1
- package/modern/BarChart/BarChart.js +11 -10
- package/modern/BarChart/BarElement.js +3 -2
- package/modern/BarChart/legend.js +13 -6
- package/modern/ChartContainer/ChartContainer.js +10 -10
- package/modern/ChartsOverlay/ChartsLoadingOverlay.js +3 -3
- package/modern/ChartsOverlay/ChartsNoDataOverlay.js +2 -2
- package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +4 -2
- package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +7 -3
- package/modern/ChartsTooltip/utils.js +13 -8
- package/modern/ChartsXAxis/ChartsXAxis.js +1 -2
- package/modern/ChartsYAxis/ChartsYAxis.js +2 -2
- package/modern/LineChart/AreaElement.js +3 -3
- package/modern/LineChart/AreaPlot.js +3 -2
- package/modern/LineChart/LineChart.js +11 -10
- package/modern/LineChart/LineElement.js +3 -3
- package/modern/LineChart/legend.js +13 -6
- package/modern/PieChart/PieArcLabel.js +3 -1
- package/modern/PieChart/PieArcLabelPlot.js +14 -5
- package/modern/PieChart/PieArcPlot.js +1 -1
- package/modern/PieChart/PieChart.js +11 -10
- package/modern/PieChart/formatter.js +4 -1
- package/modern/PieChart/legend.js +15 -5
- package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +10 -10
- package/modern/ScatterChart/ScatterChart.js +16 -15
- package/modern/ScatterChart/legend.js +13 -6
- package/modern/SparkLineChart/SparkLineChart.js +5 -5
- package/modern/context/ZAxisContextProvider.js +5 -5
- package/modern/hooks/useAxisEvents.js +12 -7
- package/modern/index.js +1 -1
- package/modern/internals/getLabel.js +3 -0
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
1
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
3
|
const _excluded = ["message"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { styled } from '@mui/material/styles';
|
|
@@ -7,7 +7,7 @@ import { useDrawingArea } from '../hooks/useDrawingArea';
|
|
|
7
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
8
|
const StyledText = styled('text')(({
|
|
9
9
|
theme
|
|
10
|
-
}) => ({
|
|
10
|
+
}) => _extends({}, theme.typography.body2, {
|
|
11
11
|
stroke: 'none',
|
|
12
12
|
fill: theme.palette.text.primary,
|
|
13
13
|
shapeRendering: 'crispEdges',
|
|
@@ -29,6 +29,6 @@ export function ChartsLoadingOverlay(props) {
|
|
|
29
29
|
x: left + width / 2,
|
|
30
30
|
y: top + height / 2
|
|
31
31
|
}, other, {
|
|
32
|
-
children: message ?? 'Loading data
|
|
32
|
+
children: message ?? 'Loading data…'
|
|
33
33
|
}));
|
|
34
34
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
1
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
3
|
const _excluded = ["message"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { styled } from '@mui/material/styles';
|
|
@@ -7,7 +7,7 @@ import { useDrawingArea } from '../hooks/useDrawingArea';
|
|
|
7
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
8
|
const StyledText = styled('text')(({
|
|
9
9
|
theme
|
|
10
|
-
}) => ({
|
|
10
|
+
}) => _extends({}, theme.typography.body2, {
|
|
11
11
|
stroke: 'none',
|
|
12
12
|
fill: theme.palette.text.primary,
|
|
13
13
|
shapeRendering: 'crispEdges',
|
|
@@ -4,6 +4,7 @@ import clsx from 'clsx';
|
|
|
4
4
|
import Typography from '@mui/material/Typography';
|
|
5
5
|
import { ChartsTooltipCell, ChartsTooltipPaper, ChartsTooltipTable, ChartsTooltipMark, ChartsTooltipRow } from './ChartsTooltipTable';
|
|
6
6
|
import { isCartesianSeries, utcFormatter } from './utils';
|
|
7
|
+
import { getLabel } from '../internals/getLabel';
|
|
7
8
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
9
|
function DefaultChartsAxisTooltipContent(props) {
|
|
9
10
|
const {
|
|
@@ -50,6 +51,7 @@ function DefaultChartsAxisTooltipContent(props) {
|
|
|
50
51
|
if (formattedValue == null) {
|
|
51
52
|
return null;
|
|
52
53
|
}
|
|
54
|
+
const formattedLabel = getLabel(label, 'tooltip');
|
|
53
55
|
return /*#__PURE__*/_jsxs(ChartsTooltipRow, {
|
|
54
56
|
className: classes.row,
|
|
55
57
|
children: [/*#__PURE__*/_jsx(ChartsTooltipCell, {
|
|
@@ -60,8 +62,8 @@ function DefaultChartsAxisTooltipContent(props) {
|
|
|
60
62
|
})
|
|
61
63
|
}), /*#__PURE__*/_jsx(ChartsTooltipCell, {
|
|
62
64
|
className: clsx(classes.labelCell, classes.cell),
|
|
63
|
-
children:
|
|
64
|
-
children:
|
|
65
|
+
children: formattedLabel ? /*#__PURE__*/_jsx(Typography, {
|
|
66
|
+
children: formattedLabel
|
|
65
67
|
}) : null
|
|
66
68
|
}), /*#__PURE__*/_jsx(ChartsTooltipCell, {
|
|
67
69
|
className: clsx(classes.valueCell, classes.cell),
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
1
2
|
import * as React from 'react';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
4
|
import clsx from 'clsx';
|
|
4
5
|
import { ChartsTooltipTable, ChartsTooltipCell, ChartsTooltipMark, ChartsTooltipPaper, ChartsTooltipRow } from './ChartsTooltipTable';
|
|
6
|
+
import { getLabel } from '../internals/getLabel';
|
|
5
7
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
8
|
function DefaultChartsItemTooltipContent(props) {
|
|
7
9
|
const {
|
|
@@ -19,12 +21,14 @@ function DefaultChartsItemTooltipContent(props) {
|
|
|
19
21
|
color
|
|
20
22
|
} = series.type === 'pie' ? {
|
|
21
23
|
color: getColor(itemData.dataIndex),
|
|
22
|
-
displayedLabel: series.data[itemData.dataIndex].label
|
|
24
|
+
displayedLabel: getLabel(series.data[itemData.dataIndex].label, 'tooltip')
|
|
23
25
|
} : {
|
|
24
26
|
color: getColor(itemData.dataIndex) ?? series.color,
|
|
25
|
-
displayedLabel: series.label
|
|
27
|
+
displayedLabel: getLabel(series.label, 'tooltip')
|
|
26
28
|
};
|
|
27
|
-
const value = series.data[itemData.dataIndex]
|
|
29
|
+
const value = series.type === 'pie' ? _extends({}, series.data[itemData.dataIndex], {
|
|
30
|
+
label: getLabel(series.data[itemData.dataIndex].label, 'tooltip')
|
|
31
|
+
}) : series.data[itemData.dataIndex];
|
|
28
32
|
const formattedValue = series.valueFormatter?.(value, {
|
|
29
33
|
dataIndex: itemData.dataIndex
|
|
30
34
|
});
|
|
@@ -53,20 +53,25 @@ export function useMouseTracker() {
|
|
|
53
53
|
if (element === null) {
|
|
54
54
|
return () => {};
|
|
55
55
|
}
|
|
56
|
-
const
|
|
56
|
+
const handleOut = () => {
|
|
57
57
|
setMousePosition(null);
|
|
58
58
|
};
|
|
59
|
-
const
|
|
59
|
+
const handleMove = event => {
|
|
60
|
+
const target = 'targetTouches' in event ? event.targetTouches[0] : event;
|
|
60
61
|
setMousePosition({
|
|
61
|
-
x:
|
|
62
|
-
y:
|
|
62
|
+
x: target.clientX,
|
|
63
|
+
y: target.clientY
|
|
63
64
|
});
|
|
64
65
|
};
|
|
65
|
-
element.addEventListener('mouseout',
|
|
66
|
-
element.addEventListener('mousemove',
|
|
66
|
+
element.addEventListener('mouseout', handleOut);
|
|
67
|
+
element.addEventListener('mousemove', handleMove);
|
|
68
|
+
element.addEventListener('touchend', handleOut);
|
|
69
|
+
element.addEventListener('touchmove', handleMove);
|
|
67
70
|
return () => {
|
|
68
|
-
element.removeEventListener('mouseout',
|
|
69
|
-
element.removeEventListener('mousemove',
|
|
71
|
+
element.removeEventListener('mouseout', handleOut);
|
|
72
|
+
element.removeEventListener('mousemove', handleMove);
|
|
73
|
+
element.addEventListener('touchend', handleOut);
|
|
74
|
+
element.addEventListener('touchmove', handleMove);
|
|
70
75
|
};
|
|
71
76
|
}, [svgRef]);
|
|
72
77
|
return mousePosition;
|
|
@@ -167,8 +167,7 @@ function ChartsXAxis(inProps) {
|
|
|
167
167
|
textAnchor: 'middle',
|
|
168
168
|
dominantBaseline: position === 'bottom' ? 'hanging' : 'auto',
|
|
169
169
|
fontSize: tickFontSize ?? 12
|
|
170
|
-
}, tickLabelStyle)
|
|
171
|
-
className: classes.tickLabel
|
|
170
|
+
}, tickLabelStyle)
|
|
172
171
|
},
|
|
173
172
|
className: classes.tickLabel,
|
|
174
173
|
ownerState: {}
|
|
@@ -120,9 +120,9 @@ function ChartsYAxis(inProps) {
|
|
|
120
120
|
fontSize: tickFontSize,
|
|
121
121
|
textAnchor: position === 'right' ? 'start' : 'end',
|
|
122
122
|
dominantBaseline: 'central'
|
|
123
|
-
}, tickLabelStyle)
|
|
124
|
-
className: classes.tickLabel
|
|
123
|
+
}, tickLabelStyle)
|
|
125
124
|
},
|
|
125
|
+
className: classes.tickLabel,
|
|
126
126
|
ownerState: {}
|
|
127
127
|
});
|
|
128
128
|
const axisLabelProps = useSlotProps({
|
|
@@ -74,17 +74,17 @@ function AreaElement(props) {
|
|
|
74
74
|
const areaProps = useSlotProps({
|
|
75
75
|
elementType: Area,
|
|
76
76
|
externalSlotProps: slotProps?.area,
|
|
77
|
-
additionalProps: _extends({},
|
|
77
|
+
additionalProps: _extends({}, getInteractionItemProps({
|
|
78
78
|
type: 'line',
|
|
79
79
|
seriesId: id
|
|
80
80
|
}), {
|
|
81
|
-
className: classes.root,
|
|
82
81
|
onClick,
|
|
83
82
|
cursor: onClick ? 'pointer' : 'unset'
|
|
84
83
|
}),
|
|
84
|
+
className: classes.root,
|
|
85
85
|
ownerState
|
|
86
86
|
});
|
|
87
|
-
return /*#__PURE__*/_jsx(Area, _extends({}, areaProps));
|
|
87
|
+
return /*#__PURE__*/_jsx(Area, _extends({}, other, areaProps));
|
|
88
88
|
}
|
|
89
89
|
process.env.NODE_ENV !== "production" ? AreaElement.propTypes = {
|
|
90
90
|
// ----------------------------- Warning --------------------------------
|
|
@@ -33,7 +33,8 @@ const useAggregatedData = () => {
|
|
|
33
33
|
return stackingGroups.flatMap(({
|
|
34
34
|
ids: groupIds
|
|
35
35
|
}) => {
|
|
36
|
-
return groupIds.
|
|
36
|
+
return [...groupIds].reverse() // Revert stacked area for a more pleasant animation
|
|
37
|
+
.map(seriesId => {
|
|
37
38
|
const {
|
|
38
39
|
xAxisKey = defaultXAxisId,
|
|
39
40
|
yAxisKey = defaultYAxisId,
|
|
@@ -92,7 +93,7 @@ function AreaPlot(props) {
|
|
|
92
93
|
const getGradientId = useChartGradient();
|
|
93
94
|
const completedData = useAggregatedData();
|
|
94
95
|
return /*#__PURE__*/_jsx("g", _extends({}, other, {
|
|
95
|
-
children: completedData.
|
|
96
|
+
children: completedData.map(({
|
|
96
97
|
d,
|
|
97
98
|
seriesId,
|
|
98
99
|
color,
|
|
@@ -205,6 +205,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
205
205
|
}),
|
|
206
206
|
/**
|
|
207
207
|
* If `true`, a loading overlay is displayed.
|
|
208
|
+
* @default false
|
|
208
209
|
*/
|
|
209
210
|
loading: PropTypes.bool,
|
|
210
211
|
/**
|
|
@@ -304,6 +305,11 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
304
305
|
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
305
306
|
classes: PropTypes.object,
|
|
306
307
|
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
308
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
309
|
+
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
310
|
+
unknownColor: PropTypes.string,
|
|
311
|
+
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
312
|
+
}), PropTypes.shape({
|
|
307
313
|
color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
|
|
308
314
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
309
315
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
@@ -312,11 +318,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
312
318
|
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
313
319
|
thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
|
|
314
320
|
type: PropTypes.oneOf(['piecewise']).isRequired
|
|
315
|
-
}), PropTypes.shape({
|
|
316
|
-
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
317
|
-
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
318
|
-
unknownColor: PropTypes.string,
|
|
319
|
-
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
320
321
|
})]),
|
|
321
322
|
data: PropTypes.array,
|
|
322
323
|
dataKey: PropTypes.string,
|
|
@@ -357,6 +358,11 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
357
358
|
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
358
359
|
classes: PropTypes.object,
|
|
359
360
|
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
361
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
362
|
+
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
363
|
+
unknownColor: PropTypes.string,
|
|
364
|
+
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
365
|
+
}), PropTypes.shape({
|
|
360
366
|
color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
|
|
361
367
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
362
368
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
@@ -365,11 +371,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
365
371
|
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
366
372
|
thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
|
|
367
373
|
type: PropTypes.oneOf(['piecewise']).isRequired
|
|
368
|
-
}), PropTypes.shape({
|
|
369
|
-
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
370
|
-
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
371
|
-
unknownColor: PropTypes.string,
|
|
372
|
-
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
373
374
|
})]),
|
|
374
375
|
data: PropTypes.array,
|
|
375
376
|
dataKey: PropTypes.string,
|
|
@@ -74,17 +74,17 @@ function LineElement(props) {
|
|
|
74
74
|
const lineProps = useSlotProps({
|
|
75
75
|
elementType: Line,
|
|
76
76
|
externalSlotProps: slotProps?.line,
|
|
77
|
-
additionalProps: _extends({},
|
|
77
|
+
additionalProps: _extends({}, getInteractionItemProps({
|
|
78
78
|
type: 'line',
|
|
79
79
|
seriesId: id
|
|
80
80
|
}), {
|
|
81
|
-
className: classes.root,
|
|
82
81
|
onClick,
|
|
83
82
|
cursor: onClick ? 'pointer' : 'unset'
|
|
84
83
|
}),
|
|
84
|
+
className: classes.root,
|
|
85
85
|
ownerState
|
|
86
86
|
});
|
|
87
|
-
return /*#__PURE__*/_jsx(Line, _extends({}, lineProps));
|
|
87
|
+
return /*#__PURE__*/_jsx(Line, _extends({}, other, lineProps));
|
|
88
88
|
}
|
|
89
89
|
process.env.NODE_ENV !== "production" ? LineElement.propTypes = {
|
|
90
90
|
// ----------------------------- Warning --------------------------------
|
package/esm/LineChart/legend.js
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
|
+
import { getLabel } from '../internals/getLabel';
|
|
1
2
|
const legendGetter = params => {
|
|
2
3
|
const {
|
|
3
4
|
seriesOrder,
|
|
4
5
|
series
|
|
5
6
|
} = params;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
return seriesOrder.reduce((acc, seriesId) => {
|
|
8
|
+
const formattedLabel = getLabel(series[seriesId].label, 'legend');
|
|
9
|
+
if (formattedLabel === undefined) {
|
|
10
|
+
return acc;
|
|
11
|
+
}
|
|
12
|
+
acc.push({
|
|
13
|
+
color: series[seriesId].color,
|
|
14
|
+
label: formattedLabel,
|
|
15
|
+
id: seriesId
|
|
16
|
+
});
|
|
17
|
+
return acc;
|
|
18
|
+
}, []);
|
|
12
19
|
};
|
|
13
20
|
export default legendGetter;
|
|
@@ -35,7 +35,8 @@ const PieArcLabelRoot = styled(animated.text, {
|
|
|
35
35
|
}) => ({
|
|
36
36
|
fill: (theme.vars || theme).palette.text.primary,
|
|
37
37
|
textAnchor: 'middle',
|
|
38
|
-
dominantBaseline: 'middle'
|
|
38
|
+
dominantBaseline: 'middle',
|
|
39
|
+
pointerEvents: 'none'
|
|
39
40
|
}));
|
|
40
41
|
/**
|
|
41
42
|
* Helper to compute label position.
|
|
@@ -97,6 +98,7 @@ process.env.NODE_ENV !== "production" ? PieArcLabel.propTypes = {
|
|
|
97
98
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
98
99
|
// ----------------------------------------------------------------------
|
|
99
100
|
classes: PropTypes.object,
|
|
101
|
+
color: PropTypes.string.isRequired,
|
|
100
102
|
formattedArcLabel: PropTypes.string,
|
|
101
103
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
102
104
|
isFaded: PropTypes.bool.isRequired,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
1
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
3
|
const _excluded = ["arcLabel", "arcLabelMinAngle", "arcLabelRadius", "cornerRadius", "data", "faded", "highlighted", "highlightScope", "id", "innerRadius", "outerRadius", "paddingAngle", "skipAnimation", "slotProps", "slots"],
|
|
4
4
|
_excluded2 = ["startAngle", "endAngle", "paddingAngle", "innerRadius", "outerRadius", "arcLabelRadius", "cornerRadius"];
|
|
5
5
|
import * as React from 'react';
|
|
@@ -8,6 +8,7 @@ import { useTransition } from '@react-spring/web';
|
|
|
8
8
|
import { defaultLabelTransitionConfig } from './dataTransform/transition';
|
|
9
9
|
import { useTransformData } from './dataTransform/useTransformData';
|
|
10
10
|
import { PieArcLabel } from './PieArcLabel';
|
|
11
|
+
import { getLabel } from '../internals/getLabel';
|
|
11
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
13
|
const RATIO = 180 / Math.PI;
|
|
13
14
|
function getItemLabel(arcLabel, arcLabelMinAngle, item) {
|
|
@@ -18,10 +19,18 @@ function getItemLabel(arcLabel, arcLabelMinAngle, item) {
|
|
|
18
19
|
if (angle < arcLabelMinAngle) {
|
|
19
20
|
return null;
|
|
20
21
|
}
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
switch (arcLabel) {
|
|
23
|
+
case 'label':
|
|
24
|
+
return getLabel(item.label, 'arc');
|
|
25
|
+
case 'value':
|
|
26
|
+
return item.value?.toString();
|
|
27
|
+
case 'formattedValue':
|
|
28
|
+
return item.formattedValue;
|
|
29
|
+
default:
|
|
30
|
+
return arcLabel(_extends({}, item, {
|
|
31
|
+
label: getLabel(item.label, 'arc')
|
|
32
|
+
}));
|
|
23
33
|
}
|
|
24
|
-
return arcLabel(item);
|
|
25
34
|
}
|
|
26
35
|
function PieArcLabelPlot(props) {
|
|
27
36
|
const {
|
|
@@ -123,7 +132,7 @@ process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
|
|
|
123
132
|
formattedValue: PropTypes.string.isRequired,
|
|
124
133
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
125
134
|
index: PropTypes.number.isRequired,
|
|
126
|
-
label: PropTypes.string,
|
|
135
|
+
label: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
|
|
127
136
|
padAngle: PropTypes.number.isRequired,
|
|
128
137
|
startAngle: PropTypes.number.isRequired,
|
|
129
138
|
value: PropTypes.number.isRequired
|
|
@@ -103,7 +103,7 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
|
|
|
103
103
|
formattedValue: PropTypes.string.isRequired,
|
|
104
104
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
105
105
|
index: PropTypes.number.isRequired,
|
|
106
|
-
label: PropTypes.string,
|
|
106
|
+
label: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
|
|
107
107
|
padAngle: PropTypes.number.isRequired,
|
|
108
108
|
startAngle: PropTypes.number.isRequired,
|
|
109
109
|
value: PropTypes.number.isRequired
|
package/esm/PieChart/PieChart.js
CHANGED
|
@@ -179,6 +179,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
179
179
|
}),
|
|
180
180
|
/**
|
|
181
181
|
* If `true`, a loading overlay is displayed.
|
|
182
|
+
* @default false
|
|
182
183
|
*/
|
|
183
184
|
loading: PropTypes.bool,
|
|
184
185
|
/**
|
|
@@ -263,6 +264,11 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
263
264
|
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
264
265
|
classes: PropTypes.object,
|
|
265
266
|
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
267
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
268
|
+
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
269
|
+
unknownColor: PropTypes.string,
|
|
270
|
+
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
271
|
+
}), PropTypes.shape({
|
|
266
272
|
color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
|
|
267
273
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
268
274
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
@@ -271,11 +277,6 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
271
277
|
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
272
278
|
thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
|
|
273
279
|
type: PropTypes.oneOf(['piecewise']).isRequired
|
|
274
|
-
}), PropTypes.shape({
|
|
275
|
-
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
276
|
-
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
277
|
-
unknownColor: PropTypes.string,
|
|
278
|
-
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
279
280
|
})]),
|
|
280
281
|
data: PropTypes.array,
|
|
281
282
|
dataKey: PropTypes.string,
|
|
@@ -316,6 +317,11 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
316
317
|
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
317
318
|
classes: PropTypes.object,
|
|
318
319
|
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
320
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
321
|
+
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
322
|
+
unknownColor: PropTypes.string,
|
|
323
|
+
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
324
|
+
}), PropTypes.shape({
|
|
319
325
|
color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
|
|
320
326
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
321
327
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
@@ -324,11 +330,6 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
324
330
|
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
325
331
|
thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
|
|
326
332
|
type: PropTypes.oneOf(['piecewise']).isRequired
|
|
327
|
-
}), PropTypes.shape({
|
|
328
|
-
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
329
|
-
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
330
|
-
unknownColor: PropTypes.string,
|
|
331
|
-
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
332
333
|
})]),
|
|
333
334
|
data: PropTypes.array,
|
|
334
335
|
dataKey: PropTypes.string,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import { pie as d3Pie } from 'd3-shape';
|
|
3
|
+
import { getLabel } from '../internals/getLabel';
|
|
3
4
|
const getSortingComparator = (comparator = 'none') => {
|
|
4
5
|
if (typeof comparator === 'function') {
|
|
5
6
|
return comparator;
|
|
@@ -29,7 +30,9 @@ const formatter = params => {
|
|
|
29
30
|
data: series[seriesId].data.map((item, index) => _extends({}, item, {
|
|
30
31
|
id: item.id ?? `auto-generated-pie-id-${seriesId}-${index}`
|
|
31
32
|
}, arcs[index])).map((item, index) => _extends({}, item, {
|
|
32
|
-
formattedValue: series[seriesId].valueFormatter?.(item, {
|
|
33
|
+
formattedValue: series[seriesId].valueFormatter?.(_extends({}, item, {
|
|
34
|
+
label: getLabel(item.label, 'arc')
|
|
35
|
+
}), {
|
|
33
36
|
dataIndex: index
|
|
34
37
|
}) ?? item.value.toLocaleString()
|
|
35
38
|
}))
|
package/esm/PieChart/legend.js
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
|
+
import { getLabel } from '../internals/getLabel';
|
|
1
2
|
const legendGetter = params => {
|
|
2
3
|
const {
|
|
3
4
|
seriesOrder,
|
|
4
5
|
series
|
|
5
6
|
} = params;
|
|
6
|
-
return seriesOrder.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
return seriesOrder.reduce((acc, seriesId) => {
|
|
8
|
+
series[seriesId].data.forEach(item => {
|
|
9
|
+
const formattedLabel = getLabel(item.label, 'legend');
|
|
10
|
+
if (formattedLabel === undefined) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
acc.push({
|
|
14
|
+
color: item.color,
|
|
15
|
+
label: formattedLabel,
|
|
16
|
+
id: item.id
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
return acc;
|
|
20
|
+
}, []);
|
|
11
21
|
};
|
|
12
22
|
export default legendGetter;
|
|
@@ -113,6 +113,11 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
|
|
|
113
113
|
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
114
114
|
classes: PropTypes.object,
|
|
115
115
|
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
116
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
117
|
+
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
118
|
+
unknownColor: PropTypes.string,
|
|
119
|
+
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
120
|
+
}), PropTypes.shape({
|
|
116
121
|
color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
|
|
117
122
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
118
123
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
@@ -121,11 +126,6 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
|
|
|
121
126
|
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
122
127
|
thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
|
|
123
128
|
type: PropTypes.oneOf(['piecewise']).isRequired
|
|
124
|
-
}), PropTypes.shape({
|
|
125
|
-
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
126
|
-
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
127
|
-
unknownColor: PropTypes.string,
|
|
128
|
-
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
129
129
|
})]),
|
|
130
130
|
data: PropTypes.array,
|
|
131
131
|
dataKey: PropTypes.string,
|
|
@@ -166,6 +166,11 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
|
|
|
166
166
|
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
167
167
|
classes: PropTypes.object,
|
|
168
168
|
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
169
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
170
|
+
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
171
|
+
unknownColor: PropTypes.string,
|
|
172
|
+
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
173
|
+
}), PropTypes.shape({
|
|
169
174
|
color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
|
|
170
175
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
171
176
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
@@ -174,11 +179,6 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
|
|
|
174
179
|
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
175
180
|
thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
|
|
176
181
|
type: PropTypes.oneOf(['piecewise']).isRequired
|
|
177
|
-
}), PropTypes.shape({
|
|
178
|
-
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
179
|
-
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
180
|
-
unknownColor: PropTypes.string,
|
|
181
|
-
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
182
182
|
})]),
|
|
183
183
|
data: PropTypes.array,
|
|
184
184
|
dataKey: PropTypes.string,
|
|
@@ -172,6 +172,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
172
172
|
}),
|
|
173
173
|
/**
|
|
174
174
|
* If `true`, a loading overlay is displayed.
|
|
175
|
+
* @default false
|
|
175
176
|
*/
|
|
176
177
|
loading: PropTypes.bool,
|
|
177
178
|
/**
|
|
@@ -258,6 +259,11 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
258
259
|
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
259
260
|
classes: PropTypes.object,
|
|
260
261
|
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
262
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
263
|
+
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
264
|
+
unknownColor: PropTypes.string,
|
|
265
|
+
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
266
|
+
}), PropTypes.shape({
|
|
261
267
|
color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
|
|
262
268
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
263
269
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
@@ -266,11 +272,6 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
266
272
|
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
267
273
|
thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
|
|
268
274
|
type: PropTypes.oneOf(['piecewise']).isRequired
|
|
269
|
-
}), PropTypes.shape({
|
|
270
|
-
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
271
|
-
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
272
|
-
unknownColor: PropTypes.string,
|
|
273
|
-
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
274
275
|
})]),
|
|
275
276
|
data: PropTypes.array,
|
|
276
277
|
dataKey: PropTypes.string,
|
|
@@ -311,6 +312,11 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
311
312
|
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
312
313
|
classes: PropTypes.object,
|
|
313
314
|
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
315
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
316
|
+
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
317
|
+
unknownColor: PropTypes.string,
|
|
318
|
+
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
319
|
+
}), PropTypes.shape({
|
|
314
320
|
color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
|
|
315
321
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
316
322
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
@@ -319,11 +325,6 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
319
325
|
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
320
326
|
thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
|
|
321
327
|
type: PropTypes.oneOf(['piecewise']).isRequired
|
|
322
|
-
}), PropTypes.shape({
|
|
323
|
-
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
324
|
-
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
325
|
-
unknownColor: PropTypes.string,
|
|
326
|
-
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
327
328
|
})]),
|
|
328
329
|
data: PropTypes.array,
|
|
329
330
|
dataKey: PropTypes.string,
|
|
@@ -360,6 +361,11 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
360
361
|
*/
|
|
361
362
|
zAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
362
363
|
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
364
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
365
|
+
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
366
|
+
unknownColor: PropTypes.string,
|
|
367
|
+
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
368
|
+
}), PropTypes.shape({
|
|
363
369
|
color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
|
|
364
370
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
365
371
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
@@ -368,11 +374,6 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
368
374
|
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
369
375
|
thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
|
|
370
376
|
type: PropTypes.oneOf(['piecewise']).isRequired
|
|
371
|
-
}), PropTypes.shape({
|
|
372
|
-
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
373
|
-
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
374
|
-
unknownColor: PropTypes.string,
|
|
375
|
-
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
376
377
|
})]),
|
|
377
378
|
data: PropTypes.array,
|
|
378
379
|
dataKey: PropTypes.string,
|
|
@@ -1,13 +1,20 @@
|
|
|
1
|
+
import { getLabel } from '../internals/getLabel';
|
|
1
2
|
const legendGetter = params => {
|
|
2
3
|
const {
|
|
3
4
|
seriesOrder,
|
|
4
5
|
series
|
|
5
6
|
} = params;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
return seriesOrder.reduce((acc, seriesId) => {
|
|
8
|
+
const formattedLabel = getLabel(series[seriesId].label, 'legend');
|
|
9
|
+
if (formattedLabel === undefined) {
|
|
10
|
+
return acc;
|
|
11
|
+
}
|
|
12
|
+
acc.push({
|
|
13
|
+
color: series[seriesId].color,
|
|
14
|
+
label: formattedLabel,
|
|
15
|
+
id: seriesId
|
|
16
|
+
});
|
|
17
|
+
return acc;
|
|
18
|
+
}, []);
|
|
12
19
|
};
|
|
13
20
|
export default legendGetter;
|