@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.
Files changed (59) hide show
  1. package/CHANGELOG.md +266 -12
  2. package/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
  3. package/README.md +1 -1
  4. package/context/CartesianContextProvider.js +2 -2
  5. package/esm/BarChart/BarChart.js +6 -9
  6. package/esm/BarChart/BarElement.js +2 -3
  7. package/esm/BarChart/BarPlot.js +5 -8
  8. package/esm/BarChart/extremums.js +2 -3
  9. package/esm/BarChart/formatter.js +2 -6
  10. package/esm/ChartsAxis/ChartsAxis.js +3 -4
  11. package/esm/ChartsLegend/ChartsLegend.js +2 -3
  12. package/esm/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -4
  13. package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +2 -3
  14. package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +2 -3
  15. package/esm/ChartsText/ChartsText.js +1 -1
  16. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
  17. package/esm/ChartsTooltip/ChartsItemTooltipContent.js +1 -1
  18. package/esm/ChartsTooltip/ChartsTooltip.js +6 -7
  19. package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -4
  20. package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +2 -3
  21. package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +4 -6
  22. package/esm/ChartsXAxis/ChartsXAxis.js +13 -14
  23. package/esm/ChartsYAxis/ChartsYAxis.js +9 -10
  24. package/esm/Gauge/GaugeContainer.js +18 -21
  25. package/esm/Gauge/GaugeProvider.js +3 -3
  26. package/esm/LineChart/AreaElement.js +2 -3
  27. package/esm/LineChart/AreaPlot.js +2 -3
  28. package/esm/LineChart/LineChart.js +3 -6
  29. package/esm/LineChart/LineElement.js +2 -3
  30. package/esm/LineChart/LineHighlightPlot.js +3 -4
  31. package/esm/LineChart/LinePlot.js +2 -3
  32. package/esm/LineChart/MarkElement.js +1 -2
  33. package/esm/LineChart/MarkPlot.js +3 -4
  34. package/esm/LineChart/extremums.js +2 -3
  35. package/esm/LineChart/formatter.js +2 -6
  36. package/esm/PieChart/PieArcLabelPlot.js +3 -5
  37. package/esm/PieChart/PieArcPlot.js +2 -3
  38. package/esm/PieChart/PieChart.js +2 -2
  39. package/esm/PieChart/PiePlot.js +9 -9
  40. package/esm/PieChart/dataTransform/useTransformData.js +5 -6
  41. package/esm/PieChart/formatter.js +6 -13
  42. package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +15 -18
  43. package/esm/ResponsiveChartContainer/useChartContainerDimensions.js +2 -2
  44. package/esm/ScatterChart/ScatterPlot.js +5 -6
  45. package/esm/SparkLineChart/SparkLineChart.js +1 -1
  46. package/esm/context/CartesianContextProvider.js +18 -24
  47. package/esm/context/DrawingProvider.js +1 -1
  48. package/esm/context/SeriesContextProvider.js +2 -4
  49. package/esm/hooks/useAxisEvents.js +1 -1
  50. package/esm/hooks/useInteractionItemProps.js +2 -2
  51. package/esm/hooks/useScale.js +2 -2
  52. package/esm/hooks/useTicks.js +23 -32
  53. package/esm/internals/defaultizeValueFormatter.js +1 -2
  54. package/esm/internals/stackSeries.js +2 -3
  55. package/index.js +1 -1
  56. package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
  57. package/modern/context/CartesianContextProvider.js +2 -2
  58. package/modern/index.js +1 -1
  59. 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 != null ? content : DefaultChartsAxisTooltipContent;
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 != null ? content : DefaultChartsItemTooltipContent;
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 = (_slots$popper = slots == null ? void 0 : slots.popper) != null ? _slots$popper : ChartsTooltipRoot;
74
+ const PopperComponent = slots?.popper ?? ChartsTooltipRoot;
76
75
  const popperProps = useSlotProps({
77
76
  elementType: PopperComponent,
78
- externalSlotProps: slotProps == null ? void 0 : slotProps.popper,
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: (_slots$itemContent = slots == null ? void 0 : slots.itemContent) != null ? _slots$itemContent : itemContent,
94
- contentProps: slotProps == null ? void 0 : slotProps.itemContent,
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: (_slots$axisContent = slots == null ? void 0 : slots.axisContent) != null ? _slots$axisContent : axisContent,
102
- contentProps: slotProps == null ? void 0 : slotProps.axisContent,
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 = (_axis$valueFormatter = axis.valueFormatter) != null ? _axis$valueFormatter : v => axis.scaleType === 'utc' ? utcFormatter(v) : v.toLocaleString();
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((_data$dataIndex = data[dataIndex]) != null ? _data$dataIndex : null);
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 = (_series$valueFormatte = series.valueFormatter) == null ? void 0 : _series$valueFormatte.call(series, value);
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
- } = (_React$useContext$sca = React.useContext(SeriesContext).scatter) != null ? _React$useContext$sca : {};
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 != null ? xAxisKey : defaultXAxisId].scale;
69
- const yScale = yAxis[yAxisKey != null ? yAxisKey : defaultYAxisId].scale;
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 = (_voronoiRef$current$d = voronoiRef.current.delauney) == null ? void 0 : _voronoiRef$current$d.find(svgPoint.x, svgPoint.y);
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 == null ? void 0 : style.angle);
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 = (_props$axisId = props.axisId) != null ? _props$axisId : xAxisIds[0],
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 = (_slots$axisLine = slots == null ? void 0 : slots.axisLine) != null ? _slots$axisLine : 'line';
161
- const Tick = (_slots$axisTick = slots == null ? void 0 : slots.axisTick) != null ? _slots$axisTick : 'line';
162
- const TickLabel = (_slots$axisTickLabel = slots == null ? void 0 : slots.axisTickLabel) != null ? _slots$axisTickLabel : ChartsText;
163
- const Label = (_slots$axisLabel = slots == null ? void 0 : slots.axisLabel) != null ? _slots$axisLabel : ChartsText;
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 == null ? void 0 : slotProps.axisTickLabel,
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 != null ? tickFontSize : 12
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 == null ? void 0 : slotProps.axisLabel,
197
+ externalSlotProps: slotProps?.axisLabel,
199
198
  additionalProps: {
200
199
  style: _extends({
201
- fontSize: labelFontSize != null ? labelFontSize : 14,
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 == null ? void 0 : slotProps.axisLine)), xTicksWithDimension.map(({
214
+ }, slotProps?.axisLine)), xTicksWithDimension.map(({
216
215
  formattedValue,
217
216
  offset,
218
217
  labelOffset,
219
218
  skipLabel
220
219
  }, index) => {
221
- const xTickLabel = labelOffset != null ? labelOffset : 0;
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 == null ? void 0 : slotProps.axisTick)), formattedValue !== undefined && !skipLabel && /*#__PURE__*/_jsx(TickLabel, _extends({
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 = (_props$axisId = props.axisId) != null ? _props$axisId : yAxisIds[0],
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 = (_slots$axisLine = slots == null ? void 0 : slots.axisLine) != null ? _slots$axisLine : 'line';
111
- const Tick = (_slots$axisTick = slots == null ? void 0 : slots.axisTick) != null ? _slots$axisTick : 'line';
112
- const TickLabel = (_slots$axisTickLabel = slots == null ? void 0 : slots.axisTickLabel) != null ? _slots$axisTickLabel : ChartsText;
113
- const Label = (_slots$axisLabel = slots == null ? void 0 : slots.axisLabel) != null ? _slots$axisLabel : ChartsText;
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 == null ? void 0 : slotProps.axisTickLabel,
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 == null ? void 0 : slotProps.axisLabel,
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 == null ? void 0 : slotProps.axisLine)), yTicks.map(({
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 == null ? void 0 : slotProps.axisTick)), formattedValue !== undefined && /*#__PURE__*/_jsx(TickLabel, _extends({
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
- var _ownerState$width, _ownerState$height;
21
- return {
22
- width: (_ownerState$width = ownerState.width) != null ? _ownerState$width : '100%',
23
- height: (_ownerState$height = ownerState.height) != null ? _ownerState$height : '100%',
24
- display: 'flex',
25
- position: 'relative',
26
- flexGrow: 1,
27
- flexDirection: 'column',
28
- alignItems: 'center',
29
- justifyContent: 'center',
30
- overflow: 'hidden',
31
- '&>svg': {
32
- width: '100%',
33
- height: '100%'
34
- },
35
- '& text': {
36
- fill: (theme.vars || theme).palette.text.primary
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 != null ? outerRadiusParam : maxRadius, maxRadius);
61
- const innerRadius = getPercentageValue(innerRadiusParam != null ? innerRadiusParam : '80%', maxRadius);
62
- const cornerRadius = getPercentageValue(cornerRadiusParam != null ? cornerRadiusParam : 0, outerRadius - innerRadius);
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 = (_slots$area = slots == null ? void 0 : slots.area) != null ? _slots$area : AnimatedArea;
71
+ const Area = slots?.area ?? AnimatedArea;
73
72
  const areaProps = useSlotProps({
74
73
  elementType: Area,
75
- externalSlotProps: slotProps == null ? void 0 : slotProps.area,
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 = (_xData$map = xData == null ? void 0 : xData.map((x, index) => ({
56
+ const formattedData = xData?.map((x, index) => ({
58
57
  x,
59
58
  y: stackedData[index]
60
- }))) != null ? _xData$map : [];
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 != null ? 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: (tooltip == null ? void 0 : tooltip.trigger) !== 'axis' && (axisHighlight == null ? void 0 : axisHighlight.x) === 'none' && (axisHighlight == null ? void 0 : axisHighlight.y) === 'none' && !onAxisClick,
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 = (_slots$line = slots == null ? void 0 : slots.line) != null ? _slots$line : AnimatedLine;
71
+ const Line = slots?.line ?? AnimatedLine;
73
72
  const lineProps = useSlotProps({
74
73
  elementType: Line,
75
- externalSlotProps: slotProps == null ? void 0 : slotProps.line,
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 = (_axis$x = axis.x) == null ? void 0 : _axis$x.index;
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 = (_slots$lineHighlight = slots == null ? void 0 : slots.lineHighlight) != null ? _slots$lineHighlight : LineHighlightElement;
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 == null ? void 0 : slotProps.lineHighlight), `${seriesId}`);
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 = (_xData$map = xData == null ? void 0 : xData.map((x, index) => ({
55
+ const formattedData = xData?.map((x, index) => ({
57
56
  x,
58
57
  y: stackedData[index]
59
- }))) != null ? _xData$map : [];
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 = ((_axis$x = axis.x) == null ? void 0 : _axis$x.index) === dataIndex || getIsHighlighted(item, {
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 = (_slots$mark = slots == null ? void 0 : slots.mark) != null ? _slots$mark : MarkElement;
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 == null ? void 0 : xData.map((x, index) => {
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 == null ? void 0 : slotProps.mark), `${seriesId}-${index}`);
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(...((_axis$data = axis.data) != null ? _axis$data : []));
7
- const maxX = Math.max(...((_axis$data2 = axis.data) != null ? _axis$data2 : []));
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 = (_ref = dataset) != null ? _ref : [];
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
- var _item$arcLabel;
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 = (_slots$pieArcLabel = slots == null ? void 0 : slots.pieArcLabel) != null ? _slots$pieArcLabel : PieArcLabel;
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 == null ? void 0 : slotProps.pieArcLabel));
92
+ }, slotProps?.pieArcLabel));
95
93
  })
96
94
  }));
97
95
  }