@mui/x-charts 6.18.7 → 6.19.3

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 (151) hide show
  1. package/BarChart/BarChart.js +1 -0
  2. package/BarChart/BarElement.d.ts +37 -20
  3. package/CHANGELOG.md +155 -0
  4. package/ChartsLegend/ChartsLegend.d.ts +5 -2
  5. package/ChartsLegend/ChartsLegend.js +137 -1
  6. package/ChartsReferenceLine/ChartsReferenceLine.js +7 -3
  7. package/ChartsSurface.d.ts +2 -2
  8. package/ChartsSurface.js +33 -1
  9. package/ChartsTooltip/ChartsAxisTooltipContent.js +2 -54
  10. package/ChartsTooltip/ChartsItemTooltipContent.js +15 -1
  11. package/ChartsTooltip/ChartsTooltipTable.d.ts +1 -1
  12. package/ChartsTooltip/ChartsTooltipTable.js +2 -0
  13. package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -54
  14. package/ChartsTooltip/DefaultChartsItemTooltipContent.js +15 -1
  15. package/LineChart/LineChart.d.ts +1 -0
  16. package/LineChart/LineChart.js +2 -0
  17. package/LineChart/formatter.js +5 -1
  18. package/PieChart/PieArcLabel.d.ts +1 -0
  19. package/PieChart/PieArcLabel.js +7 -8
  20. package/PieChart/PieArcLabelPlot.d.ts +5 -0
  21. package/PieChart/PieArcLabelPlot.js +16 -3
  22. package/PieChart/PieArcPlot.d.ts +5 -0
  23. package/PieChart/PieArcPlot.js +9 -1
  24. package/PieChart/PieChart.d.ts +14 -2
  25. package/PieChart/PieChart.js +6 -2
  26. package/PieChart/PiePlot.js +3 -0
  27. package/PieChart/dataTransform/transition.js +9 -2
  28. package/PieChart/dataTransform/useTransformData.d.ts +1 -0
  29. package/PieChart/dataTransform/useTransformData.js +11 -8
  30. package/ScatterChart/ScatterChart.js +1 -0
  31. package/SparkLineChart/SparkLineChart.d.ts +15 -1
  32. package/SparkLineChart/SparkLineChart.js +8 -1
  33. package/context/CartesianContextProvider.d.ts +1 -1
  34. package/context/CartesianContextProvider.js +7 -6
  35. package/context/DrawingProvider.d.ts +1 -1
  36. package/context/DrawingProvider.js +8 -7
  37. package/context/HighlightProvider.d.ts +2 -2
  38. package/context/HighlightProvider.js +4 -3
  39. package/context/InteractionProvider.d.ts +2 -2
  40. package/context/InteractionProvider.js +4 -3
  41. package/context/SeriesContextProvider.d.ts +3 -1
  42. package/context/SeriesContextProvider.js +7 -6
  43. package/esm/BarChart/BarChart.js +1 -0
  44. package/esm/ChartsLegend/ChartsLegend.js +139 -2
  45. package/esm/ChartsReferenceLine/ChartsReferenceLine.js +7 -3
  46. package/esm/ChartsSurface.js +35 -2
  47. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +2 -54
  48. package/esm/ChartsTooltip/ChartsItemTooltipContent.js +15 -1
  49. package/esm/ChartsTooltip/ChartsTooltipTable.js +2 -0
  50. package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -54
  51. package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +15 -1
  52. package/esm/LineChart/LineChart.js +2 -0
  53. package/esm/LineChart/formatter.js +5 -1
  54. package/esm/PieChart/PieArcLabel.js +7 -8
  55. package/esm/PieChart/PieArcLabelPlot.js +16 -3
  56. package/esm/PieChart/PieArcPlot.js +9 -1
  57. package/esm/PieChart/PieChart.js +6 -2
  58. package/esm/PieChart/PiePlot.js +3 -0
  59. package/esm/PieChart/dataTransform/transition.js +9 -2
  60. package/esm/PieChart/dataTransform/useTransformData.js +12 -9
  61. package/esm/ScatterChart/ScatterChart.js +1 -0
  62. package/esm/SparkLineChart/SparkLineChart.js +8 -1
  63. package/esm/context/CartesianContextProvider.js +7 -6
  64. package/esm/context/DrawingProvider.js +8 -7
  65. package/esm/context/HighlightProvider.js +6 -4
  66. package/esm/context/InteractionProvider.js +6 -4
  67. package/esm/context/SeriesContextProvider.js +9 -7
  68. package/esm/hooks/useDrawingArea.js +7 -3
  69. package/esm/index.js +2 -0
  70. package/esm/internals/stackSeries.js +5 -3
  71. package/esm/models/index.js +1 -0
  72. package/esm/models/stacking.js +1 -0
  73. package/hooks/useDrawingArea.d.ts +2 -0
  74. package/hooks/useDrawingArea.js +7 -3
  75. package/index.d.ts +2 -0
  76. package/index.js +23 -1
  77. package/internals/defaultizeColor.d.ts +7 -4
  78. package/internals/stackSeries.d.ts +8 -3
  79. package/internals/stackSeries.js +4 -3
  80. package/legacy/BarChart/BarChart.js +1 -0
  81. package/legacy/ChartsLegend/ChartsLegend.js +139 -2
  82. package/legacy/ChartsReferenceLine/ChartsReferenceLine.js +5 -3
  83. package/legacy/ChartsReferenceLine/common.js +3 -4
  84. package/legacy/ChartsSurface.js +35 -2
  85. package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +2 -54
  86. package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +15 -1
  87. package/legacy/ChartsTooltip/ChartsTooltipTable.js +8 -7
  88. package/legacy/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -54
  89. package/legacy/ChartsTooltip/DefaultChartsItemTooltipContent.js +15 -1
  90. package/legacy/LineChart/LineChart.js +2 -0
  91. package/legacy/LineChart/formatter.js +6 -2
  92. package/legacy/PieChart/PieArcLabel.js +7 -6
  93. package/legacy/PieChart/PieArcLabelPlot.js +16 -4
  94. package/legacy/PieChart/PieArcPlot.js +10 -1
  95. package/legacy/PieChart/PieChart.js +6 -2
  96. package/legacy/PieChart/PiePlot.js +3 -0
  97. package/legacy/PieChart/dataTransform/transition.js +9 -2
  98. package/legacy/PieChart/dataTransform/useTransformData.js +12 -9
  99. package/legacy/ScatterChart/ScatterChart.js +1 -0
  100. package/legacy/SparkLineChart/SparkLineChart.js +8 -1
  101. package/legacy/context/CartesianContextProvider.js +15 -15
  102. package/legacy/context/DrawingProvider.js +6 -6
  103. package/legacy/context/HighlightProvider.js +4 -3
  104. package/legacy/context/InteractionProvider.js +4 -3
  105. package/legacy/context/SeriesContextProvider.js +8 -7
  106. package/legacy/hooks/useDrawingArea.js +7 -3
  107. package/legacy/index.js +3 -1
  108. package/legacy/internals/components/AxisSharedComponents.js +5 -6
  109. package/legacy/internals/stackSeries.js +5 -3
  110. package/legacy/models/index.js +1 -0
  111. package/legacy/models/stacking.js +1 -0
  112. package/models/index.d.ts +1 -0
  113. package/models/index.js +11 -0
  114. package/models/seriesType/bar.d.ts +6 -0
  115. package/models/seriesType/common.d.ts +2 -3
  116. package/models/seriesType/index.d.ts +0 -1
  117. package/models/seriesType/line.d.ts +6 -0
  118. package/models/seriesType/pie.d.ts +15 -0
  119. package/models/stacking.d.ts +2 -0
  120. package/models/stacking.js +5 -0
  121. package/modern/BarChart/BarChart.js +1 -0
  122. package/modern/ChartsLegend/ChartsLegend.js +139 -2
  123. package/modern/ChartsReferenceLine/ChartsReferenceLine.js +7 -3
  124. package/modern/ChartsSurface.js +35 -2
  125. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +2 -54
  126. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +15 -1
  127. package/modern/ChartsTooltip/ChartsTooltipTable.js +2 -0
  128. package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -54
  129. package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +15 -1
  130. package/modern/LineChart/LineChart.js +2 -0
  131. package/modern/LineChart/formatter.js +5 -1
  132. package/modern/PieChart/PieArcLabel.js +7 -8
  133. package/modern/PieChart/PieArcLabelPlot.js +16 -3
  134. package/modern/PieChart/PieArcPlot.js +9 -1
  135. package/modern/PieChart/PieChart.js +6 -2
  136. package/modern/PieChart/PiePlot.js +3 -0
  137. package/modern/PieChart/dataTransform/transition.js +9 -2
  138. package/modern/PieChart/dataTransform/useTransformData.js +11 -8
  139. package/modern/ScatterChart/ScatterChart.js +1 -0
  140. package/modern/SparkLineChart/SparkLineChart.js +8 -1
  141. package/modern/context/CartesianContextProvider.js +7 -6
  142. package/modern/context/DrawingProvider.js +8 -7
  143. package/modern/context/HighlightProvider.js +6 -4
  144. package/modern/context/InteractionProvider.js +6 -4
  145. package/modern/context/SeriesContextProvider.js +9 -7
  146. package/modern/hooks/useDrawingArea.js +7 -3
  147. package/modern/index.js +3 -1
  148. package/modern/internals/stackSeries.js +4 -3
  149. package/modern/models/index.js +1 -0
  150. package/modern/models/stacking.js +1 -0
  151. package/package.json +1 -1
