@mui/x-charts 7.0.0-beta.7 → 7.1.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/CHANGELOG.md +266 -12
- package/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
- package/README.md +1 -1
- package/context/CartesianContextProvider.js +2 -2
- package/esm/BarChart/BarChart.js +6 -9
- package/esm/BarChart/BarElement.js +2 -3
- package/esm/BarChart/BarPlot.js +5 -8
- package/esm/BarChart/extremums.js +2 -3
- package/esm/BarChart/formatter.js +2 -6
- package/esm/ChartsAxis/ChartsAxis.js +3 -4
- package/esm/ChartsLegend/ChartsLegend.js +2 -3
- package/esm/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -4
- package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +2 -3
- package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +2 -3
- package/esm/ChartsText/ChartsText.js +1 -1
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +1 -1
- package/esm/ChartsTooltip/ChartsTooltip.js +6 -7
- package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -4
- package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +2 -3
- package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +4 -6
- package/esm/ChartsXAxis/ChartsXAxis.js +13 -14
- package/esm/ChartsYAxis/ChartsYAxis.js +9 -10
- package/esm/Gauge/GaugeContainer.js +18 -21
- package/esm/Gauge/GaugeProvider.js +3 -3
- package/esm/LineChart/AreaElement.js +2 -3
- package/esm/LineChart/AreaPlot.js +2 -3
- package/esm/LineChart/LineChart.js +3 -6
- package/esm/LineChart/LineElement.js +2 -3
- package/esm/LineChart/LineHighlightPlot.js +3 -4
- package/esm/LineChart/LinePlot.js +2 -3
- package/esm/LineChart/MarkElement.js +1 -2
- package/esm/LineChart/MarkPlot.js +3 -4
- package/esm/LineChart/extremums.js +2 -3
- package/esm/LineChart/formatter.js +2 -6
- package/esm/PieChart/PieArcLabelPlot.js +3 -5
- package/esm/PieChart/PieArcPlot.js +2 -3
- package/esm/PieChart/PieChart.js +2 -2
- package/esm/PieChart/PiePlot.js +9 -9
- package/esm/PieChart/dataTransform/useTransformData.js +5 -6
- package/esm/PieChart/formatter.js +6 -13
- package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +15 -18
- package/esm/ResponsiveChartContainer/useChartContainerDimensions.js +2 -2
- package/esm/ScatterChart/ScatterPlot.js +5 -6
- package/esm/SparkLineChart/SparkLineChart.js +1 -1
- package/esm/context/CartesianContextProvider.js +18 -24
- package/esm/context/DrawingProvider.js +1 -1
- package/esm/context/SeriesContextProvider.js +2 -4
- package/esm/hooks/useAxisEvents.js +1 -1
- package/esm/hooks/useInteractionItemProps.js +2 -2
- package/esm/hooks/useScale.js +2 -2
- package/esm/hooks/useTicks.js +23 -32
- package/esm/internals/defaultizeValueFormatter.js +1 -2
- package/esm/internals/stackSeries.js +2 -3
- package/index.js +1 -1
- package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
- package/modern/context/CartesianContextProvider.js +2 -2
- package/modern/index.js +1 -1
- package/package.json +5 -5
|
@@ -42,7 +42,7 @@ function ChartsAxisTooltipContent(props) {
|
|
|
42
42
|
const relevantAxis = React.useMemo(() => {
|
|
43
43
|
return isXaxis ? xAxis[USED_AXIS_ID] : yAxis[USED_AXIS_ID];
|
|
44
44
|
}, [USED_AXIS_ID, isXaxis, xAxis, yAxis]);
|
|
45
|
-
const Content = content
|
|
45
|
+
const Content = content ?? DefaultChartsAxisTooltipContent;
|
|
46
46
|
const chartTooltipContentProps = useSlotProps({
|
|
47
47
|
elementType: Content,
|
|
48
48
|
externalSlotProps: contentProps,
|
|
@@ -14,7 +14,7 @@ function ChartsItemTooltipContent(props) {
|
|
|
14
14
|
contentProps
|
|
15
15
|
} = props;
|
|
16
16
|
const series = React.useContext(SeriesContext)[itemData.type].series[itemData.seriesId];
|
|
17
|
-
const Content = content
|
|
17
|
+
const Content = content ?? DefaultChartsItemTooltipContent;
|
|
18
18
|
const chartTooltipContentProps = useSlotProps({
|
|
19
19
|
elementType: Content,
|
|
20
20
|
externalSlotProps: contentProps,
|
|
@@ -49,7 +49,6 @@ const ChartsTooltipRoot = styled(Popper, {
|
|
|
49
49
|
* - [ChartsTooltip API](https://mui.com/x/api/charts/charts-tool-tip/)
|
|
50
50
|
*/
|
|
51
51
|
function ChartsTooltip(props) {
|
|
52
|
-
var _slots$popper, _slots$itemContent, _slots$axisContent;
|
|
53
52
|
const themeProps = useThemeProps({
|
|
54
53
|
props,
|
|
55
54
|
name: 'MuiChartsTooltip'
|
|
@@ -72,10 +71,10 @@ function ChartsTooltip(props) {
|
|
|
72
71
|
const classes = useUtilityClasses({
|
|
73
72
|
classes: themeProps.classes
|
|
74
73
|
});
|
|
75
|
-
const PopperComponent =
|
|
74
|
+
const PopperComponent = slots?.popper ?? ChartsTooltipRoot;
|
|
76
75
|
const popperProps = useSlotProps({
|
|
77
76
|
elementType: PopperComponent,
|
|
78
|
-
externalSlotProps: slotProps
|
|
77
|
+
externalSlotProps: slotProps?.popper,
|
|
79
78
|
additionalProps: {
|
|
80
79
|
open: popperOpen,
|
|
81
80
|
placement: 'right-start',
|
|
@@ -90,16 +89,16 @@ function ChartsTooltip(props) {
|
|
|
90
89
|
children: popperOpen && /*#__PURE__*/_jsx(PopperComponent, _extends({}, popperProps, {
|
|
91
90
|
children: trigger === 'item' ? /*#__PURE__*/_jsx(ChartsItemTooltipContent, {
|
|
92
91
|
itemData: displayedData,
|
|
93
|
-
content:
|
|
94
|
-
contentProps: slotProps
|
|
92
|
+
content: slots?.itemContent ?? itemContent,
|
|
93
|
+
contentProps: slotProps?.itemContent,
|
|
95
94
|
sx: {
|
|
96
95
|
mx: 2
|
|
97
96
|
},
|
|
98
97
|
classes: classes
|
|
99
98
|
}) : /*#__PURE__*/_jsx(ChartsAxisTooltipContent, {
|
|
100
99
|
axisData: displayedData,
|
|
101
|
-
content:
|
|
102
|
-
contentProps: slotProps
|
|
100
|
+
content: slots?.axisContent ?? axisContent,
|
|
101
|
+
contentProps: slotProps?.axisContent,
|
|
103
102
|
sx: {
|
|
104
103
|
mx: 2
|
|
105
104
|
},
|
|
@@ -7,7 +7,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) {
|
|
10
|
-
var _axis$valueFormatter;
|
|
11
10
|
const {
|
|
12
11
|
series,
|
|
13
12
|
axis,
|
|
@@ -19,7 +18,7 @@ function DefaultChartsAxisTooltipContent(props) {
|
|
|
19
18
|
if (dataIndex == null) {
|
|
20
19
|
return null;
|
|
21
20
|
}
|
|
22
|
-
const axisFormatter =
|
|
21
|
+
const axisFormatter = axis.valueFormatter ?? (v => axis.scaleType === 'utc' ? utcFormatter(v) : v.toLocaleString());
|
|
23
22
|
return /*#__PURE__*/_jsx(ChartsTooltipPaper, {
|
|
24
23
|
sx: sx,
|
|
25
24
|
className: classes.root,
|
|
@@ -44,9 +43,8 @@ function DefaultChartsAxisTooltipContent(props) {
|
|
|
44
43
|
valueFormatter,
|
|
45
44
|
data
|
|
46
45
|
}) => {
|
|
47
|
-
var _data$dataIndex;
|
|
48
46
|
// @ts-ignore
|
|
49
|
-
const formattedValue = valueFormatter(
|
|
47
|
+
const formattedValue = valueFormatter(data[dataIndex] ?? null);
|
|
50
48
|
if (formattedValue == null) {
|
|
51
49
|
return null;
|
|
52
50
|
}
|
|
@@ -5,14 +5,13 @@ import { ChartsTooltipTable, ChartsTooltipCell, ChartsTooltipMark, ChartsTooltip
|
|
|
5
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
6
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
7
|
function DefaultChartsItemTooltipContent(props) {
|
|
8
|
-
var _series$valueFormatte;
|
|
9
8
|
const {
|
|
10
9
|
series,
|
|
11
10
|
itemData,
|
|
12
11
|
sx,
|
|
13
12
|
classes
|
|
14
13
|
} = props;
|
|
15
|
-
if (itemData.dataIndex === undefined) {
|
|
14
|
+
if (itemData.dataIndex === undefined || !series.data[itemData.dataIndex]) {
|
|
16
15
|
return null;
|
|
17
16
|
}
|
|
18
17
|
const {
|
|
@@ -26,7 +25,7 @@ function DefaultChartsItemTooltipContent(props) {
|
|
|
26
25
|
displayedLabel: series.label
|
|
27
26
|
};
|
|
28
27
|
const value = series.data[itemData.dataIndex];
|
|
29
|
-
const formattedValue =
|
|
28
|
+
const formattedValue = series.valueFormatter?.(value);
|
|
30
29
|
return /*#__PURE__*/_jsx(ChartsTooltipPaper, {
|
|
31
30
|
sx: sx,
|
|
32
31
|
className: classes.root,
|
|
@@ -10,7 +10,6 @@ import { getValueToPositionMapper } from '../hooks/useScale';
|
|
|
10
10
|
import { getSVGPoint } from '../internals/utils';
|
|
11
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
12
|
function ChartsVoronoiHandler(props) {
|
|
13
|
-
var _React$useContext$sca;
|
|
14
13
|
const {
|
|
15
14
|
voronoiMaxRadius,
|
|
16
15
|
onItemClick
|
|
@@ -34,7 +33,7 @@ function ChartsVoronoiHandler(props) {
|
|
|
34
33
|
const {
|
|
35
34
|
series,
|
|
36
35
|
seriesOrder
|
|
37
|
-
} =
|
|
36
|
+
} = React.useContext(SeriesContext).scatter ?? {};
|
|
38
37
|
const voronoiRef = React.useRef({});
|
|
39
38
|
const defaultXAxisId = xAxisIds[0];
|
|
40
39
|
const defaultYAxisId = yAxisIds[0];
|
|
@@ -65,8 +64,8 @@ function ChartsVoronoiHandler(props) {
|
|
|
65
64
|
xAxisKey,
|
|
66
65
|
yAxisKey
|
|
67
66
|
} = series[seriesId];
|
|
68
|
-
const xScale = xAxis[xAxisKey
|
|
69
|
-
const yScale = yAxis[yAxisKey
|
|
67
|
+
const xScale = xAxis[xAxisKey ?? defaultXAxisId].scale;
|
|
68
|
+
const yScale = yAxis[yAxisKey ?? defaultYAxisId].scale;
|
|
70
69
|
const getXPosition = getValueToPositionMapper(xScale);
|
|
71
70
|
const getYPosition = getValueToPositionMapper(yScale);
|
|
72
71
|
const seriesPoints = data.flatMap(({
|
|
@@ -89,7 +88,6 @@ function ChartsVoronoiHandler(props) {
|
|
|
89
88
|
|
|
90
89
|
// TODO: A perf optimisation of voronoi could be to use the last point as the intial point for the next search.
|
|
91
90
|
function getClosestPoint(event) {
|
|
92
|
-
var _voronoiRef$current$d;
|
|
93
91
|
// Get mouse coordinate in global SVG space
|
|
94
92
|
const svgPoint = getSVGPoint(svgRef.current, event);
|
|
95
93
|
const outsideX = svgPoint.x < left || svgPoint.x > left + width;
|
|
@@ -100,7 +98,7 @@ function ChartsVoronoiHandler(props) {
|
|
|
100
98
|
if (!voronoiRef.current.delauney) {
|
|
101
99
|
return 'no-point-found';
|
|
102
100
|
}
|
|
103
|
-
const closestPointIndex =
|
|
101
|
+
const closestPointIndex = voronoiRef.current.delauney?.find(svgPoint.x, svgPoint.y);
|
|
104
102
|
if (closestPointIndex === undefined) {
|
|
105
103
|
return 'no-point-found';
|
|
106
104
|
}
|
|
@@ -72,7 +72,7 @@ function addLabelDimension(xTicks, {
|
|
|
72
72
|
labelOffset,
|
|
73
73
|
height
|
|
74
74
|
} = item;
|
|
75
|
-
const distance = getMinXTranslation(width, height, style
|
|
75
|
+
const distance = getMinXTranslation(width, height, style?.angle);
|
|
76
76
|
const textPosition = offset + labelOffset;
|
|
77
77
|
const gapRatio = 1.2; // Ratio applied to the minimal distance to add some margin.
|
|
78
78
|
|
|
@@ -105,7 +105,6 @@ const defaultProps = {
|
|
|
105
105
|
* - [ChartsXAxis API](https://mui.com/x/api/charts/charts-x-axis/)
|
|
106
106
|
*/
|
|
107
107
|
function ChartsXAxis(inProps) {
|
|
108
|
-
var _props$axisId, _slots$axisLine, _slots$axisTick, _slots$axisTickLabel, _slots$axisLabel;
|
|
109
108
|
const props = useThemeProps({
|
|
110
109
|
props: _extends({}, defaultProps, inProps),
|
|
111
110
|
name: 'MuiChartsXAxis'
|
|
@@ -114,7 +113,7 @@ function ChartsXAxis(inProps) {
|
|
|
114
113
|
xAxisIds
|
|
115
114
|
} = React.useContext(CartesianContext);
|
|
116
115
|
const _React$useContext = React.useContext(CartesianContext),
|
|
117
|
-
_ref =
|
|
116
|
+
_ref = props.axisId ?? xAxisIds[0],
|
|
118
117
|
{
|
|
119
118
|
xAxis: {
|
|
120
119
|
[_ref]: {
|
|
@@ -157,18 +156,18 @@ function ChartsXAxis(inProps) {
|
|
|
157
156
|
} = React.useContext(DrawingContext);
|
|
158
157
|
const tickSize = disableTicks ? 4 : tickSizeProp;
|
|
159
158
|
const positionSign = position === 'bottom' ? 1 : -1;
|
|
160
|
-
const Line =
|
|
161
|
-
const Tick =
|
|
162
|
-
const TickLabel =
|
|
163
|
-
const Label =
|
|
159
|
+
const Line = slots?.axisLine ?? 'line';
|
|
160
|
+
const Tick = slots?.axisTick ?? 'line';
|
|
161
|
+
const TickLabel = slots?.axisTickLabel ?? ChartsText;
|
|
162
|
+
const Label = slots?.axisLabel ?? ChartsText;
|
|
164
163
|
const axisTickLabelProps = useSlotProps({
|
|
165
164
|
elementType: TickLabel,
|
|
166
|
-
externalSlotProps: slotProps
|
|
165
|
+
externalSlotProps: slotProps?.axisTickLabel,
|
|
167
166
|
additionalProps: {
|
|
168
167
|
style: _extends({
|
|
169
168
|
textAnchor: 'middle',
|
|
170
169
|
dominantBaseline: position === 'bottom' ? 'hanging' : 'auto',
|
|
171
|
-
fontSize: tickFontSize
|
|
170
|
+
fontSize: tickFontSize ?? 12
|
|
172
171
|
}, tickLabelStyle),
|
|
173
172
|
className: classes.tickLabel
|
|
174
173
|
},
|
|
@@ -195,10 +194,10 @@ function ChartsXAxis(inProps) {
|
|
|
195
194
|
};
|
|
196
195
|
const axisLabelProps = useSlotProps({
|
|
197
196
|
elementType: Label,
|
|
198
|
-
externalSlotProps: slotProps
|
|
197
|
+
externalSlotProps: slotProps?.axisLabel,
|
|
199
198
|
additionalProps: {
|
|
200
199
|
style: _extends({
|
|
201
|
-
fontSize: labelFontSize
|
|
200
|
+
fontSize: labelFontSize ?? 14,
|
|
202
201
|
textAnchor: 'middle',
|
|
203
202
|
dominantBaseline: position === 'bottom' ? 'hanging' : 'auto'
|
|
204
203
|
}, labelStyle)
|
|
@@ -212,13 +211,13 @@ function ChartsXAxis(inProps) {
|
|
|
212
211
|
x1: xScale.range()[0],
|
|
213
212
|
x2: xScale.range()[1],
|
|
214
213
|
className: classes.line
|
|
215
|
-
}, slotProps
|
|
214
|
+
}, slotProps?.axisLine)), xTicksWithDimension.map(({
|
|
216
215
|
formattedValue,
|
|
217
216
|
offset,
|
|
218
217
|
labelOffset,
|
|
219
218
|
skipLabel
|
|
220
219
|
}, index) => {
|
|
221
|
-
const xTickLabel = labelOffset
|
|
220
|
+
const xTickLabel = labelOffset ?? 0;
|
|
222
221
|
const yTickLabel = positionSign * (tickSize + 3);
|
|
223
222
|
return /*#__PURE__*/_jsxs("g", {
|
|
224
223
|
transform: `translate(${offset}, 0)`,
|
|
@@ -226,7 +225,7 @@ function ChartsXAxis(inProps) {
|
|
|
226
225
|
children: [!disableTicks && /*#__PURE__*/_jsx(Tick, _extends({
|
|
227
226
|
y2: positionSign * tickSize,
|
|
228
227
|
className: classes.tick
|
|
229
|
-
}, slotProps
|
|
228
|
+
}, slotProps?.axisTick)), formattedValue !== undefined && !skipLabel && /*#__PURE__*/_jsx(TickLabel, _extends({
|
|
230
229
|
x: xTickLabel,
|
|
231
230
|
y: yTickLabel
|
|
232
231
|
}, axisTickLabelProps, {
|
|
@@ -48,7 +48,6 @@ const defaultProps = {
|
|
|
48
48
|
* - [ChartsYAxis API](https://mui.com/x/api/charts/charts-y-axis/)
|
|
49
49
|
*/
|
|
50
50
|
function ChartsYAxis(inProps) {
|
|
51
|
-
var _props$axisId, _slots$axisLine, _slots$axisTick, _slots$axisTickLabel, _slots$axisLabel;
|
|
52
51
|
const props = useThemeProps({
|
|
53
52
|
props: _extends({}, defaultProps, inProps),
|
|
54
53
|
name: 'MuiChartsYAxis'
|
|
@@ -57,7 +56,7 @@ function ChartsYAxis(inProps) {
|
|
|
57
56
|
yAxisIds
|
|
58
57
|
} = React.useContext(CartesianContext);
|
|
59
58
|
const _React$useContext = React.useContext(CartesianContext),
|
|
60
|
-
_ref =
|
|
59
|
+
_ref = props.axisId ?? yAxisIds[0],
|
|
61
60
|
{
|
|
62
61
|
yAxis: {
|
|
63
62
|
[_ref]: {
|
|
@@ -107,13 +106,13 @@ function ChartsYAxis(inProps) {
|
|
|
107
106
|
x: positionSign * (tickFontSize + tickSize + 10),
|
|
108
107
|
y: top + height / 2
|
|
109
108
|
};
|
|
110
|
-
const Line =
|
|
111
|
-
const Tick =
|
|
112
|
-
const TickLabel =
|
|
113
|
-
const Label =
|
|
109
|
+
const Line = slots?.axisLine ?? 'line';
|
|
110
|
+
const Tick = slots?.axisTick ?? 'line';
|
|
111
|
+
const TickLabel = slots?.axisTickLabel ?? ChartsText;
|
|
112
|
+
const Label = slots?.axisLabel ?? ChartsText;
|
|
114
113
|
const axisTickLabelProps = useSlotProps({
|
|
115
114
|
elementType: TickLabel,
|
|
116
|
-
externalSlotProps: slotProps
|
|
115
|
+
externalSlotProps: slotProps?.axisTickLabel,
|
|
117
116
|
additionalProps: {
|
|
118
117
|
style: _extends({
|
|
119
118
|
fontSize: tickFontSize,
|
|
@@ -126,7 +125,7 @@ function ChartsYAxis(inProps) {
|
|
|
126
125
|
});
|
|
127
126
|
const axisLabelProps = useSlotProps({
|
|
128
127
|
elementType: Label,
|
|
129
|
-
externalSlotProps: slotProps
|
|
128
|
+
externalSlotProps: slotProps?.axisLabel,
|
|
130
129
|
additionalProps: {
|
|
131
130
|
style: _extends({
|
|
132
131
|
fontSize: labelFontSize,
|
|
@@ -144,7 +143,7 @@ function ChartsYAxis(inProps) {
|
|
|
144
143
|
y1: yScale.range()[0],
|
|
145
144
|
y2: yScale.range()[1],
|
|
146
145
|
className: classes.line
|
|
147
|
-
}, slotProps
|
|
146
|
+
}, slotProps?.axisLine)), yTicks.map(({
|
|
148
147
|
formattedValue,
|
|
149
148
|
offset,
|
|
150
149
|
labelOffset
|
|
@@ -157,7 +156,7 @@ function ChartsYAxis(inProps) {
|
|
|
157
156
|
children: [!disableTicks && /*#__PURE__*/_jsx(Tick, _extends({
|
|
158
157
|
x2: positionSign * tickSize,
|
|
159
158
|
className: classes.tick
|
|
160
|
-
}, slotProps
|
|
159
|
+
}, slotProps?.axisTick)), formattedValue !== undefined && /*#__PURE__*/_jsx(TickLabel, _extends({
|
|
161
160
|
x: xTickLabel,
|
|
162
161
|
y: yTickLabel,
|
|
163
162
|
text: formattedValue.toString()
|
|
@@ -16,27 +16,24 @@ const ResizableContainer = styled('div', {
|
|
|
16
16
|
})(({
|
|
17
17
|
ownerState,
|
|
18
18
|
theme
|
|
19
|
-
}) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
'
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
});
|
|
19
|
+
}) => ({
|
|
20
|
+
width: ownerState.width ?? '100%',
|
|
21
|
+
height: ownerState.height ?? '100%',
|
|
22
|
+
display: 'flex',
|
|
23
|
+
position: 'relative',
|
|
24
|
+
flexGrow: 1,
|
|
25
|
+
flexDirection: 'column',
|
|
26
|
+
alignItems: 'center',
|
|
27
|
+
justifyContent: 'center',
|
|
28
|
+
overflow: 'hidden',
|
|
29
|
+
'&>svg': {
|
|
30
|
+
width: '100%',
|
|
31
|
+
height: '100%'
|
|
32
|
+
},
|
|
33
|
+
'& text': {
|
|
34
|
+
fill: (theme.vars || theme).palette.text.primary
|
|
35
|
+
}
|
|
36
|
+
}));
|
|
40
37
|
const GaugeContainer = /*#__PURE__*/React.forwardRef(function GaugeContainer(props, ref) {
|
|
41
38
|
const {
|
|
42
39
|
width: inWidth,
|
|
@@ -57,9 +57,9 @@ export function GaugeProvider(props) {
|
|
|
57
57
|
const usedHeight = maxRadius * (ratios.maxY - ratios.minY);
|
|
58
58
|
cy = top + (height - usedHeight) / 2 + ratios.cy * usedHeight;
|
|
59
59
|
}
|
|
60
|
-
const outerRadius = getPercentageValue(outerRadiusParam
|
|
61
|
-
const innerRadius = getPercentageValue(innerRadiusParam
|
|
62
|
-
const cornerRadius = getPercentageValue(cornerRadiusParam
|
|
60
|
+
const outerRadius = getPercentageValue(outerRadiusParam ?? maxRadius, maxRadius);
|
|
61
|
+
const innerRadius = getPercentageValue(innerRadiusParam ?? '80%', maxRadius);
|
|
62
|
+
const cornerRadius = getPercentageValue(cornerRadiusParam ?? 0, outerRadius - innerRadius);
|
|
63
63
|
const contextValue = React.useMemo(() => {
|
|
64
64
|
const startAngleRad = Math.PI * startAngle / 180;
|
|
65
65
|
const endAngleRad = Math.PI * endAngle / 180;
|
|
@@ -38,7 +38,6 @@ const useUtilityClasses = ownerState => {
|
|
|
38
38
|
* - [AreaElement API](https://mui.com/x/api/charts/area-element/)
|
|
39
39
|
*/
|
|
40
40
|
function AreaElement(props) {
|
|
41
|
-
var _slots$area;
|
|
42
41
|
const {
|
|
43
42
|
id,
|
|
44
43
|
classes: innerClasses,
|
|
@@ -69,10 +68,10 @@ function AreaElement(props) {
|
|
|
69
68
|
isHighlighted
|
|
70
69
|
};
|
|
71
70
|
const classes = useUtilityClasses(ownerState);
|
|
72
|
-
const Area =
|
|
71
|
+
const Area = slots?.area ?? AnimatedArea;
|
|
73
72
|
const areaProps = useSlotProps({
|
|
74
73
|
elementType: Area,
|
|
75
|
-
externalSlotProps: slotProps
|
|
74
|
+
externalSlotProps: slotProps?.area,
|
|
76
75
|
additionalProps: _extends({}, other, getInteractionItemProps({
|
|
77
76
|
type: 'line',
|
|
78
77
|
seriesId: id
|
|
@@ -33,7 +33,6 @@ const useAggregatedData = () => {
|
|
|
33
33
|
ids: groupIds
|
|
34
34
|
}) => {
|
|
35
35
|
return groupIds.flatMap(seriesId => {
|
|
36
|
-
var _xData$map;
|
|
37
36
|
const {
|
|
38
37
|
xAxisKey = defaultXAxisId,
|
|
39
38
|
yAxisKey = defaultYAxisId,
|
|
@@ -54,10 +53,10 @@ const useAggregatedData = () => {
|
|
|
54
53
|
}
|
|
55
54
|
const areaPath = d3Area().x(d => xScale(d.x)).defined((_, i) => connectNulls || data[i] != null).y0(d => d.y && yScale(d.y[0])).y1(d => d.y && yScale(d.y[1]));
|
|
56
55
|
const curve = getCurveFactory(series[seriesId].curve);
|
|
57
|
-
const formattedData =
|
|
56
|
+
const formattedData = xData?.map((x, index) => ({
|
|
58
57
|
x,
|
|
59
58
|
y: stackedData[index]
|
|
60
|
-
}))
|
|
59
|
+
})) ?? [];
|
|
61
60
|
const d3Data = connectNulls ? formattedData.filter((_, i) => data[i] != null) : formattedData;
|
|
62
61
|
const d = areaPath.curve(curve)(d3Data) || '';
|
|
63
62
|
return _extends({}, series[seriesId], {
|
|
@@ -69,21 +69,18 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
|
|
|
69
69
|
width: width,
|
|
70
70
|
height: height,
|
|
71
71
|
margin: margin,
|
|
72
|
-
xAxis: xAxis
|
|
72
|
+
xAxis: xAxis ?? [{
|
|
73
73
|
id: DEFAULT_X_AXIS_KEY,
|
|
74
74
|
scaleType: 'point',
|
|
75
75
|
data: Array.from({
|
|
76
|
-
length: Math.max(...series.map(s =>
|
|
77
|
-
var _ref, _s$data;
|
|
78
|
-
return ((_ref = (_s$data = s.data) != null ? _s$data : dataset) != null ? _ref : []).length;
|
|
79
|
-
}))
|
|
76
|
+
length: Math.max(...series.map(s => (s.data ?? dataset ?? []).length))
|
|
80
77
|
}, (_, index) => index)
|
|
81
78
|
}],
|
|
82
79
|
yAxis: yAxis,
|
|
83
80
|
colors: colors,
|
|
84
81
|
dataset: dataset,
|
|
85
82
|
sx: sx,
|
|
86
|
-
disableAxisListener:
|
|
83
|
+
disableAxisListener: tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none' && !onAxisClick,
|
|
87
84
|
children: [onAxisClick && /*#__PURE__*/_jsx(ChartsOnAxisClickHandler, {
|
|
88
85
|
onAxisClick: onAxisClick
|
|
89
86
|
}), grid && /*#__PURE__*/_jsx(ChartsGrid, {
|
|
@@ -38,7 +38,6 @@ const useUtilityClasses = ownerState => {
|
|
|
38
38
|
* - [LineElement API](https://mui.com/x/api/charts/line-element/)
|
|
39
39
|
*/
|
|
40
40
|
function LineElement(props) {
|
|
41
|
-
var _slots$line;
|
|
42
41
|
const {
|
|
43
42
|
id,
|
|
44
43
|
classes: innerClasses,
|
|
@@ -69,10 +68,10 @@ function LineElement(props) {
|
|
|
69
68
|
isHighlighted
|
|
70
69
|
};
|
|
71
70
|
const classes = useUtilityClasses(ownerState);
|
|
72
|
-
const Line =
|
|
71
|
+
const Line = slots?.line ?? AnimatedLine;
|
|
73
72
|
const lineProps = useSlotProps({
|
|
74
73
|
elementType: Line,
|
|
75
|
-
externalSlotProps: slotProps
|
|
74
|
+
externalSlotProps: slotProps?.line,
|
|
76
75
|
additionalProps: _extends({}, other, getInteractionItemProps({
|
|
77
76
|
type: 'line',
|
|
78
77
|
seriesId: id
|
|
@@ -21,7 +21,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
21
21
|
* - [LineHighlightPlot API](https://mui.com/x/api/charts/line-highlight-plot/)
|
|
22
22
|
*/
|
|
23
23
|
function LineHighlightPlot(props) {
|
|
24
|
-
var _axis$x, _slots$lineHighlight;
|
|
25
24
|
const {
|
|
26
25
|
slots,
|
|
27
26
|
slotProps
|
|
@@ -32,7 +31,7 @@ function LineHighlightPlot(props) {
|
|
|
32
31
|
const {
|
|
33
32
|
axis
|
|
34
33
|
} = React.useContext(InteractionContext);
|
|
35
|
-
const highlightedIndex =
|
|
34
|
+
const highlightedIndex = axis.x?.index;
|
|
36
35
|
if (highlightedIndex === undefined) {
|
|
37
36
|
return null;
|
|
38
37
|
}
|
|
@@ -51,7 +50,7 @@ function LineHighlightPlot(props) {
|
|
|
51
50
|
} = axisData;
|
|
52
51
|
const defaultXAxisId = xAxisIds[0];
|
|
53
52
|
const defaultYAxisId = yAxisIds[0];
|
|
54
|
-
const Element =
|
|
53
|
+
const Element = slots?.lineHighlight ?? LineHighlightElement;
|
|
55
54
|
return /*#__PURE__*/_jsx("g", _extends({}, other, {
|
|
56
55
|
children: stackingGroups.flatMap(({
|
|
57
56
|
ids: groupIds
|
|
@@ -80,7 +79,7 @@ function LineHighlightPlot(props) {
|
|
|
80
79
|
color: series[seriesId].color,
|
|
81
80
|
x: x,
|
|
82
81
|
y: y
|
|
83
|
-
}, slotProps
|
|
82
|
+
}, slotProps?.lineHighlight), `${seriesId}`);
|
|
84
83
|
});
|
|
85
84
|
})
|
|
86
85
|
}));
|
|
@@ -33,7 +33,6 @@ const useAggregatedData = () => {
|
|
|
33
33
|
ids: groupIds
|
|
34
34
|
}) => {
|
|
35
35
|
return groupIds.flatMap(seriesId => {
|
|
36
|
-
var _xData$map;
|
|
37
36
|
const {
|
|
38
37
|
xAxisKey = defaultXAxisId,
|
|
39
38
|
yAxisKey = defaultYAxisId,
|
|
@@ -53,10 +52,10 @@ const useAggregatedData = () => {
|
|
|
53
52
|
}
|
|
54
53
|
}
|
|
55
54
|
const linePath = d3Line().x(d => xScale(d.x)).defined((_, i) => connectNulls || data[i] != null).y(d => yScale(d.y[1]));
|
|
56
|
-
const formattedData =
|
|
55
|
+
const formattedData = xData?.map((x, index) => ({
|
|
57
56
|
x,
|
|
58
57
|
y: stackedData[index]
|
|
59
|
-
}))
|
|
58
|
+
})) ?? [];
|
|
60
59
|
const d3Data = connectNulls ? formattedData.filter((_, i) => data[i] != null) : formattedData;
|
|
61
60
|
const d = linePath.curve(getCurveFactory(series[seriesId].curve))(d3Data) || '';
|
|
62
61
|
return _extends({}, series[seriesId], {
|
|
@@ -67,7 +67,6 @@ MarkElementPath.propTypes = {
|
|
|
67
67
|
* - [MarkElement API](https://mui.com/x/api/charts/mark-element/)
|
|
68
68
|
*/
|
|
69
69
|
function MarkElement(props) {
|
|
70
|
-
var _axis$x;
|
|
71
70
|
const {
|
|
72
71
|
x,
|
|
73
72
|
y,
|
|
@@ -86,7 +85,7 @@ function MarkElement(props) {
|
|
|
86
85
|
item,
|
|
87
86
|
axis
|
|
88
87
|
} = React.useContext(InteractionContext);
|
|
89
|
-
const isHighlighted =
|
|
88
|
+
const isHighlighted = axis.x?.index === dataIndex || getIsHighlighted(item, {
|
|
90
89
|
type: 'line',
|
|
91
90
|
seriesId: id
|
|
92
91
|
}, highlightScope);
|
|
@@ -22,7 +22,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
22
22
|
* - [MarkPlot API](https://mui.com/x/api/charts/mark-plot/)
|
|
23
23
|
*/
|
|
24
24
|
function MarkPlot(props) {
|
|
25
|
-
var _slots$mark;
|
|
26
25
|
const {
|
|
27
26
|
slots,
|
|
28
27
|
slotProps,
|
|
@@ -35,7 +34,7 @@ function MarkPlot(props) {
|
|
|
35
34
|
const {
|
|
36
35
|
chartId
|
|
37
36
|
} = React.useContext(DrawingContext);
|
|
38
|
-
const Mark =
|
|
37
|
+
const Mark = slots?.mark ?? MarkElement;
|
|
39
38
|
if (seriesData === undefined) {
|
|
40
39
|
return null;
|
|
41
40
|
}
|
|
@@ -90,7 +89,7 @@ function MarkPlot(props) {
|
|
|
90
89
|
|
|
91
90
|
return /*#__PURE__*/_jsx("g", {
|
|
92
91
|
clipPath: `url(#${clipId})`,
|
|
93
|
-
children: xData
|
|
92
|
+
children: xData?.map((x, index) => {
|
|
94
93
|
const value = data[index] == null ? null : stackedData[index][1];
|
|
95
94
|
return {
|
|
96
95
|
x: xScale(x),
|
|
@@ -147,7 +146,7 @@ function MarkPlot(props) {
|
|
|
147
146
|
seriesId,
|
|
148
147
|
dataIndex: index
|
|
149
148
|
}))
|
|
150
|
-
}, slotProps
|
|
149
|
+
}, slotProps?.mark), `${seriesId}-${index}`);
|
|
151
150
|
})
|
|
152
151
|
}, seriesId);
|
|
153
152
|
});
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
export const getExtremumX = params => {
|
|
2
|
-
var _axis$data, _axis$data2;
|
|
3
2
|
const {
|
|
4
3
|
axis
|
|
5
4
|
} = params;
|
|
6
|
-
const minX = Math.min(...(
|
|
7
|
-
const maxX = Math.max(...(
|
|
5
|
+
const minX = Math.min(...(axis.data ?? []));
|
|
6
|
+
const maxX = Math.max(...(axis.data ?? []));
|
|
8
7
|
return [minX, maxX];
|
|
9
8
|
};
|
|
10
9
|
function getSeriesExtremums(getValues, stackedData) {
|
|
@@ -6,7 +6,6 @@ let warnedOnce = false;
|
|
|
6
6
|
|
|
7
7
|
// For now it's a copy past of bar charts formatter, but maybe will diverge later
|
|
8
8
|
const formatter = (params, dataset) => {
|
|
9
|
-
var _ref;
|
|
10
9
|
const {
|
|
11
10
|
seriesOrder,
|
|
12
11
|
series
|
|
@@ -18,7 +17,7 @@ const formatter = (params, dataset) => {
|
|
|
18
17
|
}));
|
|
19
18
|
|
|
20
19
|
// Create a data set with format adapted to d3
|
|
21
|
-
const d3Dataset =
|
|
20
|
+
const d3Dataset = dataset ?? [];
|
|
22
21
|
seriesOrder.forEach(id => {
|
|
23
22
|
const data = series[id].data;
|
|
24
23
|
if (data !== undefined) {
|
|
@@ -47,10 +46,7 @@ const formatter = (params, dataset) => {
|
|
|
47
46
|
// Use dataKey if needed and available
|
|
48
47
|
const dataKey = series[id].dataKey;
|
|
49
48
|
return series[id].data === undefined && dataKey !== undefined ? dataKey : id;
|
|
50
|
-
})).value((d, key) =>
|
|
51
|
-
var _d$key;
|
|
52
|
-
return (_d$key = d[key]) != null ? _d$key : 0;
|
|
53
|
-
}) // defaultize null value to 0
|
|
49
|
+
})).value((d, key) => d[key] ?? 0) // defaultize null value to 0
|
|
54
50
|
.order(stackingOrder).offset(stackingOffset)(d3Dataset);
|
|
55
51
|
ids.forEach((id, index) => {
|
|
56
52
|
const dataKey = series[id].dataKey;
|
|
@@ -19,13 +19,11 @@ function getItemLabel(arcLabel, arcLabelMinAngle, item) {
|
|
|
19
19
|
return null;
|
|
20
20
|
}
|
|
21
21
|
if (typeof arcLabel === 'string') {
|
|
22
|
-
|
|
23
|
-
return (_item$arcLabel = item[arcLabel]) == null ? void 0 : _item$arcLabel.toString();
|
|
22
|
+
return item[arcLabel]?.toString();
|
|
24
23
|
}
|
|
25
24
|
return arcLabel(item);
|
|
26
25
|
}
|
|
27
26
|
function PieArcLabelPlot(props) {
|
|
28
|
-
var _slots$pieArcLabel;
|
|
29
27
|
const {
|
|
30
28
|
arcLabel,
|
|
31
29
|
arcLabelMinAngle = 0,
|
|
@@ -64,7 +62,7 @@ function PieArcLabelPlot(props) {
|
|
|
64
62
|
if (data.length === 0) {
|
|
65
63
|
return null;
|
|
66
64
|
}
|
|
67
|
-
const ArcLabel =
|
|
65
|
+
const ArcLabel = slots?.pieArcLabel ?? PieArcLabel;
|
|
68
66
|
return /*#__PURE__*/_jsx("g", _extends({}, other, {
|
|
69
67
|
children: transition((_ref, item) => {
|
|
70
68
|
let {
|
|
@@ -91,7 +89,7 @@ function PieArcLabelPlot(props) {
|
|
|
91
89
|
isFaded: item.isFaded,
|
|
92
90
|
isHighlighted: item.isHighlighted,
|
|
93
91
|
formattedArcLabel: getItemLabel(arcLabel, arcLabelMinAngle, item)
|
|
94
|
-
}, slotProps
|
|
92
|
+
}, slotProps?.pieArcLabel));
|
|
95
93
|
})
|
|
96
94
|
}));
|
|
97
95
|
}
|