@mui/x-charts 7.0.0-alpha.5 → 7.0.0-alpha.7

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 (41) hide show
  1. package/CHANGELOG.md +185 -3
  2. package/LineChart/formatter.js +1 -1
  3. package/PieChart/PieArcLabel.d.ts +1 -0
  4. package/PieChart/PieArcLabel.js +7 -8
  5. package/PieChart/PieArcLabelPlot.js +14 -3
  6. package/PieChart/PieArcPlot.js +8 -1
  7. package/PieChart/PieChart.js +3 -0
  8. package/PieChart/PiePlot.js +3 -0
  9. package/PieChart/dataTransform/transition.js +9 -2
  10. package/PieChart/dataTransform/useTransformData.d.ts +1 -0
  11. package/PieChart/dataTransform/useTransformData.js +11 -8
  12. package/esm/LineChart/formatter.js +1 -1
  13. package/esm/PieChart/PieArcLabel.js +7 -8
  14. package/esm/PieChart/PieArcLabelPlot.js +14 -3
  15. package/esm/PieChart/PieArcPlot.js +8 -1
  16. package/esm/PieChart/PieChart.js +3 -0
  17. package/esm/PieChart/PiePlot.js +3 -0
  18. package/esm/PieChart/dataTransform/transition.js +9 -2
  19. package/esm/PieChart/dataTransform/useTransformData.js +12 -9
  20. package/index.js +1 -1
  21. package/internals/defaultizeColor.d.ts +3 -0
  22. package/legacy/LineChart/formatter.js +1 -1
  23. package/legacy/PieChart/PieArcLabel.js +7 -8
  24. package/legacy/PieChart/PieArcLabelPlot.js +14 -4
  25. package/legacy/PieChart/PieArcPlot.js +9 -1
  26. package/legacy/PieChart/PieChart.js +3 -0
  27. package/legacy/PieChart/PiePlot.js +3 -0
  28. package/legacy/PieChart/dataTransform/transition.js +9 -2
  29. package/legacy/PieChart/dataTransform/useTransformData.js +12 -9
  30. package/legacy/index.js +1 -1
  31. package/models/seriesType/pie.d.ts +14 -0
  32. package/modern/LineChart/formatter.js +1 -1
  33. package/modern/PieChart/PieArcLabel.js +7 -8
  34. package/modern/PieChart/PieArcLabelPlot.js +14 -3
  35. package/modern/PieChart/PieArcPlot.js +8 -1
  36. package/modern/PieChart/PieChart.js +3 -0
  37. package/modern/PieChart/PiePlot.js +3 -0
  38. package/modern/PieChart/dataTransform/transition.js +9 -2
  39. package/modern/PieChart/dataTransform/useTransformData.js +11 -8
  40. package/modern/index.js +1 -1
  41. package/package.json +5 -5
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["slots", "slotProps", "innerRadius", "outerRadius", "cornerRadius", "paddingAngle", "id", "highlightScope", "highlighted", "faded", "data", "arcLabel", "arcLabelMinAngle", "skipAnimation"],
4
- _excluded2 = ["startAngle", "endAngle", "paddingAngle", "innerRadius", "outerRadius", "cornerRadius"];
3
+ const _excluded = ["slots", "slotProps", "innerRadius", "outerRadius", "arcLabelRadius", "cornerRadius", "paddingAngle", "id", "highlightScope", "highlighted", "faded", "data", "arcLabel", "arcLabelMinAngle", "skipAnimation"],
4
+ _excluded2 = ["startAngle", "endAngle", "paddingAngle", "innerRadius", "outerRadius", "arcLabelRadius", "cornerRadius"];
5
5
  import * as React from 'react';
6
6
  import PropTypes from 'prop-types';
7
7
  import { useTransition } from '@react-spring/web';
