@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
@@ -10,7 +10,6 @@ import { defaultTransitionConfig } from './dataTransform/transition';
10
10
  import { useTransformData } from './dataTransform/useTransformData';
11
11
  import { jsx as _jsx } from "react/jsx-runtime";
12
12
  function PieArcPlot(props) {
13
- var _slots$pieArc;
14
13
  const {
15
14
  slots,
16
15
  slotProps,
@@ -46,7 +45,7 @@ function PieArcPlot(props) {
46
45
  if (data.length === 0) {
47
46
  return null;
48
47
  }
49
- const Arc = (_slots$pieArc = slots == null ? void 0 : slots.pieArc) != null ? _slots$pieArc : PieArc;
48
+ const Arc = slots?.pieArc ?? PieArc;
50
49
  return /*#__PURE__*/_jsx("g", _extends({}, other, {
51
50
  children: transition((_ref, item, _, index) => {
52
51
  let {
@@ -79,7 +78,7 @@ function PieArcPlot(props) {
79
78
  dataIndex: index
80
79
  }, item);
81
80
  })
82
- }, slotProps == null ? void 0 : slotProps.pieArc));
81
+ }, slotProps?.pieArc));
83
82
  })
84
83
  }));
85
84
  }
@@ -78,7 +78,7 @@ function PieChart(props) {
78
78
  width: width,
79
79
  height: height,
80
80
  margin: margin,
81
- xAxis: xAxis != null ? xAxis : [{
81
+ xAxis: xAxis ?? [{
82
82
  id: DEFAULT_X_AXIS_KEY,
83
83
  scaleType: 'point',
84
84
  data: [...new Array(Math.max(...series.map(s => s.data.length)))].map((_, index) => index)
@@ -86,7 +86,7 @@ function PieChart(props) {
86
86
  yAxis: yAxis,
87
87
  colors: colors,
88
88
  sx: sx,
89
- disableAxisListener: (tooltip == null ? void 0 : tooltip.trigger) !== 'axis' && (axisHighlight == null ? void 0 : axisHighlight.x) === 'none' && (axisHighlight == null ? void 0 : axisHighlight.y) === 'none',
89
+ disableAxisListener: tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none',
90
90
  children: [/*#__PURE__*/_jsx(ChartsAxis, {
91
91
  topAxis: topAxis,
92
92
  leftAxis: leftAxis,
@@ -53,10 +53,10 @@ function PiePlot(props) {
53
53
  faded,
54
54
  highlightScope
55
55
  } = series[seriesId];
56
- const outerRadius = getPercentageValue(outerRadiusParam != null ? outerRadiusParam : availableRadius, availableRadius);
57
- const innerRadius = getPercentageValue(innerRadiusParam != null ? innerRadiusParam : 0, availableRadius);
58
- const cx = getPercentageValue(cxParam != null ? cxParam : '50%', width);
59
- const cy = getPercentageValue(cyParam != null ? cyParam : '50%', height);
56
+ const outerRadius = getPercentageValue(outerRadiusParam ?? availableRadius, availableRadius);
57
+ const innerRadius = getPercentageValue(innerRadiusParam ?? 0, availableRadius);
58
+ const cx = getPercentageValue(cxParam ?? '50%', width);
59
+ const cy = getPercentageValue(cyParam ?? '50%', height);
60
60
  return /*#__PURE__*/_jsx("g", {
61
61
  transform: `translate(${left + cx}, ${top + cy})`,
62
62
  children: /*#__PURE__*/_jsx(PieArcPlot, {
@@ -89,16 +89,16 @@ function PiePlot(props) {
89
89
  cy: cyParam,
90
90
  highlightScope
91
91
  } = series[seriesId];
92
- const outerRadius = getPercentageValue(outerRadiusParam != null ? outerRadiusParam : availableRadius, availableRadius);
93
- const innerRadius = getPercentageValue(innerRadiusParam != null ? innerRadiusParam : 0, availableRadius);
92
+ const outerRadius = getPercentageValue(outerRadiusParam ?? availableRadius, availableRadius);
93
+ const innerRadius = getPercentageValue(innerRadiusParam ?? 0, availableRadius);
94
94
  const arcLabelRadius = arcLabelRadiusParam === undefined ? (outerRadius + innerRadius) / 2 : getPercentageValue(arcLabelRadiusParam, availableRadius);
95
- const cx = getPercentageValue(cxParam != null ? cxParam : '50%', width);
96
- const cy = getPercentageValue(cyParam != null ? cyParam : '50%', height);
95
+ const cx = getPercentageValue(cxParam ?? '50%', width);
96
+ const cy = getPercentageValue(cyParam ?? '50%', height);
97
97
  return /*#__PURE__*/_jsx("g", {
98
98
  transform: `translate(${left + cx}, ${top + cy})`,
99
99
  children: /*#__PURE__*/_jsx(PieArcLabelPlot, {
100
100
  innerRadius: innerRadius,
101
- outerRadius: outerRadius != null ? outerRadius : availableRadius,
101
+ outerRadius: outerRadius ?? availableRadius,
102
102
  arcLabelRadius: arcLabelRadius,
103
103
  cornerRadius: cornerRadius,
104
104
  paddingAngle: paddingAngle,
@@ -35,7 +35,6 @@ export function useTransformData(series) {
35
35
  };
36
36
  }, [highlightScope, highlightedItem, seriesId]);
37
37
  const dataWithHighlight = React.useMemo(() => data.map((item, itemIndex) => {
38
- var _attributesOverride$p, _attributesOverride$i, _attributesOverride$o, _attributesOverride$c, _ref, _attributesOverride$a;
39
38
  const {
40
39
  isHighlighted,
41
40
  isFaded
@@ -43,11 +42,11 @@ export function useTransformData(series) {
43
42
  const attributesOverride = _extends({
44
43
  additionalRadius: 0
45
44
  }, isFaded && faded || isHighlighted && highlighted || {});
46
- const paddingAngle = Math.max(0, Math.PI * ((_attributesOverride$p = attributesOverride.paddingAngle) != null ? _attributesOverride$p : basePaddingAngle) / 180);
47
- const innerRadius = Math.max(0, (_attributesOverride$i = attributesOverride.innerRadius) != null ? _attributesOverride$i : baseInnerRadius);
48
- const outerRadius = Math.max(0, (_attributesOverride$o = attributesOverride.outerRadius) != null ? _attributesOverride$o : baseOuterRadius + attributesOverride.additionalRadius);
49
- const cornerRadius = (_attributesOverride$c = attributesOverride.cornerRadius) != null ? _attributesOverride$c : baseCornerRadius;
50
- const arcLabelRadius = (_ref = (_attributesOverride$a = attributesOverride.arcLabelRadius) != null ? _attributesOverride$a : baseArcLabelRadius) != null ? _ref : (innerRadius + outerRadius) / 2;
45
+ const paddingAngle = Math.max(0, Math.PI * (attributesOverride.paddingAngle ?? basePaddingAngle) / 180);
46
+ const innerRadius = Math.max(0, attributesOverride.innerRadius ?? baseInnerRadius);
47
+ const outerRadius = Math.max(0, attributesOverride.outerRadius ?? baseOuterRadius + attributesOverride.additionalRadius);
48
+ const cornerRadius = attributesOverride.cornerRadius ?? baseCornerRadius;
49
+ const arcLabelRadius = attributesOverride.arcLabelRadius ?? baseArcLabelRadius ?? (innerRadius + outerRadius) / 2;
51
50
  return _extends({}, item, attributesOverride, {
52
51
  isFaded,
53
52
  isHighlighted,
@@ -22,22 +22,15 @@ const formatter = params => {
22
22
  } = params;
23
23
  const defaultizedSeries = {};
24
24
  seriesOrder.forEach(seriesId => {
25
- var _series$seriesId$star, _series$seriesId$endA, _series$seriesId$padd, _series$seriesId$sort;
26
- const arcs = d3Pie().startAngle(2 * Math.PI * ((_series$seriesId$star = series[seriesId].startAngle) != null ? _series$seriesId$star : 0) / 360).endAngle(2 * Math.PI * ((_series$seriesId$endA = series[seriesId].endAngle) != null ? _series$seriesId$endA : 360) / 360).padAngle(2 * Math.PI * ((_series$seriesId$padd = series[seriesId].paddingAngle) != null ? _series$seriesId$padd : 0) / 360).sortValues(getSortingComparator((_series$seriesId$sort = series[seriesId].sortingValues) != null ? _series$seriesId$sort : 'none'))(series[seriesId].data.map(piePoint => piePoint.value));
25
+ const arcs = d3Pie().startAngle(2 * Math.PI * (series[seriesId].startAngle ?? 0) / 360).endAngle(2 * Math.PI * (series[seriesId].endAngle ?? 360) / 360).padAngle(2 * Math.PI * (series[seriesId].paddingAngle ?? 0) / 360).sortValues(getSortingComparator(series[seriesId].sortingValues ?? 'none'))(series[seriesId].data.map(piePoint => piePoint.value));
27
26
  defaultizedSeries[seriesId] = _extends({
28
27
  valueFormatter: item => item.value.toLocaleString()
29
28
  }, series[seriesId], {
30
- data: series[seriesId].data.map((item, index) => {
31
- var _item$id;
32
- return _extends({}, item, {
33
- id: (_item$id = item.id) != null ? _item$id : `auto-generated-pie-id-${seriesId}-${index}`
34
- }, arcs[index]);
35
- }).map(item => {
36
- var _series$seriesId$valu, _series$seriesId$valu2, _series$seriesId;
37
- return _extends({}, item, {
38
- formattedValue: (_series$seriesId$valu = (_series$seriesId$valu2 = (_series$seriesId = series[seriesId]).valueFormatter) == null ? void 0 : _series$seriesId$valu2.call(_series$seriesId, item)) != null ? _series$seriesId$valu : item.value.toLocaleString()
39
- });
40
- })
29
+ data: series[seriesId].data.map((item, index) => _extends({}, item, {
30
+ id: item.id ?? `auto-generated-pie-id-${seriesId}-${index}`
31
+ }, arcs[index])).map(item => _extends({}, item, {
32
+ formattedValue: series[seriesId].valueFormatter?.(item) ?? item.value.toLocaleString()
33
+ }))
41
34
  });
42
35
  });
43
36
  return {
@@ -12,24 +12,21 @@ const ResizableContainer = styled('div', {
12
12
  slot: 'Container'
13
13
  })(({
14
14
  ownerState
15
- }) => {
16
- var _ownerState$width, _ownerState$height;
17
- return {
18
- width: (_ownerState$width = ownerState.width) != null ? _ownerState$width : '100%',
19
- height: (_ownerState$height = ownerState.height) != null ? _ownerState$height : '100%',
20
- display: 'flex',
21
- position: 'relative',
22
- flexGrow: 1,
23
- flexDirection: 'column',
24
- alignItems: 'center',
25
- justifyContent: 'center',
26
- overflow: 'hidden',
27
- '&>svg': {
28
- width: '100%',
29
- height: '100%'
30
- }
31
- };
32
- });
15
+ }) => ({
16
+ width: ownerState.width ?? '100%',
17
+ height: ownerState.height ?? '100%',
18
+ display: 'flex',
19
+ position: 'relative',
20
+ flexGrow: 1,
21
+ flexDirection: 'column',
22
+ alignItems: 'center',
23
+ justifyContent: 'center',
24
+ overflow: 'hidden',
25
+ '&>svg': {
26
+ width: '100%',
27
+ height: '100%'
28
+ }
29
+ }));
33
30
  const ResponsiveChartContainer = /*#__PURE__*/React.forwardRef(function ResponsiveChartContainer(props, ref) {
34
31
  const {
35
32
  width: inWidth,
@@ -9,7 +9,7 @@ export const useChartContainerDimensions = (inWidth, inHeight) => {
9
9
 
10
10
  // Adaptation of the `computeSizeAndPublishResizeEvent` from the grid.
11
11
  const computeSize = React.useCallback(() => {
12
- const mainEl = rootRef == null ? void 0 : rootRef.current;
12
+ const mainEl = rootRef?.current;
13
13
  if (!mainEl) {
14
14
  return;
15
15
  }
@@ -62,5 +62,5 @@ export const useChartContainerDimensions = (inWidth, inHeight) => {
62
62
  displayError.current = false;
63
63
  }
64
64
  }
65
- return [rootRef, inWidth != null ? inWidth : width, inHeight != null ? inHeight : height];
65
+ return [rootRef, inWidth ?? width, inHeight ?? height];
66
66
  };
@@ -16,7 +16,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
16
16
  * - [ScatterPlot API](https://mui.com/x/api/charts/scatter-plot/)
17
17
  */
18
18
  function ScatterPlot(props) {
19
- var _slots$scatter;
20
19
  const {
21
20
  slots,
22
21
  slotProps,
@@ -39,7 +38,7 @@ function ScatterPlot(props) {
39
38
  } = axisData;
40
39
  const defaultXAxisId = xAxisIds[0];
41
40
  const defaultYAxisId = yAxisIds[0];
42
- const ScatterItems = (_slots$scatter = slots == null ? void 0 : slots.scatter) != null ? _slots$scatter : Scatter;
41
+ const ScatterItems = slots?.scatter ?? Scatter;
43
42
  return /*#__PURE__*/_jsx(React.Fragment, {
44
43
  children: seriesOrder.map(seriesId => {
45
44
  const {
@@ -49,16 +48,16 @@ function ScatterPlot(props) {
49
48
  markerSize,
50
49
  color
51
50
  } = series[seriesId];
52
- const xScale = xAxis[xAxisKey != null ? xAxisKey : defaultXAxisId].scale;
53
- const yScale = yAxis[yAxisKey != null ? yAxisKey : defaultYAxisId].scale;
51
+ const xScale = xAxis[xAxisKey ?? defaultXAxisId].scale;
52
+ const yScale = yAxis[yAxisKey ?? defaultYAxisId].scale;
54
53
  return /*#__PURE__*/_jsx(ScatterItems, _extends({
55
54
  xScale: xScale,
56
55
  yScale: yScale,
57
56
  color: color,
58
- markerSize: markerSize != null ? markerSize : 4,
57
+ markerSize: markerSize ?? 4,
59
58
  series: series[seriesId],
60
59
  onItemClick: onItemClick
61
- }, slotProps == null ? void 0 : slotProps.scatter), id);
60
+ }, slotProps?.scatter), id);
62
61
  })
63
62
  });
64
63
  }
@@ -76,7 +76,7 @@ const SparkLineChart = /*#__PURE__*/React.forwardRef(function SparkLineChart(pro
76
76
  }, xAxis)],
77
77
  colors: colors,
78
78
  sx: sx,
79
- disableAxisListener: (!showTooltip || (tooltip == null ? void 0 : tooltip.trigger) !== 'axis') && (axisHighlight == null ? void 0 : axisHighlight.x) === 'none' && (axisHighlight == null ? void 0 : axisHighlight.y) === 'none',
79
+ disableAxisListener: (!showTooltip || tooltip?.trigger !== 'axis') && axisHighlight?.x === 'none' && axisHighlight?.y === 'none',
80
80
  children: [plotType === 'bar' && /*#__PURE__*/_jsx(BarPlot, {
81
81
  skipAnimation: true,
82
82
  slots: slots,
@@ -43,7 +43,7 @@ function CartesianContextProvider(props) {
43
43
  } = props;
44
44
  const formattedSeries = React.useContext(SeriesContext);
45
45
  const drawingArea = React.useContext(DrawingContext);
46
- const xAxis = React.useMemo(() => inXAxis == null ? void 0 : inXAxis.map(axisConfig => {
46
+ const xAxis = React.useMemo(() => inXAxis?.map(axisConfig => {
47
47
  const dataKey = axisConfig.dataKey;
48
48
  if (dataKey === undefined || axisConfig.data !== undefined) {
49
49
  return axisConfig;
@@ -55,7 +55,7 @@ function CartesianContextProvider(props) {
55
55
  data: dataset.map(d => d[dataKey])
56
56
  });
57
57
  }), [inXAxis, dataset]);
58
- const yAxis = React.useMemo(() => inYAxis == null ? void 0 : inYAxis.map(axisConfig => {
58
+ const yAxis = React.useMemo(() => inYAxis?.map(axisConfig => {
59
59
  const dataKey = axisConfig.dataKey;
60
60
  if (dataKey === undefined || axisConfig.data !== undefined) {
61
61
  return axisConfig;
@@ -68,11 +68,9 @@ function CartesianContextProvider(props) {
68
68
  });
69
69
  }), [inYAxis, dataset]);
70
70
  const value = React.useMemo(() => {
71
- var _xAxis$map, _yAxis$map;
72
71
  const axisExtremumCallback = (acc, chartType, axis, getters, isDefaultAxis) => {
73
- var _ref, _formattedSeries$char;
74
72
  const getter = getters[chartType];
75
- const series = (_ref = (_formattedSeries$char = formattedSeries[chartType]) == null ? void 0 : _formattedSeries$char.series) != null ? _ref : {};
73
+ const series = formattedSeries[chartType]?.series ?? {};
76
74
  const [minChartTypeData, maxChartTypeData] = getter({
77
75
  series,
78
76
  axis,
@@ -91,9 +89,9 @@ function CartesianContextProvider(props) {
91
89
  const charTypes = Object.keys(getters);
92
90
  return charTypes.reduce((acc, charType) => axisExtremumCallback(acc, charType, axis, getters, isDefaultAxis), [null, null]);
93
91
  };
94
- const allXAxis = [...((_xAxis$map = xAxis == null ? void 0 : xAxis.map((axis, index) => _extends({
95
- id: `deaultized-x-axis-${index}`
96
- }, axis))) != null ? _xAxis$map : []),
92
+ const allXAxis = [...(xAxis?.map((axis, index) => _extends({
93
+ id: `defaultized-x-axis-${index}`
94
+ }, axis)) ?? []),
97
95
  // Allows to specify an axis with id=DEFAULT_X_AXIS_KEY
98
96
  ...(xAxis === undefined || xAxis.findIndex(({
99
97
  id
@@ -103,14 +101,12 @@ function CartesianContextProvider(props) {
103
101
  }] : [])];
104
102
  const completedXAxis = {};
105
103
  allXAxis.forEach((axis, axisIndex) => {
106
- var _axis$scaleType, _axis$min, _axis$max, _axis$min2, _axis$max2;
107
104
  const isDefaultAxis = axisIndex === 0;
108
105
  const [minData, maxData] = getAxisExtremum(axis, xExtremumGetters, isDefaultAxis);
109
106
  const range = axis.reverse ? [drawingArea.left + drawingArea.width, drawingArea.left] : [drawingArea.left, drawingArea.left + drawingArea.width];
110
107
  if (isBandScaleConfig(axis)) {
111
- var _axis$categoryGapRati, _axis$barGapRatio;
112
- const categoryGapRatio = (_axis$categoryGapRati = axis.categoryGapRatio) != null ? _axis$categoryGapRati : DEFAULT_CATEGORY_GAP_RATIO;
113
- const barGapRatio = (_axis$barGapRatio = axis.barGapRatio) != null ? _axis$barGapRatio : DEFAULT_BAR_GAP_RATIO;
108
+ const categoryGapRatio = axis.categoryGapRatio ?? DEFAULT_CATEGORY_GAP_RATIO;
109
+ const barGapRatio = axis.barGapRatio ?? DEFAULT_BAR_GAP_RATIO;
114
110
  completedXAxis[axis.id] = _extends({
115
111
  categoryGapRatio,
116
112
  barGapRatio
@@ -129,24 +125,24 @@ function CartesianContextProvider(props) {
129
125
  // Could be merged with the two previous "if conditions" but then TS does not get that `axis.scaleType` can't be `band` or `point`.
130
126
  return;
131
127
  }
132
- const scaleType = (_axis$scaleType = axis.scaleType) != null ? _axis$scaleType : 'linear';
133
- const extremums = [(_axis$min = axis.min) != null ? _axis$min : minData, (_axis$max = axis.max) != null ? _axis$max : maxData];
128
+ const scaleType = axis.scaleType ?? 'linear';
129
+ const extremums = [axis.min ?? minData, axis.max ?? maxData];
134
130
  const tickNumber = getTickNumber(_extends({}, axis, {
135
131
  range,
136
132
  domain: extremums
137
133
  }));
138
134
  const niceScale = getScale(scaleType, extremums, range).nice(tickNumber);
139
135
  const niceDomain = niceScale.domain();
140
- const domain = [(_axis$min2 = axis.min) != null ? _axis$min2 : niceDomain[0], (_axis$max2 = axis.max) != null ? _axis$max2 : niceDomain[1]];
136
+ const domain = [axis.min ?? niceDomain[0], axis.max ?? niceDomain[1]];
141
137
  completedXAxis[axis.id] = _extends({}, axis, {
142
138
  scaleType,
143
139
  scale: niceScale.domain(domain),
144
140
  tickNumber
145
141
  });
146
142
  });
147
- const allYAxis = [...((_yAxis$map = yAxis == null ? void 0 : yAxis.map((axis, index) => _extends({
148
- id: `deaultized-y-axis-${index}`
149
- }, axis))) != null ? _yAxis$map : []), ...(yAxis === undefined || yAxis.findIndex(({
143
+ const allYAxis = [...(yAxis?.map((axis, index) => _extends({
144
+ id: `defaultized-y-axis-${index}`
145
+ }, axis)) ?? []), ...(yAxis === undefined || yAxis.findIndex(({
150
146
  id
151
147
  }) => id === DEFAULT_Y_AXIS_KEY) === -1 ? [{
152
148
  id: DEFAULT_Y_AXIS_KEY,
@@ -154,13 +150,11 @@ function CartesianContextProvider(props) {
154
150
  }] : [])];
155
151
  const completedYAxis = {};
156
152
  allYAxis.forEach((axis, axisIndex) => {
157
- var _axis$scaleType2, _axis$min3, _axis$max3, _axis$min4, _axis$max4;
158
153
  const isDefaultAxis = axisIndex === 0;
159
154
  const [minData, maxData] = getAxisExtremum(axis, yExtremumGetters, isDefaultAxis);
160
155
  const range = axis.reverse ? [drawingArea.top, drawingArea.top + drawingArea.height] : [drawingArea.top + drawingArea.height, drawingArea.top];
161
156
  if (isBandScaleConfig(axis)) {
162
- var _axis$categoryGapRati2;
163
- const categoryGapRatio = (_axis$categoryGapRati2 = axis.categoryGapRatio) != null ? _axis$categoryGapRati2 : DEFAULT_CATEGORY_GAP_RATIO;
157
+ const categoryGapRatio = axis.categoryGapRatio ?? DEFAULT_CATEGORY_GAP_RATIO;
164
158
  completedYAxis[axis.id] = _extends({
165
159
  categoryGapRatio,
166
160
  barGapRatio: 0
@@ -179,15 +173,15 @@ function CartesianContextProvider(props) {
179
173
  // Could be merged with the two previous "if conditions" but then TS does not get that `axis.scaleType` can't be `band` or `point`.
180
174
  return;
181
175
  }
182
- const scaleType = (_axis$scaleType2 = axis.scaleType) != null ? _axis$scaleType2 : 'linear';
183
- const extremums = [(_axis$min3 = axis.min) != null ? _axis$min3 : minData, (_axis$max3 = axis.max) != null ? _axis$max3 : maxData];
176
+ const scaleType = axis.scaleType ?? 'linear';
177
+ const extremums = [axis.min ?? minData, axis.max ?? maxData];
184
178
  const tickNumber = getTickNumber(_extends({}, axis, {
185
179
  range,
186
180
  domain: extremums
187
181
  }));
188
182
  const niceScale = getScale(scaleType, extremums, range).nice(tickNumber);
189
183
  const niceDomain = niceScale.domain();
190
- const domain = [(_axis$min4 = axis.min) != null ? _axis$min4 : niceDomain[0], (_axis$max4 = axis.max) != null ? _axis$max4 : niceDomain[1]];
184
+ const domain = [axis.min ?? niceDomain[0], axis.max ?? niceDomain[1]];
191
185
  completedYAxis[axis.id] = _extends({}, axis, {
192
186
  scaleType,
193
187
  scale: niceScale.domain(domain),
@@ -36,7 +36,7 @@ export function DrawingProvider(props) {
36
36
  const drawingArea = useChartDimensions(width, height, margin);
37
37
  const chartId = useId();
38
38
  const value = React.useMemo(() => _extends({
39
- chartId: chartId != null ? chartId : ''
39
+ chartId: chartId ?? ''
40
40
  }, drawingArea), [chartId, drawingArea]);
41
41
  return /*#__PURE__*/_jsx(SvgContext.Provider, {
42
42
  value: svgRef,
@@ -31,7 +31,6 @@ const formatSeries = (series, colors, dataset) => {
31
31
  // Group series by type
32
32
  const seriesGroups = {};
33
33
  series.forEach((seriesData, seriesIndex) => {
34
- var _seriesGroups$type;
35
34
  const {
36
35
  id = `auto-generated-id-${seriesIndex}`,
37
36
  type
@@ -42,7 +41,7 @@ const formatSeries = (series, colors, dataset) => {
42
41
  seriesOrder: []
43
42
  };
44
43
  }
45
- if (((_seriesGroups$type = seriesGroups[type]) == null ? void 0 : _seriesGroups$type.series[id]) !== undefined) {
44
+ if (seriesGroups[type]?.series[id] !== undefined) {
46
45
  throw new Error(`MUI X Charts: series' id "${id}" is not unique.`);
47
46
  }
48
47
  seriesGroups[type].series[id] = _extends({
@@ -54,8 +53,7 @@ const formatSeries = (series, colors, dataset) => {
54
53
  // Apply formater on a type group
55
54
  Object.keys(seriesTypeFormatter).forEach(type => {
56
55
  if (seriesGroups[type] !== undefined) {
57
- var _seriesTypeFormatter$, _seriesTypeFormatter$2;
58
- formattedSeries[type] = (_seriesTypeFormatter$ = (_seriesTypeFormatter$2 = seriesTypeFormatter[type]) == null ? void 0 : _seriesTypeFormatter$2.call(seriesTypeFormatter, seriesGroups[type], dataset)) != null ? _seriesTypeFormatter$ : seriesGroups[type];
56
+ formattedSeries[type] = seriesTypeFormatter[type]?.(seriesGroups[type], dataset) ?? seriesGroups[type];
59
57
  }
60
58
  });
61
59
  return formattedSeries;
@@ -54,7 +54,7 @@ export const useAxisEvents = disableAxisListener => {
54
54
  };
55
55
  }
56
56
  const valueAsNumber = getAsANumber(value);
57
- const closestIndex = axisData == null ? void 0 : axisData.findIndex((pointValue, index) => {
57
+ const closestIndex = axisData?.findIndex((pointValue, index) => {
58
58
  const v = getAsANumber(pointValue);
59
59
  if (v > valueAsNumber) {
60
60
  if (index === 0 || Math.abs(valueAsNumber - v) <= Math.abs(valueAsNumber - getAsANumber(axisData[index - 1]))) {
@@ -41,7 +41,7 @@ export const useInteractionItemProps = (scope, skip) => {
41
41
  return getInteractionItemProps;
42
42
  };
43
43
  export const getIsHighlighted = (selectedItem, currentItem, highlightScope) => {
44
- if (!(highlightScope != null && highlightScope.highlighted) || highlightScope.highlighted === 'none' || selectedItem === null) {
44
+ if (!highlightScope?.highlighted || highlightScope.highlighted === 'none' || selectedItem === null) {
45
45
  return false;
46
46
  }
47
47
  const isSeriesSelected = selectedItem.type === currentItem.type && selectedItem.seriesId === currentItem.seriesId;
@@ -54,7 +54,7 @@ export const getIsHighlighted = (selectedItem, currentItem, highlightScope) => {
54
54
  return selectedItem.dataIndex !== undefined && selectedItem.dataIndex === currentItem.dataIndex;
55
55
  };
56
56
  export const getIsFaded = (selectedItem, currentItem, highlightScope) => {
57
- if (!(highlightScope != null && highlightScope.faded) || highlightScope.faded === 'none' || selectedItem === null) {
57
+ if (!highlightScope?.faded || highlightScope.faded === 'none' || selectedItem === null) {
58
58
  return false;
59
59
  }
60
60
  const isSeriesSelected = selectedItem.type === currentItem.type && selectedItem.seriesId === currentItem.seriesId;
@@ -18,7 +18,7 @@ export function useXScale(identifier) {
18
18
  xAxis,
19
19
  xAxisIds
20
20
  } = React.useContext(CartesianContext);
21
- const id = typeof identifier === 'string' ? identifier : xAxisIds[identifier != null ? identifier : 0];
21
+ const id = typeof identifier === 'string' ? identifier : xAxisIds[identifier ?? 0];
22
22
  return xAxis[id].scale;
23
23
  }
24
24
  export function useYScale(identifier) {
@@ -26,6 +26,6 @@ export function useYScale(identifier) {
26
26
  yAxis,
27
27
  yAxisIds
28
28
  } = React.useContext(CartesianContext);
29
- const id = typeof identifier === 'string' ? identifier : yAxisIds[identifier != null ? identifier : 0];
29
+ const id = typeof identifier === 'string' ? identifier : yAxisIds[identifier ?? 0];
30
30
  return yAxis[id].scale;
31
31
  }
@@ -10,7 +10,7 @@ export function getTickNumber(params) {
10
10
  } = params;
11
11
  const maxTicks = tickMinStep === undefined ? 999 : Math.floor(Math.abs(domain[1] - domain[0]) / tickMinStep);
12
12
  const minTicks = tickMaxStep === undefined ? 2 : Math.ceil(Math.abs(domain[1] - domain[0]) / tickMaxStep);
13
- const defaultizedTickNumber = tickNumber != null ? tickNumber : Math.floor(Math.abs(range[1] - range[0]) / 50);
13
+ const defaultizedTickNumber = tickNumber ?? Math.floor(Math.abs(range[1] - range[0]) / 50);
14
14
  return Math.min(maxTicks, Math.max(minTicks, defaultizedTickNumber));
15
15
  }
16
16
  const offsetRatio = {
@@ -34,17 +34,14 @@ export function useTicks(options) {
34
34
  const domain = scale.domain();
35
35
  if (scale.bandwidth() > 0) {
36
36
  // scale type = 'band'
37
- return [...domain.map(value => {
38
- var _valueFormatter;
39
- return {
40
- value,
41
- formattedValue: (_valueFormatter = valueFormatter == null ? void 0 : valueFormatter(value, {
42
- location: 'tick'
43
- })) != null ? _valueFormatter : `${value}`,
44
- offset: scale(value) - (scale.step() - scale.bandwidth()) / 2 + offsetRatio[tickPlacement] * scale.step(),
45
- labelOffset: tickLabelPlacement === 'tick' ? 0 : scale.step() * (offsetRatio[tickLabelPlacement] - offsetRatio[tickPlacement])
46
- };
47
- }), ...(tickPlacement === 'extremities' ? [{
37
+ return [...domain.map(value => ({
38
+ value,
39
+ formattedValue: valueFormatter?.(value, {
40
+ location: 'tick'
41
+ }) ?? `${value}`,
42
+ offset: scale(value) - (scale.step() - scale.bandwidth()) / 2 + offsetRatio[tickPlacement] * scale.step(),
43
+ labelOffset: tickLabelPlacement === 'tick' ? 0 : scale.step() * (offsetRatio[tickLabelPlacement] - offsetRatio[tickPlacement])
44
+ })), ...(tickPlacement === 'extremities' ? [{
48
45
  formattedValue: undefined,
49
46
  offset: scale.range()[1],
50
47
  labelOffset: 0
@@ -53,29 +50,23 @@ export function useTicks(options) {
53
50
 
54
51
  // scale type = 'point'
55
52
  const filteredDomain = typeof tickInterval === 'function' && domain.filter(tickInterval) || typeof tickInterval === 'object' && tickInterval || domain;
56
- return filteredDomain.map(value => {
57
- var _valueFormatter2;
58
- return {
59
- value,
60
- formattedValue: (_valueFormatter2 = valueFormatter == null ? void 0 : valueFormatter(value, {
61
- location: 'tick'
62
- })) != null ? _valueFormatter2 : `${value}`,
63
- offset: scale(value),
64
- labelOffset: 0
65
- };
66
- });
67
- }
68
- const ticks = typeof tickInterval === 'object' ? tickInterval : scale.ticks(tickNumber);
69
- return ticks.map(value => {
70
- var _valueFormatter3;
71
- return {
53
+ return filteredDomain.map(value => ({
72
54
  value,
73
- formattedValue: (_valueFormatter3 = valueFormatter == null ? void 0 : valueFormatter(value, {
55
+ formattedValue: valueFormatter?.(value, {
74
56
  location: 'tick'
75
- })) != null ? _valueFormatter3 : scale.tickFormat(tickNumber)(value),
57
+ }) ?? `${value}`,
76
58
  offset: scale(value),
77
59
  labelOffset: 0
78
- };
79
- });
60
+ }));
61
+ }
62
+ const ticks = typeof tickInterval === 'object' ? tickInterval : scale.ticks(tickNumber);
63
+ return ticks.map(value => ({
64
+ value,
65
+ formattedValue: valueFormatter?.(value, {
66
+ location: 'tick'
67
+ }) ?? scale.tickFormat(tickNumber)(value),
68
+ offset: scale(value),
69
+ labelOffset: 0
70
+ }));
80
71
  }, [scale, tickInterval, tickNumber, valueFormatter, tickPlacement, tickLabelPlacement]);
81
72
  }
@@ -2,9 +2,8 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  function defaultizeValueFormatter(series, defaultValueFormatter) {
3
3
  const defaultizedSeries = {};
4
4
  Object.keys(series).forEach(seriesId => {
5
- var _series$seriesId$valu;
6
5
  defaultizedSeries[seriesId] = _extends({}, series[seriesId], {
7
- valueFormatter: (_series$seriesId$valu = series[seriesId].valueFormatter) != null ? _series$seriesId$valu : defaultValueFormatter
6
+ valueFormatter: series[seriesId].valueFormatter ?? defaultValueFormatter
8
7
  });
9
8
  });
10
9
  return defaultizedSeries;
@@ -74,12 +74,11 @@ export const getStackingGroups = params => {
74
74
  stackingOffset: StackOffset.none
75
75
  });
76
76
  } else if (stackIndex[stack] === undefined) {
77
- var _ref, _ref2;
78
77
  stackIndex[stack] = stackingGroups.length;
79
78
  stackingGroups.push({
80
79
  ids: [id],
81
- stackingOrder: StackOrder[(_ref = stackOrder != null ? stackOrder : defaultStrategy == null ? void 0 : defaultStrategy.stackOrder) != null ? _ref : 'none'],
82
- stackingOffset: StackOffset[(_ref2 = stackOffset != null ? stackOffset : defaultStrategy == null ? void 0 : defaultStrategy.stackOffset) != null ? _ref2 : 'diverging']
80
+ stackingOrder: StackOrder[stackOrder ?? defaultStrategy?.stackOrder ?? 'none'],
81
+ stackingOffset: StackOffset[stackOffset ?? defaultStrategy?.stackOffset ?? 'diverging']
83
82
  });
84
83
  } else {
85
84
  stackingGroups[stackIndex[stack]].ids.push(id);
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v7.0.0-beta.7
2
+ * @mui/x-charts v7.1.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -11,7 +11,7 @@ function DefaultChartsItemTooltipContent(props) {
11
11
  sx,
12
12
  classes
13
13
  } = props;
14
- if (itemData.dataIndex === undefined) {
14
+ if (itemData.dataIndex === undefined || !series.data[itemData.dataIndex]) {
15
15
  return null;
16
16
  }
17
17
  const {
@@ -90,7 +90,7 @@ function CartesianContextProvider(props) {
90
90
  return charTypes.reduce((acc, charType) => axisExtremumCallback(acc, charType, axis, getters, isDefaultAxis), [null, null]);
91
91
  };
92
92
  const allXAxis = [...(xAxis?.map((axis, index) => _extends({
93
- id: `deaultized-x-axis-${index}`
93
+ id: `defaultized-x-axis-${index}`
94
94
  }, axis)) ?? []),
95
95
  // Allows to specify an axis with id=DEFAULT_X_AXIS_KEY
96
96
  ...(xAxis === undefined || xAxis.findIndex(({
@@ -141,7 +141,7 @@ function CartesianContextProvider(props) {
141
141
  });
142
142
  });
143
143
  const allYAxis = [...(yAxis?.map((axis, index) => _extends({
144
- id: `deaultized-y-axis-${index}`
144
+ id: `defaultized-y-axis-${index}`
145
145
  }, axis)) ?? []), ...(yAxis === undefined || yAxis.findIndex(({
146
146
  id
147
147
  }) => id === DEFAULT_Y_AXIS_KEY) === -1 ? [{
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v7.0.0-beta.7
2
+ * @mui/x-charts v7.1.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-charts",
3
- "version": "7.0.0-beta.7",
3
+ "version": "7.1.0",
4
4
  "description": "The community edition of the charts components (MUI X).",
5
5
  "author": "MUI Team",
6
6
  "main": "./index.js",
@@ -29,9 +29,9 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@babel/runtime": "^7.24.0",
32
- "@mui/base": "^5.0.0-beta.36",
33
- "@mui/system": "^5.15.9",
34
- "@mui/utils": "^5.15.9",
32
+ "@mui/base": "^5.0.0-beta.40",
33
+ "@mui/system": "^5.15.14",
34
+ "@mui/utils": "^5.15.14",
35
35
  "@react-spring/rafz": "^9.7.3",
36
36
  "@react-spring/web": "^9.7.3",
37
37
  "clsx": "^2.1.0",
@@ -45,7 +45,7 @@
45
45
  "peerDependencies": {
46
46
  "@emotion/react": "^11.9.0",
47
47
  "@emotion/styled": "^11.8.1",
48
- "@mui/material": "^5.15.0",
48
+ "@mui/material": "^5.15.14",
49
49
  "react": "^17.0.0 || ^18.0.0",
50
50
  "react-dom": "^17.0.0 || ^18.0.0"
51
51
  },