@@ -80,37 +80,7 @@ process.env.NODE_ENV !== "production" ? DefaultChartsAxisTooltipContent.propType
80
80
  /**
81
81
  * The properties of the triggered axis.
82
82
  */
83
- axis: PropTypes.shape({
84
- axisId: PropTypes.string,
85
- classes: PropTypes.object,
86
- data: PropTypes.array,
87
- dataKey: PropTypes.string,
88
- disableLine: PropTypes.bool,
89
- disableTicks: PropTypes.bool,
90
- fill: PropTypes.string,
91
- hideTooltip: PropTypes.bool,
92
- id: PropTypes.string.isRequired,
93
- label: PropTypes.string,
94
- labelFontSize: PropTypes.number,
95
- labelStyle: PropTypes.object,
96
- max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
97
- min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
98
- position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
99
- scale: PropTypes.func.isRequired,
100
- scaleType: PropTypes.oneOf(['time']).isRequired,
101
- slotProps: PropTypes.object,
102
- slots: PropTypes.object,
103
- stroke: PropTypes.string,
104
- tickFontSize: PropTypes.number,
105
- tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
106
- tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
107
- tickLabelStyle: PropTypes.object,
108
- tickMaxStep: PropTypes.number,
109
- tickMinStep: PropTypes.number,
110
- tickNumber: PropTypes.number.isRequired,
111
- tickSize: PropTypes.number,
112
- valueFormatter: PropTypes.func
113
- }).isRequired,
83
+ axis: PropTypes.object.isRequired,
114
84
  /**
115
85
  * Data identifying the triggered axis.
116
86
  */