@@ -29,8 +29,9 @@ function PieArcLabelPlot(props) {
29
29
  const {
30
30
  slots,
31
31
  slotProps,
32
- innerRadius = 0,
32
+ innerRadius,
33
33
  outerRadius,
34
+ arcLabelRadius,
34
35
  cornerRadius = 0,
35
36
  paddingAngle = 0,
36
37
  id,
@@ -48,6 +49,7 @@ function PieArcLabelPlot(props) {
48
49
  const transformedData = useTransformData({
49
50
  innerRadius,
50
51
  outerRadius,
52
+ arcLabelRadius,
51
53
  cornerRadius,
52
54
  paddingAngle,
53
55
  id,
@@ -71,6 +73,7 @@ function PieArcLabelPlot(props) {
71
73
  paddingAngle: pA,
72
74
  innerRadius: iR,
73
75
  outerRadius: oR,
76
+ arcLabelRadius: aLR,
74
77
  cornerRadius: cR
75
78
  } = _ref,
76
79
  style = _objectWithoutPropertiesLoose(_ref, _excluded2);
@@ -80,6 +83,7 @@ function PieArcLabelPlot(props) {
80
83
  paddingAngle: pA,
81
84
  innerRadius: iR,
82
85
  outerRadius: oR,
86
+ arcLabelRadius: aLR,
83
87
  cornerRadius: cR,
84
88
  style: style,
85
89
  id: id,
@@ -104,6 +108,11 @@ process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
104
108
  * The minimal angle required to display the arc label.
105
109
  */
106
110
  arcLabelMinAngle: PropTypes.number,
111
+ /**
112
+ * The radius between circle center and the arc label in px.
113
+ * @default (innerRadius - outerRadius) / 2
114
+ */
115
+ arcLabelRadius: PropTypes.number,
107
116
  /**
108
117
  * The radius applied to arc corners (similar to border radius).
109
118
  * @default 0
@@ -125,6 +134,7 @@ process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
125
134
  */
126
135
  faded: PropTypes.shape({
127
136
  additionalRadius: PropTypes.number,
137
+ arcLabelRadius: PropTypes.number,
128
138
  color: PropTypes.string,
129
139
  cornerRadius: PropTypes.number,
130
140
  innerRadius: PropTypes.number,
@@ -136,6 +146,7 @@ process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
136
146
  */
137
147
  highlighted: PropTypes.shape({
138
148
  additionalRadius: PropTypes.number,
149
+ arcLabelRadius: PropTypes.number,
139
150
  color: PropTypes.string,
140
151
  cornerRadius: PropTypes.number,
141
152
  innerRadius: PropTypes.number,
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
3
  const _excluded = ["slots", "slotProps", "innerRadius", "outerRadius", "cornerRadius", "paddingAngle", "id", "highlightScope", "highlighted", "faded", "data", "onClick", "skipAnimation"],
4
- _excluded2 = ["startAngle", "endAngle", "paddingAngle", "innerRadius", "outerRadius", "cornerRadius"];
4
+ _excluded2 = ["startAngle", "endAngle", "paddingAngle", "innerRadius", "arcLabelRadius", "outerRadius", "cornerRadius"];
5
5
  import * as React from 'react';
6
6
  import PropTypes from 'prop-types';
7
7
  import { useTransition } from '@react-spring/web';
@@ -88,6 +88,11 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
88
88
  // | These PropTypes are generated from the TypeScript type definitions |
89
89
  // | To update them edit the TypeScript types and run "yarn proptypes" |
90
90
  // ----------------------------------------------------------------------
91
+ /**
92
+ * The radius between circle center and the arc label in px.
93
+ * @default (innerRadius - outerRadius) / 2
94
+ */
95
+ arcLabelRadius: PropTypes.number,
91
96
  /**
92
97
  * The radius applied to arc corners (similar to border radius).
93
98
  * @default 0
@@ -109,6 +114,7 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
109
114
  */
110
115
  faded: PropTypes.shape({
111
116
  additionalRadius: PropTypes.number,
117
+ arcLabelRadius: PropTypes.number,
112
118
  color: PropTypes.string,
113
119
  cornerRadius: PropTypes.number,
114
120
  innerRadius: PropTypes.number,
@@ -120,6 +126,7 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
120
126
  */
121
127
  highlighted: PropTypes.shape({
122
128
  additionalRadius: PropTypes.number,
129
+ arcLabelRadius: PropTypes.number,
123
130
  color: PropTypes.string,
124
131
  cornerRadius: PropTypes.number,
125
132
  innerRadius: PropTypes.number,
@@ -238,6 +238,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
238
238
  series: PropTypes.arrayOf(PropTypes.shape({
239
239
  arcLabel: PropTypes.oneOfType([PropTypes.oneOf(['formattedValue', 'label', 'value']), PropTypes.func]),
240
240
  arcLabelMinAngle: PropTypes.number,
241
+ arcLabelRadius: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
241
242
  color: PropTypes.string,
242
243
  cornerRadius: PropTypes.number,
243
244
  cx: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
@@ -251,6 +252,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
251
252
  endAngle: PropTypes.number,
252
253
  faded: PropTypes.shape({
253
254
  additionalRadius: PropTypes.number,
255
+ arcLabelRadius: PropTypes.number,
254
256
  color: PropTypes.string,
255
257
  cornerRadius: PropTypes.number,
256
258
  innerRadius: PropTypes.number,
@@ -259,6 +261,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
259
261
  }),
260
262
  highlighted: PropTypes.shape({
261
263
  additionalRadius: PropTypes.number,
264
+ arcLabelRadius: PropTypes.number,
262
265
  color: PropTypes.string,
263
266
  cornerRadius: PropTypes.number,
264
267
  innerRadius: PropTypes.number,
@@ -79,6 +79,7 @@ function PiePlot(props) {
79
79
  const {
80
80
  innerRadius: innerRadiusParam,
81
81
  outerRadius: outerRadiusParam,
82
+ arcLabelRadius: arcLabelRadiusParam,
82
83
  cornerRadius,
83
84
  paddingAngle,
84
85
  arcLabel,
@@ -90,6 +91,7 @@ function PiePlot(props) {
90
91
  } = series[seriesId];
91
92
  const outerRadius = getPercentageValue(outerRadiusParam != null ? outerRadiusParam : availableRadius, availableRadius);
92
93
  const innerRadius = getPercentageValue(innerRadiusParam != null ? innerRadiusParam : 0, availableRadius);
94
+ const arcLabelRadius = arcLabelRadiusParam === undefined ? (outerRadius + innerRadius) / 2 : getPercentageValue(arcLabelRadiusParam, availableRadius);
93
95
  const cx = getPercentageValue(cxParam != null ? cxParam : '50%', width);
94
96
  const cy = getPercentageValue(cyParam != null ? cyParam : '50%', height);
95
97
  return /*#__PURE__*/_jsx("g", {
@@ -97,6 +99,7 @@ function PiePlot(props) {
97
99
  children: /*#__PURE__*/_jsx(PieArcLabelPlot, {
98
100
  innerRadius: innerRadius,
99
101
  outerRadius: outerRadius != null ? outerRadius : availableRadius,
102
+ arcLabelRadius: arcLabelRadius,
100
103
  cornerRadius: cornerRadius,
101
104
  paddingAngle: paddingAngle,
102
105
  id: seriesId,
@@ -70,6 +70,7 @@ export const defaultLabelTransitionConfig = {
70
70
  from: ({
71
71
  innerRadius,
72
72
  outerRadius,
73
+ arcLabelRadius,
73
74
  cornerRadius,
74
75
  startAngle,
75
76
  endAngle,
@@ -78,6 +79,7 @@ export const defaultLabelTransitionConfig = {
78
79
  innerRadius,
79
80
  outerRadius: (innerRadius + outerRadius) / 2,
80
81
  cornerRadius,
82
+ arcLabelRadius,
81
83
  startAngle: (startAngle + endAngle) / 2,
82
84
  endAngle: (startAngle + endAngle) / 2,
83
85
  paddingAngle,
@@ -90,6 +92,7 @@ export const defaultLabelTransitionConfig = {
90
92
  }) => ({
91
93
  innerRadius,
92
94
  outerRadius: innerRadius,
95
+ arcLabelRadius: innerRadius,
93
96
  startAngle: (startAngle + endAngle) / 2,
94
97
  endAngle: (startAngle + endAngle) / 2,
95
98
  opacity: 0
@@ -98,12 +101,14 @@ export const defaultLabelTransitionConfig = {
98
101
  innerRadius,
99
102
  outerRadius,
100
103
  startAngle,
101
- endAngle
104
+ endAngle,
105
+ arcLabelRadius
102
106
  }) => ({
103
107
  innerRadius,
104
108
  outerRadius,
105
109
  startAngle,
106
110
  endAngle,
111
+ arcLabelRadius,
107
112
  opacity: 1
108
113
  }),
109
114
  update: ({
@@ -112,7 +117,8 @@ export const defaultLabelTransitionConfig = {
112
117
  cornerRadius,
113
118
  startAngle,
114
119
  endAngle,
115
- paddingAngle
120
+ paddingAngle,
121
+ arcLabelRadius
116
122
  }) => ({
117
123
  innerRadius,
118
124
  outerRadius,
@@ -120,6 +126,7 @@ export const defaultLabelTransitionConfig = {
120
126
  startAngle,
121
127
  endAngle,
122
128
  paddingAngle,
129
+ arcLabelRadius,
123
130
  opacity: 1
124
131
  }),
125
132
  config: {
@@ -11,6 +11,7 @@ export function useTransformData(series) {
11
11
  highlighted,
12
12
  paddingAngle: basePaddingAngle = 0,
13
13
  innerRadius: baseInnerRadius = 0,
14
+ arcLabelRadius: baseArcLabelRadius,
14
15
  outerRadius: baseOuterRadius,
15
16
  cornerRadius: baseCornerRadius = 0
16
17
  } = series;
@@ -34,26 +35,28 @@ export function useTransformData(series) {
34
35
  };
35
36
  }, [highlightScope, highlightedItem, seriesId]);
36
37
  const dataWithHighlight = React.useMemo(() => data.map((item, itemIndex) => {
37
- var _attibuesOverride$pad, _attibuesOverride$inn, _attibuesOverride$out, _attibuesOverride$cor;
38
+ var _attributesOverride$p, _attributesOverride$i, _attributesOverride$o, _attributesOverride$c, _ref, _attributesOverride$a;
38
39
  const {
39
40
  isHighlighted,
40
41
  isFaded
41
42
  } = getHighlightStatus(itemIndex);
42
- const attibuesOverride = _extends({
43
+ const attributesOverride = _extends({
43
44
  additionalRadius: 0
44
45
  }, isFaded && faded || isHighlighted && highlighted || {});
45
- const paddingAngle = Math.max(0, Math.PI * ((_attibuesOverride$pad = attibuesOverride.paddingAngle) != null ? _attibuesOverride$pad : basePaddingAngle) / 180);
46
- const innerRadius = Math.max(0, (_attibuesOverride$inn = attibuesOverride.innerRadius) != null ? _attibuesOverride$inn : baseInnerRadius);
47
- const outerRadius = Math.max(0, (_attibuesOverride$out = attibuesOverride.outerRadius) != null ? _attibuesOverride$out : baseOuterRadius + attibuesOverride.additionalRadius);
48
- const cornerRadius = (_attibuesOverride$cor = attibuesOverride.cornerRadius) != null ? _attibuesOverride$cor : baseCornerRadius;
49
- return _extends({}, item, attibuesOverride, {
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;
51
+ return _extends({}, item, attributesOverride, {
50
52
  isFaded,
51
53
  isHighlighted,
52
54
  paddingAngle,
53
55
  innerRadius,
54
56
  outerRadius,
55
- cornerRadius
57
+ cornerRadius,
58
+ arcLabelRadius
56
59
  });
57
- }), [baseCornerRadius, baseInnerRadius, baseOuterRadius, basePaddingAngle, data, faded, getHighlightStatus, highlighted]);
60
+ }), [baseCornerRadius, baseInnerRadius, baseOuterRadius, basePaddingAngle, baseArcLabelRadius, data, faded, getHighlightStatus, highlighted]);
58
61
  return dataWithHighlight;
59
62
  }
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v7.0.0-alpha.5
2
+ * @mui/x-charts v7.0.0-alpha.7
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -9,6 +9,7 @@ export declare function defaultizeColor(series: AllSeriesType, seriesIndex: numb
9
9
  type: "pie";
10
10
  innerRadius?: string | number | undefined;
11
11
  outerRadius?: string | number | undefined;
12
+ arcLabelRadius?: string | number | undefined;
12
13
  cornerRadius?: number | undefined;
13
14
  startAngle?: number | undefined;
14
15
  endAngle?: number | undefined;
@@ -24,6 +25,7 @@ export declare function defaultizeColor(series: AllSeriesType, seriesIndex: numb
24
25
  outerRadius?: number | undefined;
25
26
  cornerRadius?: number | undefined;
26
27
  paddingAngle?: number | undefined;
28
+ arcLabelRadius?: number | undefined;
27
29
  color?: string | undefined;
28
30
  } | undefined;
29
31
  faded?: {
@@ -32,6 +34,7 @@ export declare function defaultizeColor(series: AllSeriesType, seriesIndex: numb
32
34
  outerRadius?: number | undefined;
33
35
  cornerRadius?: number | undefined;
34
36
  paddingAngle?: number | undefined;
37
+ arcLabelRadius?: number | undefined;
35
38
  color?: string | undefined;
36
39
  } | undefined;
37
40
  id?: string | undefined;
@@ -54,7 +54,7 @@ var formatter = function formatter(params, dataset) {
54
54
  warnedOnce = true;
55
55
  console.error(["MUI-X charts: your dataset key \"".concat(dataKey, "\" is used for plotting line, but contains nonnumerical elements."), 'Line plots only support numbers and null values.']);
56
56
  }
57
- return 0;
57
+ return null;
58
58
  }
59
59
  return value;
60
60
  }) : series[id].data,
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
3
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
- var _excluded = ["id", "classes", "color", "startAngle", "endAngle", "paddingAngle", "innerRadius", "outerRadius", "cornerRadius", "formattedArcLabel", "isHighlighted", "isFaded", "style"];
4
+ var _excluded = ["id", "classes", "color", "startAngle", "endAngle", "paddingAngle", "arcLabelRadius", "cornerRadius", "formattedArcLabel", "isHighlighted", "isFaded", "style"];
5
5
  import * as React from 'react';
6
6
  import PropTypes from 'prop-types';
7
7
  import { animated, to } from '@react-spring/web';
@@ -44,7 +44,7 @@ var PieArcLabelRoot = styled(animated.text, {
44
44
  * It's not an inline function because we need it in inerpolation.
45
45
  */
46
46
  var getLabelPosition = function getLabelPosition(formattedArcLabel, variable) {
47
- return function (startAngle, endAngle, padAngle, innerRadius, outerRadius, cornerRadius) {
47
+ return function (startAngle, endAngle, padAngle, arcLabelRadius, cornerRadius) {
48
48
  if (!formattedArcLabel) {
49
49
  return 0;
50
50
  }
@@ -52,8 +52,8 @@ var getLabelPosition = function getLabelPosition(formattedArcLabel, variable) {
52
52
  padAngle: padAngle,
53
53
  startAngle: startAngle,
54
54
  endAngle: endAngle,
55
- innerRadius: innerRadius,
56
- outerRadius: outerRadius
55
+ innerRadius: arcLabelRadius,
56
+ outerRadius: arcLabelRadius
57
57
  }),
58
58
  _ref3 = _slicedToArray(_ref2, 2),
59
59
  x = _ref3[0],
@@ -71,8 +71,7 @@ function PieArcLabel(props) {
71
71
  startAngle = props.startAngle,
72
72
  endAngle = props.endAngle,
73
73
  paddingAngle = props.paddingAngle,
74
- innerRadius = props.innerRadius,
75
- outerRadius = props.outerRadius,
74
+ arcLabelRadius = props.arcLabelRadius,
76
75
  cornerRadius = props.cornerRadius,
77
76
  formattedArcLabel = props.formattedArcLabel,
78
77
  isHighlighted = props.isHighlighted,
@@ -91,8 +90,8 @@ function PieArcLabel(props) {
91
90
  className: classes.root
92
91
  }, other, {
93
92
  style: _extends({
94
- x: to([startAngle, endAngle, paddingAngle, innerRadius, outerRadius, cornerRadius], getLabelPosition(formattedArcLabel, 'x')),
95
- y: to([startAngle, endAngle, paddingAngle, innerRadius, outerRadius, cornerRadius], getLabelPosition(formattedArcLabel, 'y'))
93
+ x: to([startAngle, endAngle, paddingAngle, arcLabelRadius, cornerRadius], getLabelPosition(formattedArcLabel, 'x')),
94
+ y: to([startAngle, endAngle, paddingAngle, arcLabelRadius, cornerRadius], getLabelPosition(formattedArcLabel, 'y'))
96
95
  }, style),
97
96
  children: formattedArcLabel
98
97
  }));
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
- var _excluded = ["slots", "slotProps", "innerRadius", "outerRadius", "cornerRadius", "paddingAngle", "id", "highlightScope", "highlighted", "faded", "data", "arcLabel", "arcLabelMinAngle", "skipAnimation"],
4
- _excluded2 = ["startAngle", "endAngle", "paddingAngle", "innerRadius", "outerRadius", "cornerRadius"];
3
+ var _excluded = ["slots", "slotProps", "innerRadius", "outerRadius", "arcLabelRadius", "cornerRadius", "paddingAngle", "id", "highlightScope", "highlighted", "faded", "data", "arcLabel", "arcLabelMinAngle", "skipAnimation"],
4
+ _excluded2 = ["startAngle", "endAngle", "paddingAngle", "innerRadius", "outerRadius", "arcLabelRadius", "cornerRadius"];
5
5
  import * as React from 'react';
6
6
  import PropTypes from 'prop-types';
7
7
  import { useTransition } from '@react-spring/web';
@@ -28,9 +28,9 @@ function PieArcLabelPlot(props) {
28
28
  var _slots$pieArcLabel;
29
29
  var slots = props.slots,
30
30
  slotProps = props.slotProps,
31
- _props$innerRadius = props.innerRadius,
32
- innerRadius = _props$innerRadius === void 0 ? 0 : _props$innerRadius,
31
+ innerRadius = props.innerRadius,
33
32
  outerRadius = props.outerRadius,
33
+ arcLabelRadius = props.arcLabelRadius,
34
34
  _props$cornerRadius = props.cornerRadius,
35
35
  cornerRadius = _props$cornerRadius === void 0 ? 0 : _props$cornerRadius,
36
36
  _props$paddingAngle = props.paddingAngle,
@@ -51,6 +51,7 @@ function PieArcLabelPlot(props) {
51
51
  var transformedData = useTransformData({
52
52
  innerRadius: innerRadius,
53
53
  outerRadius: outerRadius,
54
+ arcLabelRadius: arcLabelRadius,
54
55
  cornerRadius: cornerRadius,
55
56
  paddingAngle: paddingAngle,
56
57
  id: id,
@@ -73,6 +74,7 @@ function PieArcLabelPlot(props) {
73
74
  pA = _ref.paddingAngle,
74
75
  iR = _ref.innerRadius,
75
76
  oR = _ref.outerRadius,
77
+ aLR = _ref.arcLabelRadius,
76
78
  cR = _ref.cornerRadius,
77
79
  style = _objectWithoutProperties(_ref, _excluded2);
78
80
  return /*#__PURE__*/_jsx(ArcLabel, _extends({
@@ -81,6 +83,7 @@ function PieArcLabelPlot(props) {
81
83
  paddingAngle: pA,
82
84
  innerRadius: iR,
83
85
  outerRadius: oR,
86
+ arcLabelRadius: aLR,
84
87
  cornerRadius: cR,
85
88
  style: style,
86
89
  id: id,
@@ -105,6 +108,11 @@ process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
105
108
  * The minimal angle required to display the arc label.
106
109
  */
107
110
  arcLabelMinAngle: PropTypes.number,
111
+ /**
112
+ * The radius between circle center and the arc label in px.
113
+ * @default (innerRadius - outerRadius) / 2
114
+ */
115
+ arcLabelRadius: PropTypes.number,
108
116
  /**
109
117
  * The radius applied to arc corners (similar to border radius).
110
118
  * @default 0
@@ -126,6 +134,7 @@ process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
126
134
  */
127
135
  faded: PropTypes.shape({
128
136
  additionalRadius: PropTypes.number,
137
+ arcLabelRadius: PropTypes.number,
129
138
  color: PropTypes.string,
130
139
  cornerRadius: PropTypes.number,
131
140
  innerRadius: PropTypes.number,
@@ -137,6 +146,7 @@ process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
137
146
  */
138
147
  highlighted: PropTypes.shape({
139
148
  additionalRadius: PropTypes.number,
149
+ arcLabelRadius: PropTypes.number,
140
150
  color: PropTypes.string,
141
151
  cornerRadius: PropTypes.number,
142
152
  innerRadius: PropTypes.number,
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
3
  var _excluded = ["slots", "slotProps", "innerRadius", "outerRadius", "cornerRadius", "paddingAngle", "id", "highlightScope", "highlighted", "faded", "data", "onClick", "skipAnimation"],
4
- _excluded2 = ["startAngle", "endAngle", "paddingAngle", "innerRadius", "outerRadius", "cornerRadius"];
4
+ _excluded2 = ["startAngle", "endAngle", "paddingAngle", "innerRadius", "arcLabelRadius", "outerRadius", "cornerRadius"];
5
5
  import * as React from 'react';
6
6
  import PropTypes from 'prop-types';
7
7
  import { useTransition } from '@react-spring/web';
@@ -55,6 +55,7 @@ function PieArcPlot(props) {
55
55
  endAngle = _ref.endAngle,
56
56
  pA = _ref.paddingAngle,
57
57
  iR = _ref.innerRadius,
58
+ arcLabelRadius = _ref.arcLabelRadius,
58
59
  oR = _ref.outerRadius,
59
60
  cR = _ref.cornerRadius,
60
61
  style = _objectWithoutProperties(_ref, _excluded2);
@@ -88,6 +89,11 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
88
89
  // | These PropTypes are generated from the TypeScript type definitions |
89
90
  // | To update them edit the TypeScript types and run "yarn proptypes" |
90
91
  // ----------------------------------------------------------------------
92
+ /**
93
+ * The radius between circle center and the arc label in px.
94
+ * @default (innerRadius - outerRadius) / 2
95
+ */
96
+ arcLabelRadius: PropTypes.number,
91
97
  /**
92
98
  * The radius applied to arc corners (similar to border radius).
93
99
  * @default 0
@@ -109,6 +115,7 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
109
115
  */
110
116
  faded: PropTypes.shape({
111
117
  additionalRadius: PropTypes.number,
118
+ arcLabelRadius: PropTypes.number,
112
119
  color: PropTypes.string,
113
120
  cornerRadius: PropTypes.number,
114
121
  innerRadius: PropTypes.number,
@@ -120,6 +127,7 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
120
127
  */
121
128
  highlighted: PropTypes.shape({
122
129
  additionalRadius: PropTypes.number,
130
+ arcLabelRadius: PropTypes.number,
123
131
  color: PropTypes.string,
124
132
  cornerRadius: PropTypes.number,
125
133
  innerRadius: PropTypes.number,
@@ -250,6 +250,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
250
250
  series: PropTypes.arrayOf(PropTypes.shape({
251
251
  arcLabel: PropTypes.oneOfType([PropTypes.oneOf(['formattedValue', 'label', 'value']), PropTypes.func]),
252
252
  arcLabelMinAngle: PropTypes.number,
253
+ arcLabelRadius: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
253
254
  color: PropTypes.string,
254
255
  cornerRadius: PropTypes.number,
255
256
  cx: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
@@ -263,6 +264,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
263
264
  endAngle: PropTypes.number,
264
265
  faded: PropTypes.shape({
265
266
  additionalRadius: PropTypes.number,
267
+ arcLabelRadius: PropTypes.number,
266
268
  color: PropTypes.string,
267
269
  cornerRadius: PropTypes.number,
268
270
  innerRadius: PropTypes.number,
@@ -271,6 +273,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
271
273
  }),
272
274
  highlighted: PropTypes.shape({
273
275
  additionalRadius: PropTypes.number,
276
+ arcLabelRadius: PropTypes.number,
274
277
  color: PropTypes.string,
275
278
  cornerRadius: PropTypes.number,
276
279
  innerRadius: PropTypes.number,
@@ -73,6 +73,7 @@ function PiePlot(props) {
73
73
  var _series$seriesId2 = series[seriesId],
74
74
  innerRadiusParam = _series$seriesId2.innerRadius,
75
75
  outerRadiusParam = _series$seriesId2.outerRadius,
76
+ arcLabelRadiusParam = _series$seriesId2.arcLabelRadius,
76
77
  cornerRadius = _series$seriesId2.cornerRadius,
77
78
  paddingAngle = _series$seriesId2.paddingAngle,
78
79
  arcLabel = _series$seriesId2.arcLabel,
@@ -83,6 +84,7 @@ function PiePlot(props) {
83
84
  highlightScope = _series$seriesId2.highlightScope;
84
85
  var outerRadius = getPercentageValue(outerRadiusParam != null ? outerRadiusParam : availableRadius, availableRadius);
85
86
  var innerRadius = getPercentageValue(innerRadiusParam != null ? innerRadiusParam : 0, availableRadius);
87
+ var arcLabelRadius = arcLabelRadiusParam === undefined ? (outerRadius + innerRadius) / 2 : getPercentageValue(arcLabelRadiusParam, availableRadius);
86
88
  var cx = getPercentageValue(cxParam != null ? cxParam : '50%', width);
87
89
  var cy = getPercentageValue(cyParam != null ? cyParam : '50%', height);
88
90
  return /*#__PURE__*/_jsx("g", {
@@ -90,6 +92,7 @@ function PiePlot(props) {
90
92
  children: /*#__PURE__*/_jsx(PieArcLabelPlot, {
91
93
  innerRadius: innerRadius,
92
94
  outerRadius: outerRadius != null ? outerRadius : availableRadius,
95
+ arcLabelRadius: arcLabelRadius,
93
96
  cornerRadius: cornerRadius,
94
97
  paddingAngle: paddingAngle,
95
98
  id: seriesId,
@@ -78,6 +78,7 @@ export var defaultLabelTransitionConfig = {
78
78
  from: function from(_ref5) {
79
79
  var innerRadius = _ref5.innerRadius,
80
80
  outerRadius = _ref5.outerRadius,
81
+ arcLabelRadius = _ref5.arcLabelRadius,
81
82
  cornerRadius = _ref5.cornerRadius,
82
83
  startAngle = _ref5.startAngle,
83
84
  endAngle = _ref5.endAngle,
@@ -86,6 +87,7 @@ export var defaultLabelTransitionConfig = {
86
87
  innerRadius: innerRadius,
87
88
  outerRadius: (innerRadius + outerRadius) / 2,
88
89
  cornerRadius: cornerRadius,
90
+ arcLabelRadius: arcLabelRadius,
89
91
  startAngle: (startAngle + endAngle) / 2,
90
92
  endAngle: (startAngle + endAngle) / 2,
91
93
  paddingAngle: paddingAngle,
@@ -99,6 +101,7 @@ export var defaultLabelTransitionConfig = {
99
101
  return {
100
102
  innerRadius: innerRadius,
101
103
  outerRadius: innerRadius,
104
+ arcLabelRadius: innerRadius,
102
105
  startAngle: (startAngle + endAngle) / 2,
103
106
  endAngle: (startAngle + endAngle) / 2,
104
107
  opacity: 0
@@ -108,12 +111,14 @@ export var defaultLabelTransitionConfig = {
108
111
  var innerRadius = _ref7.innerRadius,
109
112
  outerRadius = _ref7.outerRadius,
110
113
  startAngle = _ref7.startAngle,
111
- endAngle = _ref7.endAngle;
114
+ endAngle = _ref7.endAngle,
115
+ arcLabelRadius = _ref7.arcLabelRadius;
112
116
  return {
113
117
  innerRadius: innerRadius,
114
118
  outerRadius: outerRadius,
115
119
  startAngle: startAngle,
116
120
  endAngle: endAngle,
121
+ arcLabelRadius: arcLabelRadius,
117
122
  opacity: 1
118
123
  };
119
124
  },
@@ -123,7 +128,8 @@ export var defaultLabelTransitionConfig = {
123
128
  cornerRadius = _ref8.cornerRadius,
124
129
  startAngle = _ref8.startAngle,
125
130
  endAngle = _ref8.endAngle,
126
- paddingAngle = _ref8.paddingAngle;
131
+ paddingAngle = _ref8.paddingAngle,
132
+ arcLabelRadius = _ref8.arcLabelRadius;
127
133
  return {
128
134
  innerRadius: innerRadius,
129
135
  outerRadius: outerRadius,
@@ -131,6 +137,7 @@ export var defaultLabelTransitionConfig = {
131
137
  startAngle: startAngle,
132
138
  endAngle: endAngle,
133
139
  paddingAngle: paddingAngle,
140
+ arcLabelRadius: arcLabelRadius,
134
141
  opacity: 1
135
142
  };
136
143
  },
@@ -12,6 +12,7 @@ export function useTransformData(series) {
12
12
  basePaddingAngle = _series$paddingAngle === void 0 ? 0 : _series$paddingAngle,
13
13
  _series$innerRadius = series.innerRadius,
14
14
  baseInnerRadius = _series$innerRadius === void 0 ? 0 : _series$innerRadius,
15
+ baseArcLabelRadius = series.arcLabelRadius,
15
16
  baseOuterRadius = series.outerRadius,
16
17
  _series$cornerRadius = series.cornerRadius,
17
18
  baseCornerRadius = _series$cornerRadius === void 0 ? 0 : _series$cornerRadius;
@@ -35,26 +36,28 @@ export function useTransformData(series) {
35
36
  }, [highlightScope, highlightedItem, seriesId]);
36
37
  var dataWithHighlight = React.useMemo(function () {
37
38
  return data.map(function (item, itemIndex) {
38
- var _attibuesOverride$pad, _attibuesOverride$inn, _attibuesOverride$out, _attibuesOverride$cor;
39
+ var _attributesOverride$p, _attributesOverride$i, _attributesOverride$o, _attributesOverride$c, _ref, _attributesOverride$a;
39
40
  var _getHighlightStatus = getHighlightStatus(itemIndex),
40
41
  isHighlighted = _getHighlightStatus.isHighlighted,
41
42
  isFaded = _getHighlightStatus.isFaded;
42
- var attibuesOverride = _extends({
43
+ var attributesOverride = _extends({
43
44
  additionalRadius: 0
44
45
  }, isFaded && faded || isHighlighted && highlighted || {});
45
- var paddingAngle = Math.max(0, Math.PI * ((_attibuesOverride$pad = attibuesOverride.paddingAngle) != null ? _attibuesOverride$pad : basePaddingAngle) / 180);
46
- var innerRadius = Math.max(0, (_attibuesOverride$inn = attibuesOverride.innerRadius) != null ? _attibuesOverride$inn : baseInnerRadius);
47
- var outerRadius = Math.max(0, (_attibuesOverride$out = attibuesOverride.outerRadius) != null ? _attibuesOverride$out : baseOuterRadius + attibuesOverride.additionalRadius);
48
- var cornerRadius = (_attibuesOverride$cor = attibuesOverride.cornerRadius) != null ? _attibuesOverride$cor : baseCornerRadius;
49
- return _extends({}, item, attibuesOverride, {
46
+ var paddingAngle = Math.max(0, Math.PI * ((_attributesOverride$p = attributesOverride.paddingAngle) != null ? _attributesOverride$p : basePaddingAngle) / 180);
47
+ var innerRadius = Math.max(0, (_attributesOverride$i = attributesOverride.innerRadius) != null ? _attributesOverride$i : baseInnerRadius);
48
+ var outerRadius = Math.max(0, (_attributesOverride$o = attributesOverride.outerRadius) != null ? _attributesOverride$o : baseOuterRadius + attributesOverride.additionalRadius);
49
+ var cornerRadius = (_attributesOverride$c = attributesOverride.cornerRadius) != null ? _attributesOverride$c : baseCornerRadius;
50
+ var arcLabelRadius = (_ref = (_attributesOverride$a = attributesOverride.arcLabelRadius) != null ? _attributesOverride$a : baseArcLabelRadius) != null ? _ref : (innerRadius + outerRadius) / 2;
51
+ return _extends({}, item, attributesOverride, {
50
52
  isFaded: isFaded,
51
53
  isHighlighted: isHighlighted,
52
54
  paddingAngle: paddingAngle,
53
55
  innerRadius: innerRadius,
54
56
  outerRadius: outerRadius,
55
- cornerRadius: cornerRadius
57
+ cornerRadius: cornerRadius,
58
+ arcLabelRadius: arcLabelRadius
56
59
  });
57
60
  });
58
- }, [baseCornerRadius, baseInnerRadius, baseOuterRadius, basePaddingAngle, data, faded, getHighlightStatus, highlighted]);
61
+ }, [baseCornerRadius, baseInnerRadius, baseOuterRadius, basePaddingAngle, baseArcLabelRadius, data, faded, getHighlightStatus, highlighted]);
59
62
  return dataWithHighlight;
60
63
  }
package/legacy/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v7.0.0-alpha.5
2
+ * @mui/x-charts v7.0.0-alpha.7
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the