@@ -139,29 +109,7 @@ process.env.NODE_ENV !== "production" ? DefaultChartsAxisTooltipContent.propType
139
109
  /**
140
110
  * The series linked to the triggered axis.
141
111
  */
142
- series: PropTypes.arrayOf(PropTypes.shape({
143
- area: PropTypes.bool,
144
- color: PropTypes.string.isRequired,
145
- connectNulls: PropTypes.bool,
146
- curve: PropTypes.oneOf(['catmullRom', 'linear', 'monotoneX', 'monotoneY', 'natural', 'step', 'stepAfter', 'stepBefore']),
147
- data: PropTypes.arrayOf(PropTypes.number).isRequired,
148
- dataKey: PropTypes.string,
149
- disableHighlight: PropTypes.bool,
150
- highlightScope: PropTypes.shape({
151
- faded: PropTypes.oneOf(['global', 'none', 'series']),
152
- highlighted: PropTypes.oneOf(['item', 'none', 'series'])
153
- }),
154
- id: PropTypes.string.isRequired,
155
- label: PropTypes.string,
156
- showMark: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]),
157
- stack: PropTypes.string,
158
- stackOffset: PropTypes.oneOf(['diverging', 'expand', 'none', 'silhouette', 'wiggle']),
159
- stackOrder: PropTypes.oneOf(['appearance', 'ascending', 'descending', 'insideOut', 'none', 'reverse']),
160
- type: PropTypes.oneOf(['line']).isRequired,
161
- valueFormatter: PropTypes.func.isRequired,
162
- xAxisKey: PropTypes.string,
163
- yAxisKey: PropTypes.string
164
- })).isRequired,
112
+ series: PropTypes.arrayOf(PropTypes.object).isRequired,
165
113
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
166
114
  } : void 0;
167
115
  export { DefaultChartsAxisTooltipContent };
@@ -78,7 +78,21 @@ process.env.NODE_ENV !== "production" ? DefaultChartsItemTooltipContent.propType
78
78
  */
79
79
  series: PropTypes.shape({
80
80
  color: PropTypes.string,
81
- data: PropTypes.arrayOf(PropTypes.number).isRequired,
81
+ data: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.number), PropTypes.arrayOf(PropTypes.number), PropTypes.arrayOf(PropTypes.shape({
82
+ id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
83
+ x: PropTypes.number.isRequired,
84
+ y: PropTypes.number.isRequired
85
+ })), PropTypes.arrayOf(PropTypes.shape({
86
+ color: PropTypes.string.isRequired,
87
+ endAngle: PropTypes.number.isRequired,
88
+ formattedValue: PropTypes.string.isRequired,
89
+ id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
90
+ index: PropTypes.number.isRequired,
91
+ label: PropTypes.string,
92
+ padAngle: PropTypes.number.isRequired,
93
+ startAngle: PropTypes.number.isRequired,
94
+ value: PropTypes.number.isRequired
95
+ }))]).isRequired,
82
96
  highlightScope: PropTypes.shape({
83
97
  faded: PropTypes.oneOf(['global', 'none', 'series']),
84
98
  highlighted: PropTypes.oneOf(['item', 'none', 'series'])
@@ -117,6 +117,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
117
117
  * - 'none': display nothing.
118
118
  * - 'line': display a line at the current mouse position.
119
119
  * - 'band': display a band at the current mouse position. Only available with band scale.
120
+ * @default { x: 'line' }
120
121
  */
121
122
  axisHighlight: PropTypes.shape({
122
123
  x: PropTypes.oneOf(['band', 'line', 'none']),
@@ -153,6 +154,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
153
154
  className: PropTypes.string,
154
155
  /**
155
156
  * Color palette used to colorize multiple series.
157
+ * @default blueberryTwilightPalette
156
158
  */
157
159
  colors: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.func]),
158
160
  /**
@@ -10,7 +10,11 @@ const formatter = (params, dataset) => {
10
10
  seriesOrder,
11
11
  series
12
12
  } = params;
13
- const stackingGroups = getStackingGroups(params);
13
+ const stackingGroups = getStackingGroups(_extends({}, params, {
14
+ defaultStrategy: {
15
+ stackOffset: 'none'
16
+ }
17
+ }));
14
18
 
15
19
  // Create a data set with format adapted to d3
16
20
  const d3Dataset = dataset ?? [];
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["id", "classes", "color", "startAngle", "endAngle", "paddingAngle", "innerRadius", "outerRadius", "cornerRadius", "formattedArcLabel", "isHighlighted", "isFaded", "style"];
3
+ const _excluded = ["id", "classes", "color", "startAngle", "endAngle", "paddingAngle", "arcLabelRadius", "innerRadius", "outerRadius", "cornerRadius", "formattedArcLabel", "isHighlighted", "isFaded", "style"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import { animated, to } from '@react-spring/web';
@@ -41,7 +41,7 @@ const PieArcLabelRoot = styled(animated.text, {
41
41
  * Helper to compute label position.
42
42
  * It's not an inline function because we need it in inerpolation.
43
43
  */
44
- const getLabelPosition = (formattedArcLabel, variable) => (startAngle, endAngle, padAngle, innerRadius, outerRadius, cornerRadius) => {
44
+ const getLabelPosition = (formattedArcLabel, variable) => (startAngle, endAngle, padAngle, arcLabelRadius, cornerRadius) => {
45
45
  if (!formattedArcLabel) {
46
46
  return 0;
47
47
  }
@@ -49,8 +49,8 @@ const getLabelPosition = (formattedArcLabel, variable) => (startAngle, endAngle,
49
49
  padAngle,
50
50
  startAngle,
51
51
  endAngle,
52
- innerRadius,
53
- outerRadius
52
+ innerRadius: arcLabelRadius,
53
+ outerRadius: arcLabelRadius
54
54
  });
55
55
  if (variable === 'x') {
56
56
  return x;
@@ -65,8 +65,7 @@ function PieArcLabel(props) {
65
65
  startAngle,
66
66
  endAngle,
67
67
  paddingAngle,
68
- innerRadius,
69
- outerRadius,
68
+ arcLabelRadius,
70
69
  cornerRadius,
71
70
  formattedArcLabel,
72
71
  isHighlighted,
@@ -86,8 +85,8 @@ function PieArcLabel(props) {
86
85
  className: classes.root
87
86
  }, other, {
88
87
  style: _extends({
89
- x: to([startAngle, endAngle, paddingAngle, innerRadius, outerRadius, cornerRadius], getLabelPosition(formattedArcLabel, 'x')),
90
- y: to([startAngle, endAngle, paddingAngle, innerRadius, outerRadius, cornerRadius], getLabelPosition(formattedArcLabel, 'y'))
88
+ x: to([startAngle, endAngle, paddingAngle, arcLabelRadius, cornerRadius], getLabelPosition(formattedArcLabel, 'x')),
89
+ y: to([startAngle, endAngle, paddingAngle, arcLabelRadius, cornerRadius], getLabelPosition(formattedArcLabel, 'y'))
91
90
  }, style),
92
91
  children: formattedArcLabel
93
92
  }));
@@ -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';
@@ -27,8 +27,9 @@ function PieArcLabelPlot(props) {
27
27
  const {
28
28
  slots,
29
29
  slotProps,
30
- innerRadius = 0,
30
+ innerRadius,
31
31
  outerRadius,
32
+ arcLabelRadius,
32
33
  cornerRadius = 0,
33
34
  paddingAngle = 0,
34
35
  id,
@@ -46,6 +47,7 @@ function PieArcLabelPlot(props) {
46
47
  const transformedData = useTransformData({
47
48
  innerRadius,
48
49
  outerRadius,
50
+ arcLabelRadius,
49
51
  cornerRadius,
50
52
  paddingAngle,
51
53
  id,
@@ -69,6 +71,7 @@ function PieArcLabelPlot(props) {
69
71
  paddingAngle: pA,
70
72
  innerRadius: iR,
71
73
  outerRadius: oR,
74
+ arcLabelRadius: aLR,
72
75
  cornerRadius: cR
73
76
  } = _ref,
74
77
  style = _objectWithoutPropertiesLoose(_ref, _excluded2);
@@ -78,6 +81,7 @@ function PieArcLabelPlot(props) {
78
81
  paddingAngle: pA,
79
82
  innerRadius: iR,
80
83
  outerRadius: oR,
84
+ arcLabelRadius: aLR,
81
85
  cornerRadius: cR,
82
86
  style: style,
83
87
  id: id,
@@ -100,8 +104,14 @@ process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
100
104
  arcLabel: PropTypes.oneOfType([PropTypes.oneOf(['formattedValue', 'label', 'value']), PropTypes.func]),
101
105
  /**
102
106
  * The minimal angle required to display the arc label.
107
+ * @default 0
103
108
  */
104
109
  arcLabelMinAngle: PropTypes.number,
110
+ /**
111
+ * The radius between circle center and the arc label in px.
112
+ * @default (innerRadius - outerRadius) / 2
113
+ */
114
+ arcLabelRadius: PropTypes.number,
105
115
  /**
106
116
  * The radius applied to arc corners (similar to border radius).
107
117
  * @default 0
@@ -120,9 +130,11 @@ process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
120
130
  })).isRequired,
121
131
  /**
122
132
  * Override the arc attibutes when it is faded.
133
+ * @default { additionalRadius: -5 }
123
134
  */
124
135
  faded: PropTypes.shape({
125
136
  additionalRadius: PropTypes.number,
137
+ arcLabelRadius: PropTypes.number,
126
138
  color: PropTypes.string,
127
139
  cornerRadius: PropTypes.number,
128
140
  innerRadius: PropTypes.number,
@@ -134,6 +146,7 @@ process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
134
146
  */
135
147
  highlighted: PropTypes.shape({
136
148
  additionalRadius: PropTypes.number,
149
+ arcLabelRadius: PropTypes.number,
137
150
  color: PropTypes.string,
138
151
  cornerRadius: PropTypes.number,
139
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';
@@ -87,6 +87,11 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
87
87
  // | These PropTypes are generated from the TypeScript type definitions |
88
88
  // | To update them edit the TypeScript types and run "yarn proptypes" |
89
89
  // ----------------------------------------------------------------------
90
+ /**
91
+ * The radius between circle center and the arc label in px.
92
+ * @default (innerRadius - outerRadius) / 2
93
+ */
94
+ arcLabelRadius: PropTypes.number,
90
95
  /**
91
96
  * The radius applied to arc corners (similar to border radius).
92
97
  * @default 0
@@ -105,9 +110,11 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
105
110
  })).isRequired,
106
111
  /**
107
112
  * Override the arc attibutes when it is faded.
113
+ * @default { additionalRadius: -5 }
108
114
  */
109
115
  faded: PropTypes.shape({
110
116
  additionalRadius: PropTypes.number,
117
+ arcLabelRadius: PropTypes.number,
111
118
  color: PropTypes.string,
112
119
  cornerRadius: PropTypes.number,
113
120
  innerRadius: PropTypes.number,
@@ -119,6 +126,7 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
119
126
  */
120
127
  highlighted: PropTypes.shape({
121
128
  additionalRadius: PropTypes.number,
129
+ arcLabelRadius: PropTypes.number,
122
130
  color: PropTypes.string,
123
131
  cornerRadius: PropTypes.number,
124
132
  innerRadius: PropTypes.number,
@@ -108,7 +108,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
108
108
  /**
109
109
  * Indicate which axis to display the bottom of the charts.
110
110
  * Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
111
- * @default xAxisIds[0] The id of the first provided axis
111
+ * @default null
112
112
  */
113
113
  bottomAxis: PropTypes.oneOfType([PropTypes.shape({
114
114
  axisId: PropTypes.string,
@@ -136,6 +136,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
136
136
  className: PropTypes.string,
137
137
  /**
138
138
  * Color palette used to colorize multiple series.
139
+ * @default blueberryTwilightPalette
139
140
  */
140
141
  colors: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.func]),
141
142
  /**
@@ -157,7 +158,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
157
158
  /**
158
159
  * Indicate which axis to display the left of the charts.
159
160
  * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
160
- * @default yAxisIds[0] The id of the first provided axis
161
+ * @default null
161
162
  */
162
163
  leftAxis: PropTypes.oneOfType([PropTypes.shape({
163
164
  axisId: PropTypes.string,
@@ -238,6 +239,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
238
239
  series: PropTypes.arrayOf(PropTypes.shape({
239
240
  arcLabel: PropTypes.oneOfType([PropTypes.oneOf(['formattedValue', 'label', 'value']), PropTypes.func]),
240
241
  arcLabelMinAngle: PropTypes.number,
242
+ arcLabelRadius: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
241
243
  color: PropTypes.string,
242
244
  cornerRadius: PropTypes.number,
243
245
  cx: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
@@ -251,6 +253,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
251
253
  endAngle: PropTypes.number,
252
254
  faded: PropTypes.shape({
253
255
  additionalRadius: PropTypes.number,
256
+ arcLabelRadius: PropTypes.number,
254
257
  color: PropTypes.string,
255
258
  cornerRadius: PropTypes.number,
256
259
  innerRadius: PropTypes.number,
@@ -259,6 +262,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
259
262
  }),
260
263
  highlighted: PropTypes.shape({
261
264
  additionalRadius: PropTypes.number,
265
+ arcLabelRadius: PropTypes.number,
262
266
  color: PropTypes.string,
263
267
  cornerRadius: PropTypes.number,
264
268
  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 ?? availableRadius, availableRadius);
92
93
  const innerRadius = getPercentageValue(innerRadiusParam ?? 0, availableRadius);
94
+ const arcLabelRadius = arcLabelRadiusParam === undefined ? (outerRadius + innerRadius) / 2 : getPercentageValue(arcLabelRadiusParam, availableRadius);
93
95
  const cx = getPercentageValue(cxParam ?? '50%', width);
94
96
  const cy = getPercentageValue(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 ?? 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;
@@ -38,21 +39,23 @@ export function useTransformData(series) {
38
39
  isHighlighted,
39
40
  isFaded
40
41
  } = getHighlightStatus(itemIndex);
41
- const attibuesOverride = _extends({
42
+ const attributesOverride = _extends({
42
43
  additionalRadius: 0
43
44
  }, isFaded && faded || isHighlighted && highlighted || {});
44
- const paddingAngle = Math.max(0, Math.PI * (attibuesOverride.paddingAngle ?? basePaddingAngle) / 180);
45
- const innerRadius = Math.max(0, attibuesOverride.innerRadius ?? baseInnerRadius);
46
- const outerRadius = Math.max(0, attibuesOverride.outerRadius ?? baseOuterRadius + attibuesOverride.additionalRadius);
47
- const cornerRadius = attibuesOverride.cornerRadius ?? baseCornerRadius;
48
- return _extends({}, item, attibuesOverride, {
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;
50
+ return _extends({}, item, attributesOverride, {
49
51
  isFaded,
50
52
  isHighlighted,
51
53
  paddingAngle,
52
54
  innerRadius,
53
55
  outerRadius,
54
- cornerRadius
56
+ cornerRadius,
57
+ arcLabelRadius
55
58
  });
56
- }), [baseCornerRadius, baseInnerRadius, baseOuterRadius, basePaddingAngle, data, faded, getHighlightStatus, highlighted]);
59
+ }), [baseCornerRadius, baseInnerRadius, baseOuterRadius, basePaddingAngle, baseArcLabelRadius, data, faded, getHighlightStatus, highlighted]);
57
60
  return dataWithHighlight;
58
61
  }
@@ -113,6 +113,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
113
113
  className: PropTypes.string,
114
114
  /**
115
115
  * Color palette used to colorize multiple series.
116
+ * @default blueberryTwilightPalette
116
117
  */
117
118
  colors: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.func]),
118
119
  /**
@@ -119,6 +119,7 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
119
119
  className: PropTypes.string,
120
120
  /**
121
121
  * Color palette used to colorize multiple series.
122
+ * @default blueberryTwilightPalette
122
123
  */
123
124
  colors: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.func]),
124
125
  /**
@@ -149,7 +150,12 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
149
150
  * The margin between the SVG and the drawing area.
150
151
  * It's used for leaving some space for extra information such as the x- and y-axis or legend.
151
152
  * Accepts an object with the optional properties: `top`, `bottom`, `left`, and `right`.
152
- * @default object Depends on the charts type.
153
+ * @default {
154
+ * top: 5,
155
+ * bottom: 5,
156
+ * left: 5,
157
+ * right: 5,
158
+ * }
153
159
  */
154
160
  margin: PropTypes.shape({
155
161
  bottom: PropTypes.number,
@@ -198,6 +204,7 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
198
204
  * Formatter used by the tooltip.
199
205
  * @param {number} value The value to format.
200
206
  * @returns {string} the formatted value.
207
+ * @default (v: number) => v.toString()
201
208
  */
202
209
  valueFormatter: PropTypes.func,
203
210
  viewBox: PropTypes.shape({
@@ -38,12 +38,13 @@ export const CartesianContext = /*#__PURE__*/React.createContext({
38
38
  *
39
39
  * - [CartesianContextProvider API](https://mui.com/x/api/charts/cartesian-context-provider/)
40
40
  */
41
- function CartesianContextProvider({
42
- xAxis: inXAxis,
43
- yAxis: inYAxis,
44
- dataset,
45
- children
46
- }) {
41
+ function CartesianContextProvider(props) {
42
+ const {
43
+ xAxis: inXAxis,
44
+ yAxis: inYAxis,
45
+ dataset,
46
+ children
47
+ } = props;
47
48
  const formattedSeries = React.useContext(SeriesContext);
48
49
  const drawingArea = React.useContext(DrawingContext);
49
50
  const xAxis = React.useMemo(() => inXAxis?.map(axisConfig => {
@@ -23,13 +23,14 @@ export const SVGContext = /*#__PURE__*/React.createContext({
23
23
  *
24
24
  * - [DrawingProvider API](https://mui.com/x/api/charts/drawing-provider/)
25
25
  */
26
- function DrawingProvider({
27
- width,
28
- height,
29
- margin,
30
- svgRef,
31
- children
32
- }) {
26
+ function DrawingProvider(props) {
27
+ const {
28
+ width,
29
+ height,
30
+ margin,
31
+ svgRef,
32
+ children
33
+ } = props;
33
34
  const drawingArea = useChartDimensions(width, height, margin);
34
35
  return /*#__PURE__*/_jsx(SVGContext.Provider, {
35
36
  value: svgRef,
@@ -29,9 +29,10 @@ const dataReducer = (prevState, action) => {
29
29
  return prevState;
30
30
  }
31
31
  };
32
- export function HighlightProvider({
33
- children
34
- }) {
32
+ function HighlightProvider(props) {
33
+ const {
34
+ children
35
+ } = props;
35
36
  const [data, dispatch] = React.useReducer(dataReducer, {
36
37
  item: null,
37
38
  scope: defaultScope
@@ -43,4 +44,5 @@ export function HighlightProvider({
43
44
  value: value,
44
45
  children: children
45
46
  });
46
- }
47
+ }
48
+ export { HighlightProvider };
@@ -31,9 +31,10 @@ const dataReducer = (prevState, action) => {
31
31
  return prevState;
32
32
  }
33
33
  };
34
- export function InteractionProvider({
35
- children
36
- }) {
34
+ function InteractionProvider(props) {
35
+ const {
36
+ children
37
+ } = props;
37
38
  const [data, dispatch] = React.useReducer(dataReducer, {
38
39
  item: null,
39
40
  axis: {
@@ -48,4 +49,5 @@ export function InteractionProvider({
48
49
  value: value,
49
50
  children: children
50
51
  });
51
- }
52
+ }
53
+ export { InteractionProvider };
@@ -55,16 +55,18 @@ const formatSeries = (series, colors, dataset) => {
55
55
  });
56
56
  return formattedSeries;
57
57
  };
58
- export function SeriesContextProvider({
59
- series,
60
- dataset,
61
- colors = blueberryTwilightPalette,
62
- children
63
- }) {
58
+ function SeriesContextProvider(props) {
59
+ const {
60
+ series,
61
+ dataset,
62
+ colors = blueberryTwilightPalette,
63
+ children
64
+ } = props;
64
65
  const theme = useTheme();
65
66
  const formattedSeries = React.useMemo(() => formatSeries(series, typeof colors === 'function' ? colors(theme.palette.mode) : colors, dataset), [series, colors, theme.palette.mode, dataset]);
66
67
  return /*#__PURE__*/_jsx(SeriesContext.Provider, {
67
68
  value: formattedSeries,
68
69
  children: children
69
70
  });
70
- }
71
+ }
72
+ export { SeriesContextProvider };
@@ -5,12 +5,16 @@ export function useDrawingArea() {
5
5
  left,
6
6
  top,
7
7
  width,
8
- height
8
+ height,
9
+ bottom,
10
+ right
9
11
  } = React.useContext(DrawingContext);
10
12
  return React.useMemo(() => ({
11
13
  left,
12
14
  top,
13
15
  width,
14
- height
15
- }), [height, left, top, width]);
16
+ height,
17
+ bottom,
18
+ right
19
+ }), [height, left, top, width, bottom, right]);
16
20
  }
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v6.18.7
2
+ * @mui/x-charts v6.19.3
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -24,4 +24,6 @@ export * from './PieChart';
24
24
  export * from './ScatterChart';
25
25
  export * from './SparkLineChart';
26
26
  export * from './ChartContainer';
27
+ export * from './ChartsSurface';
28
+ export * from './ChartsLegend';
27
29
  export * from './ResponsiveChartContainer';