@mui/x-charts 6.18.2 → 6.18.4

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 (190) hide show
  1. package/BarChart/BarElement.d.ts +5 -1
  2. package/BarChart/BarElement.js +24 -1
  3. package/BarChart/BarPlot.js +7 -6
  4. package/BarChart/formatter.js +15 -3
  5. package/BarChart/index.d.ts +3 -2
  6. package/BarChart/index.js +31 -12
  7. package/CHANGELOG.md +192 -1
  8. package/ChartsAxis/ChartsAxis.js +4 -4
  9. package/ChartsLegend/ChartsLegend.d.ts +1 -1
  10. package/ChartsLegend/ChartsLegend.js +3 -2
  11. package/ChartsLegend/index.d.ts +1 -0
  12. package/ChartsLegend/index.js +11 -0
  13. package/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  14. package/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
  15. package/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
  16. package/ChartsReferenceLine/common.d.ts +1 -1
  17. package/ChartsText/ChartsText.d.ts +17 -0
  18. package/{internals/components → ChartsText}/ChartsText.js +32 -17
  19. package/ChartsText/index.d.ts +3 -0
  20. package/ChartsText/index.js +12 -0
  21. package/ChartsText/package.json +6 -0
  22. package/ChartsTooltip/ChartsAxisTooltipContent.d.ts +5 -2
  23. package/ChartsTooltip/ChartsAxisTooltipContent.js +93 -73
  24. package/ChartsTooltip/ChartsItemTooltipContent.d.ts +5 -2
  25. package/ChartsTooltip/ChartsItemTooltipContent.js +38 -57
  26. package/ChartsTooltip/DefaultChartsAxisTooltipContent.d.ts +7 -0
  27. package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +174 -0
  28. package/ChartsTooltip/DefaultChartsItemTooltipContent.d.ts +8 -0
  29. package/ChartsTooltip/DefaultChartsItemTooltipContent.js +99 -0
  30. package/ChartsTooltip/index.d.ts +4 -0
  31. package/ChartsTooltip/index.js +44 -0
  32. package/ChartsXAxis/ChartsXAxis.js +3 -2
  33. package/ChartsYAxis/ChartsYAxis.js +7 -5
  34. package/LineChart/AreaPlot.js +3 -2
  35. package/LineChart/LineHighlightPlot.js +2 -1
  36. package/LineChart/LinePlot.js +3 -2
  37. package/LineChart/MarkPlot.js +2 -1
  38. package/LineChart/extremums.js +25 -8
  39. package/LineChart/formatter.js +14 -2
  40. package/LineChart/index.d.ts +5 -5
  41. package/LineChart/index.js +50 -41
  42. package/PieChart/PieArcLabelPlot.d.ts +7 -4
  43. package/PieChart/PieArcLabelPlot.js +88 -1
  44. package/PieChart/PieArcPlot.d.ts +7 -4
  45. package/PieChart/PieArcPlot.js +87 -1
  46. package/PieChart/PieChart.js +4 -4
  47. package/PieChart/PiePlot.js +20 -15
  48. package/PieChart/dataTransform/useTransformData.d.ts +2 -3
  49. package/PieChart/index.d.ts +6 -6
  50. package/PieChart/index.js +60 -46
  51. package/ResponsiveChartContainer/index.js +2 -2
  52. package/ScatterChart/Scatter.js +1 -1
  53. package/ScatterChart/index.d.ts +3 -3
  54. package/ScatterChart/index.js +31 -19
  55. package/context/CartesianContextProvider.js +2 -2
  56. package/context/SeriesContextProvider.js +1 -1
  57. package/esm/BarChart/BarElement.js +26 -2
  58. package/esm/BarChart/BarPlot.js +7 -5
  59. package/esm/BarChart/formatter.js +20 -4
  60. package/esm/BarChart/index.js +3 -2
  61. package/esm/ChartsAxis/ChartsAxis.js +4 -4
  62. package/esm/ChartsLegend/ChartsLegend.js +2 -1
  63. package/esm/ChartsLegend/index.js +2 -1
  64. package/esm/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  65. package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
  66. package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
  67. package/esm/{internals/components → ChartsText}/ChartsText.js +33 -16
  68. package/esm/ChartsText/index.js +1 -0
  69. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +95 -75
  70. package/esm/ChartsTooltip/ChartsItemTooltipContent.js +40 -58
  71. package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +168 -0
  72. package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +92 -0
  73. package/esm/ChartsTooltip/index.js +5 -1
  74. package/esm/ChartsXAxis/ChartsXAxis.js +2 -1
  75. package/esm/ChartsYAxis/ChartsYAxis.js +7 -5
  76. package/esm/LineChart/AreaPlot.js +3 -2
  77. package/esm/LineChart/LineHighlightPlot.js +2 -1
  78. package/esm/LineChart/LinePlot.js +3 -2
  79. package/esm/LineChart/MarkPlot.js +2 -1
  80. package/esm/LineChart/extremums.js +25 -8
  81. package/esm/LineChart/formatter.js +16 -3
  82. package/esm/LineChart/index.js +5 -5
  83. package/esm/PieChart/PieArcLabelPlot.js +90 -2
  84. package/esm/PieChart/PieArcPlot.js +89 -2
  85. package/esm/PieChart/PieChart.js +4 -4
  86. package/esm/PieChart/PiePlot.js +20 -15
  87. package/esm/PieChart/index.js +6 -4
  88. package/esm/ResponsiveChartContainer/index.js +2 -2
  89. package/esm/ScatterChart/Scatter.js +1 -1
  90. package/esm/ScatterChart/index.js +3 -3
  91. package/esm/context/CartesianContextProvider.js +2 -2
  92. package/esm/context/SeriesContextProvider.js +1 -1
  93. package/esm/index.js +1 -0
  94. package/esm/internals/defaultizeValueFormatter.js +4 -3
  95. package/esm/internals/getWordsByLines.js +14 -0
  96. package/esm/internals/utils.js +40 -0
  97. package/index.d.ts +1 -0
  98. package/index.js +12 -1
  99. package/internals/defaultizeColor.d.ts +4 -4
  100. package/internals/defaultizeValueFormatter.d.ts +3 -1
  101. package/internals/defaultizeValueFormatter.js +3 -3
  102. package/internals/{components/ChartsText.d.ts → getWordsByLines.d.ts} +2 -11
  103. package/internals/getWordsByLines.js +21 -0
  104. package/internals/utils.d.ts +13 -0
  105. package/internals/utils.js +42 -0
  106. package/legacy/BarChart/BarElement.js +26 -2
  107. package/legacy/BarChart/BarPlot.js +7 -5
  108. package/legacy/BarChart/formatter.js +23 -9
  109. package/legacy/BarChart/index.js +3 -2
  110. package/legacy/ChartsAxis/ChartsAxis.js +4 -4
  111. package/legacy/ChartsLegend/ChartsLegend.js +2 -1
  112. package/legacy/ChartsLegend/index.js +2 -1
  113. package/legacy/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  114. package/legacy/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
  115. package/legacy/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
  116. package/legacy/{internals/components → ChartsText}/ChartsText.js +38 -22
  117. package/legacy/ChartsText/index.js +1 -0
  118. package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +95 -74
  119. package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +40 -55
  120. package/legacy/ChartsTooltip/DefaultChartsAxisTooltipContent.js +167 -0
  121. package/legacy/ChartsTooltip/DefaultChartsItemTooltipContent.js +89 -0
  122. package/legacy/ChartsTooltip/index.js +5 -1
  123. package/legacy/ChartsXAxis/ChartsXAxis.js +2 -1
  124. package/legacy/ChartsYAxis/ChartsYAxis.js +7 -5
  125. package/legacy/LineChart/AreaPlot.js +3 -2
  126. package/legacy/LineChart/LineHighlightPlot.js +2 -1
  127. package/legacy/LineChart/LinePlot.js +3 -2
  128. package/legacy/LineChart/MarkPlot.js +2 -1
  129. package/legacy/LineChart/extremums.js +29 -14
  130. package/legacy/LineChart/formatter.js +19 -8
  131. package/legacy/LineChart/index.js +5 -5
  132. package/legacy/PieChart/PieArcLabelPlot.js +90 -2
  133. package/legacy/PieChart/PieArcPlot.js +89 -2
  134. package/legacy/PieChart/PieChart.js +4 -4
  135. package/legacy/PieChart/PiePlot.js +20 -15
  136. package/legacy/PieChart/index.js +6 -4
  137. package/legacy/ResponsiveChartContainer/index.js +2 -2
  138. package/legacy/ScatterChart/Scatter.js +1 -1
  139. package/legacy/ScatterChart/index.js +3 -3
  140. package/legacy/context/CartesianContextProvider.js +2 -2
  141. package/legacy/context/SeriesContextProvider.js +1 -1
  142. package/legacy/index.js +2 -1
  143. package/legacy/internals/defaultizeValueFormatter.js +4 -3
  144. package/legacy/internals/getWordsByLines.js +15 -0
  145. package/legacy/internals/utils.js +40 -0
  146. package/models/axis.d.ts +1 -1
  147. package/models/seriesType/config.d.ts +9 -4
  148. package/models/seriesType/pie.d.ts +29 -7
  149. package/models/seriesType/scatter.d.ts +1 -1
  150. package/modern/BarChart/BarElement.js +26 -2
  151. package/modern/BarChart/BarPlot.js +7 -5
  152. package/modern/BarChart/formatter.js +15 -3
  153. package/modern/BarChart/index.js +3 -2
  154. package/modern/ChartsAxis/ChartsAxis.js +4 -4
  155. package/modern/ChartsLegend/ChartsLegend.js +2 -1
  156. package/modern/ChartsLegend/index.js +2 -1
  157. package/modern/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  158. package/modern/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
  159. package/modern/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
  160. package/modern/{internals/components → ChartsText}/ChartsText.js +33 -16
  161. package/modern/ChartsText/index.js +1 -0
  162. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +95 -74
  163. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +40 -58
  164. package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +167 -0
  165. package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +92 -0
  166. package/modern/ChartsTooltip/index.js +5 -1
  167. package/modern/ChartsXAxis/ChartsXAxis.js +2 -1
  168. package/modern/ChartsYAxis/ChartsYAxis.js +7 -5
  169. package/modern/LineChart/AreaPlot.js +3 -2
  170. package/modern/LineChart/LineHighlightPlot.js +2 -1
  171. package/modern/LineChart/LinePlot.js +3 -2
  172. package/modern/LineChart/MarkPlot.js +2 -1
  173. package/modern/LineChart/extremums.js +25 -8
  174. package/modern/LineChart/formatter.js +14 -2
  175. package/modern/LineChart/index.js +5 -5
  176. package/modern/PieChart/PieArcLabelPlot.js +90 -2
  177. package/modern/PieChart/PieArcPlot.js +89 -2
  178. package/modern/PieChart/PieChart.js +4 -4
  179. package/modern/PieChart/PiePlot.js +20 -15
  180. package/modern/PieChart/index.js +6 -4
  181. package/modern/ResponsiveChartContainer/index.js +2 -2
  182. package/modern/ScatterChart/Scatter.js +1 -1
  183. package/modern/ScatterChart/index.js +3 -3
  184. package/modern/context/CartesianContextProvider.js +2 -2
  185. package/modern/context/SeriesContextProvider.js +1 -1
  186. package/modern/index.js +2 -1
  187. package/modern/internals/defaultizeValueFormatter.js +3 -3
  188. package/modern/internals/getWordsByLines.js +14 -0
  189. package/modern/internals/utils.js +40 -0
  190. package/package.json +1 -1
@@ -3,6 +3,7 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
3
3
  const _excluded = ["slots", "slotProps", "innerRadius", "outerRadius", "cornerRadius", "paddingAngle", "id", "highlightScope", "highlighted", "faded", "data", "arcLabel", "arcLabelMinAngle", "skipAnimation"],
4
4
  _excluded2 = ["startAngle", "endAngle", "paddingAngle", "innerRadius", "outerRadius", "cornerRadius"];
5
5
  import * as React from 'react';
6
+ import PropTypes from 'prop-types';
6
7
  import { useTransition } from '@react-spring/web';
7
8
  import { defaultLabelTransitionConfig } from './dataTransform/transition';
8
9
  import { useTransformData } from './dataTransform/useTransformData';
@@ -22,7 +23,7 @@ function getItemLabel(arcLabel, arcLabelMinAngle, item) {
22
23
  }
23
24
  return arcLabel(item);
24
25
  }
25
- export function PieArcLabelPlot(props) {
26
+ function PieArcLabelPlot(props) {
26
27
  const {
27
28
  slots,
28
29
  slotProps,
@@ -87,4 +88,91 @@ export function PieArcLabelPlot(props) {
87
88
  }, slotProps?.pieArcLabel));
88
89
  })
89
90
  }));
90
- }
91
+ }
92
+ process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
93
+ // ----------------------------- Warning --------------------------------
94
+ // | These PropTypes are generated from the TypeScript type definitions |
95
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
96
+ // ----------------------------------------------------------------------
97
+ /**
98
+ * The label displayed into the arc.
99
+ */
100
+ arcLabel: PropTypes.oneOfType([PropTypes.oneOf(['formattedValue', 'label', 'value']), PropTypes.func]),
101
+ /**
102
+ * The minimal angle required to display the arc label.
103
+ */
104
+ arcLabelMinAngle: PropTypes.number,
105
+ /**
106
+ * The radius applied to arc corners (similar to border radius).
107
+ * @default 0
108
+ */
109
+ cornerRadius: PropTypes.number,
110
+ data: PropTypes.arrayOf(PropTypes.shape({
111
+ color: PropTypes.string.isRequired,
112
+ endAngle: PropTypes.number.isRequired,
113
+ formattedValue: PropTypes.string.isRequired,
114
+ id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
115
+ index: PropTypes.number.isRequired,
116
+ label: PropTypes.string,
117
+ padAngle: PropTypes.number.isRequired,
118
+ startAngle: PropTypes.number.isRequired,
119
+ value: PropTypes.number.isRequired
120
+ })).isRequired,
121
+ /**
122
+ * Override the arc attibutes when it is faded.
123
+ */
124
+ faded: PropTypes.shape({
125
+ additionalRadius: PropTypes.number,
126
+ color: PropTypes.string,
127
+ cornerRadius: PropTypes.number,
128
+ innerRadius: PropTypes.number,
129
+ outerRadius: PropTypes.number,
130
+ paddingAngle: PropTypes.number
131
+ }),
132
+ /**
133
+ * Override the arc attibutes when it is highlighted.
134
+ */
135
+ highlighted: PropTypes.shape({
136
+ additionalRadius: PropTypes.number,
137
+ color: PropTypes.string,
138
+ cornerRadius: PropTypes.number,
139
+ innerRadius: PropTypes.number,
140
+ outerRadius: PropTypes.number,
141
+ paddingAngle: PropTypes.number
142
+ }),
143
+ highlightScope: PropTypes.shape({
144
+ faded: PropTypes.oneOf(['global', 'none', 'series']),
145
+ highlighted: PropTypes.oneOf(['item', 'none', 'series'])
146
+ }),
147
+ id: PropTypes.string.isRequired,
148
+ /**
149
+ * The radius between circle center and the begining of the arc.
150
+ * @default 0
151
+ */
152
+ innerRadius: PropTypes.number,
153
+ /**
154
+ * The radius between circle center and the end of the arc.
155
+ */
156
+ outerRadius: PropTypes.number.isRequired,
157
+ /**
158
+ * The padding angle (deg) between two arcs.
159
+ * @default 0
160
+ */
161
+ paddingAngle: PropTypes.number,
162
+ /**
163
+ * If `true`, animations are skiped.
164
+ * @default false
165
+ */
166
+ skipAnimation: PropTypes.bool,
167
+ /**
168
+ * The props used for each component slot.
169
+ * @default {}
170
+ */
171
+ slotProps: PropTypes.object,
172
+ /**
173
+ * Overridable component slots.
174
+ * @default {}
175
+ */
176
+ slots: PropTypes.object
177
+ } : void 0;
178
+ export { PieArcLabelPlot };
@@ -3,12 +3,13 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
3
3
  const _excluded = ["slots", "slotProps", "innerRadius", "outerRadius", "cornerRadius", "paddingAngle", "id", "highlightScope", "highlighted", "faded", "data", "onClick", "skipAnimation"],
4
4
  _excluded2 = ["startAngle", "endAngle", "paddingAngle", "innerRadius", "outerRadius", "cornerRadius"];
5
5
  import * as React from 'react';
6
+ import PropTypes from 'prop-types';
6
7
  import { useTransition } from '@react-spring/web';
7
8
  import { PieArc } from './PieArc';
8
9
  import { defaultTransitionConfig } from './dataTransform/transition';
9
10
  import { useTransformData } from './dataTransform/useTransformData';
10
11
  import { jsx as _jsx } from "react/jsx-runtime";
11
- export function PieArcPlot(props) {
12
+ function PieArcPlot(props) {
12
13
  const {
13
14
  slots,
14
15
  slotProps,
@@ -80,4 +81,90 @@ export function PieArcPlot(props) {
80
81
  }, slotProps?.pieArc));
81
82
  })
82
83
  }));
83
- }
84
+ }
85
+ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
86
+ // ----------------------------- Warning --------------------------------
87
+ // | These PropTypes are generated from the TypeScript type definitions |
88
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
89
+ // ----------------------------------------------------------------------
90
+ /**
91
+ * The radius applied to arc corners (similar to border radius).
92
+ * @default 0
93
+ */
94
+ cornerRadius: PropTypes.number,
95
+ data: PropTypes.arrayOf(PropTypes.shape({
96
+ color: PropTypes.string.isRequired,
97
+ endAngle: PropTypes.number.isRequired,
98
+ formattedValue: PropTypes.string.isRequired,
99
+ id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
100
+ index: PropTypes.number.isRequired,
101
+ label: PropTypes.string,
102
+ padAngle: PropTypes.number.isRequired,
103
+ startAngle: PropTypes.number.isRequired,
104
+ value: PropTypes.number.isRequired
105
+ })).isRequired,
106
+ /**
107
+ * Override the arc attibutes when it is faded.
108
+ */
109
+ faded: PropTypes.shape({
110
+ additionalRadius: PropTypes.number,
111
+ color: PropTypes.string,
112
+ cornerRadius: PropTypes.number,
113
+ innerRadius: PropTypes.number,
114
+ outerRadius: PropTypes.number,
115
+ paddingAngle: PropTypes.number
116
+ }),
117
+ /**
118
+ * Override the arc attibutes when it is highlighted.
119
+ */
120
+ highlighted: PropTypes.shape({
121
+ additionalRadius: PropTypes.number,
122
+ color: PropTypes.string,
123
+ cornerRadius: PropTypes.number,
124
+ innerRadius: PropTypes.number,
125
+ outerRadius: PropTypes.number,
126
+ paddingAngle: PropTypes.number
127
+ }),
128
+ highlightScope: PropTypes.shape({
129
+ faded: PropTypes.oneOf(['global', 'none', 'series']),
130
+ highlighted: PropTypes.oneOf(['item', 'none', 'series'])
131
+ }),
132
+ id: PropTypes.string.isRequired,
133
+ /**
134
+ * The radius between circle center and the begining of the arc.
135
+ * @default 0
136
+ */
137
+ innerRadius: PropTypes.number,
138
+ /**
139
+ * Callback fired when a pie item is clicked.
140
+ * @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
141
+ * @param {PieItemIdentifier} pieItemIdentifier The pie item identifier.
142
+ * @param {DefaultizedPieValueType} item The pie item.
143
+ */
144
+ onClick: PropTypes.func,
145
+ /**
146
+ * The radius between circle center and the end of the arc.
147
+ */
148
+ outerRadius: PropTypes.number.isRequired,
149
+ /**
150
+ * The padding angle (deg) between two arcs.
151
+ * @default 0
152
+ */
153
+ paddingAngle: PropTypes.number,
154
+ /**
155
+ * If `true`, animations are skiped.
156
+ * @default false
157
+ */
158
+ skipAnimation: PropTypes.bool,
159
+ /**
160
+ * The props used for each component slot.
161
+ * @default {}
162
+ */
163
+ slotProps: PropTypes.object,
164
+ /**
165
+ * Overridable component slots.
166
+ * @default {}
167
+ */
168
+ slots: PropTypes.object
169
+ } : void 0;
170
+ export { PieArcPlot };
@@ -240,8 +240,8 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
240
240
  arcLabelMinAngle: PropTypes.number,
241
241
  color: PropTypes.string,
242
242
  cornerRadius: PropTypes.number,
243
- cx: PropTypes.number,
244
- cy: PropTypes.number,
243
+ cx: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
244
+ cy: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
245
245
  data: PropTypes.arrayOf(PropTypes.shape({
246
246
  color: PropTypes.string,
247
247
  id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
@@ -270,8 +270,8 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
270
270
  highlighted: PropTypes.oneOf(['item', 'none', 'series'])
271
271
  }),
272
272
  id: PropTypes.string,
273
- innerRadius: PropTypes.number,
274
- outerRadius: PropTypes.number,
273
+ innerRadius: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
274
+ outerRadius: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
275
275
  paddingAngle: PropTypes.number,
276
276
  sortingValues: PropTypes.oneOfType([PropTypes.oneOf(['asc', 'desc', 'none']), PropTypes.func]),
277
277
  startAngle: PropTypes.number,
@@ -4,6 +4,7 @@ import { SeriesContext } from '../context/SeriesContextProvider';
4
4
  import { DrawingContext } from '../context/DrawingProvider';
5
5
  import { PieArcPlot } from './PieArcPlot';
6
6
  import { PieArcLabelPlot } from './PieArcLabelPlot';
7
+ import { getPercentageValue } from '../internals/utils';
7
8
  import { jsx as _jsx } from "react/jsx-runtime";
8
9
  import { jsxs as _jsxs } from "react/jsx-runtime";
9
10
  /**
@@ -34,10 +35,6 @@ function PiePlot(props) {
34
35
  return null;
35
36
  }
36
37
  const availableRadius = Math.min(width, height) / 2;
37
- const center = {
38
- x: left + width / 2,
39
- y: top + height / 2
40
- };
41
38
  const {
42
39
  series,
43
40
  seriesOrder
@@ -45,22 +42,26 @@ function PiePlot(props) {
45
42
  return /*#__PURE__*/_jsxs("g", {
46
43
  children: [seriesOrder.map(seriesId => {
47
44
  const {
48
- innerRadius,
49
- outerRadius,
45
+ innerRadius: innerRadiusParam,
46
+ outerRadius: outerRadiusParam,
50
47
  cornerRadius,
51
48
  paddingAngle,
52
49
  data,
53
- cx,
54
- cy,
50
+ cx: cxParam,
51
+ cy: cyParam,
55
52
  highlighted,
56
53
  faded,
57
54
  highlightScope
58
55
  } = series[seriesId];
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);
59
60
  return /*#__PURE__*/_jsx("g", {
60
- transform: `translate(${cx === undefined ? center.x : left + cx}, ${cy === undefined ? center.y : top + cy})`,
61
+ transform: `translate(${left + cx}, ${top + cy})`,
61
62
  children: /*#__PURE__*/_jsx(PieArcPlot, {
62
63
  innerRadius: innerRadius,
63
- outerRadius: outerRadius ?? availableRadius,
64
+ outerRadius: outerRadius,
64
65
  cornerRadius: cornerRadius,
65
66
  paddingAngle: paddingAngle,
66
67
  id: seriesId,
@@ -76,19 +77,23 @@ function PiePlot(props) {
76
77
  }, seriesId);
77
78
  }), seriesOrder.map(seriesId => {
78
79
  const {
79
- innerRadius,
80
- outerRadius,
80
+ innerRadius: innerRadiusParam,
81
+ outerRadius: outerRadiusParam,
81
82
  cornerRadius,
82
83
  paddingAngle,
83
84
  arcLabel,
84
85
  arcLabelMinAngle,
85
86
  data,
86
- cx,
87
- cy,
87
+ cx: cxParam,
88
+ cy: cyParam,
88
89
  highlightScope
89
90
  } = series[seriesId];
91
+ const outerRadius = getPercentageValue(outerRadiusParam ?? availableRadius, availableRadius);
92
+ const innerRadius = getPercentageValue(innerRadiusParam ?? 0, availableRadius);
93
+ const cx = getPercentageValue(cxParam ?? '50%', width);
94
+ const cy = getPercentageValue(cyParam ?? '50%', height);
90
95
  return /*#__PURE__*/_jsx("g", {
91
- transform: `translate(${cx === undefined ? center.x : left + cx}, ${cy === undefined ? center.y : top + cy})`,
96
+ transform: `translate(${left + cx}, ${top + cy})`,
92
97
  children: /*#__PURE__*/_jsx(PieArcLabelPlot, {
93
98
  innerRadius: innerRadius,
94
99
  outerRadius: outerRadius ?? availableRadius,
@@ -1,4 +1,6 @@
1
- export { PiePlot } from './PiePlot';
2
- export { PieChart } from './PieChart';
3
- export { PieArcLabel, getPieArcLabelUtilityClass, pieArcLabelClasses } from './PieArcLabel';
4
- export { PieArc, getPieArcUtilityClass, pieArcClasses } from './PieArc';
1
+ export * from './PieChart';
2
+ export * from './PiePlot';
3
+ export * from './PieArcPlot';
4
+ export * from './PieArcLabelPlot';
5
+ export * from './PieArc';
6
+ export * from './PieArcLabel';
@@ -60,11 +60,11 @@ const useChartDimensions = (inWidth, inHeight) => {
60
60
  }, [computeSize, inHeight, inWidth]);
61
61
  if (process.env.NODE_ENV !== 'production') {
62
62
  if (displayError.current && inWidth === undefined && width === 0) {
63
- console.error(`MUI: Charts does not have \`width\` prop, and its container has no \`width\` defined.`);
63
+ console.error(`MUI-X-Charts: ChartContainer does not have \`width\` prop, and its container has no \`width\` defined.`);
64
64
  displayError.current = false;
65
65
  }
66
66
  if (displayError.current && inHeight === undefined && height === 0) {
67
- console.error(`MUI: Charts does not have \`height\` prop, and its container has no \`height\` defined.`);
67
+ console.error(`MUI-X-Charts: ChartContainer does not have \`height\` prop, and its container has no \`height\` defined.`);
68
68
  displayError.current = false;
69
69
  }
70
70
  }
@@ -78,7 +78,7 @@ process.env.NODE_ENV !== "production" ? Scatter.propTypes = {
78
78
  color: PropTypes.string.isRequired,
79
79
  markerSize: PropTypes.number.isRequired,
80
80
  series: PropTypes.shape({
81
- color: PropTypes.string,
81
+ color: PropTypes.string.isRequired,
82
82
  data: PropTypes.arrayOf(PropTypes.shape({
83
83
  id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
84
84
  x: PropTypes.number.isRequired,
@@ -1,3 +1,3 @@
1
- export { ScatterPlot } from './ScatterPlot';
2
- export { ScatterChart } from './ScatterChart';
3
- export { Scatter } from './Scatter';
1
+ export * from './ScatterChart';
2
+ export * from './ScatterPlot';
3
+ export * from './Scatter';
@@ -52,7 +52,7 @@ function CartesianContextProvider({
52
52
  return axisConfig;
53
53
  }
54
54
  if (dataset === undefined) {
55
- throw Error('MUI: x-axis uses `dataKey` but no `dataset` is provided.');
55
+ throw Error('MUI-X-Charts: x-axis uses `dataKey` but no `dataset` is provided.');
56
56
  }
57
57
  return _extends({}, axisConfig, {
58
58
  data: dataset.map(d => d[dataKey])
@@ -64,7 +64,7 @@ function CartesianContextProvider({
64
64
  return axisConfig;
65
65
  }
66
66
  if (dataset === undefined) {
67
- throw Error('MUI: y-axis uses `dataKey` but no `dataset` is provided.');
67
+ throw Error('MUI-X-Charts: y-axis uses `dataKey` but no `dataset` is provided.');
68
68
  }
69
69
  return _extends({}, axisConfig, {
70
70
  data: dataset.map(d => d[dataKey])
@@ -39,7 +39,7 @@ const formatSeries = (series, colors, dataset) => {
39
39
  };
40
40
  }
41
41
  if (seriesGroups[type]?.series[id] !== undefined) {
42
- throw new Error(`MUI: series' id "${id}" is not unique`);
42
+ throw new Error(`MUI-X-Charts: series' id "${id}" is not unique`);
43
43
  }
44
44
  seriesGroups[type].series[id] = _extends({
45
45
  id
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v6.18.2
2
+ * @mui/x-charts v6.18.4
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -15,6 +15,7 @@ export * from './ChartsReferenceLine';
15
15
  export * from './ChartsAxis';
16
16
  export * from './ChartsXAxis';
17
17
  export * from './ChartsYAxis';
18
+ export * from './ChartsText';
18
19
  export * from './ChartsTooltip';
19
20
  export * from './ChartsAxisHighlight';
20
21
  export * from './BarChart';
@@ -2,9 +2,9 @@ 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
- defaultizedSeries[seriesId] = _extends({
6
- valueFormatter: defaultValueFormatter
7
- }, series[seriesId]);
5
+ defaultizedSeries[seriesId] = _extends({}, series[seriesId], {
6
+ valueFormatter: series[seriesId].valueFormatter ?? defaultValueFormatter
7
+ });
8
8
  });
9
9
  return defaultizedSeries;
10
10
  }
@@ -0,0 +1,14 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import { getStringSize } from './domUtils';
3
+ export function getWordsByLines({
4
+ style,
5
+ needsComputation,
6
+ text
7
+ }) {
8
+ return text.split('\n').map(subText => _extends({
9
+ text: subText
10
+ }, needsComputation ? getStringSize(subText, style) : {
11
+ width: 0,
12
+ height: 0
13
+ }));
14
+ }
@@ -2,4 +2,44 @@
2
2
  export function getSymbol(shape) {
3
3
  const symbolNames = 'circle cross diamond square star triangle wye'.split(/ /);
4
4
  return symbolNames.indexOf(shape) || 0;
5
+ }
6
+ /**
7
+ * Transform mouse event position to corrdinates inside the SVG.
8
+ * @param svg The SVG element
9
+ * @param event The mouseEvent to transform
10
+ */
11
+ export function getSVGPoint(svg, event) {
12
+ const pt = svg.createSVGPoint();
13
+ pt.x = event.clientX;
14
+ pt.y = event.clientY;
15
+ return pt.matrixTransform(svg.getScreenCTM().inverse());
16
+ }
17
+
18
+ /**
19
+ * Helper that converts values and percentages into values.
20
+ * @param value The value provided by the developer. Can either be a number or a string with '%' or 'px'.
21
+ * @param refValue The numerical value associated to 100%.
22
+ * @returns The numerical value associated to the provided value.
23
+ */
24
+ export function getPercentageValue(value, refValue) {
25
+ if (typeof value === 'number') {
26
+ return value;
27
+ }
28
+ if (value === '100%') {
29
+ // Avoid potential rounding issues
30
+ return refValue;
31
+ }
32
+ if (value.endsWith('%')) {
33
+ const percentage = Number.parseFloat(value.slice(0, value.length - 1));
34
+ if (!Number.isNaN(percentage)) {
35
+ return percentage * refValue / 100;
36
+ }
37
+ }
38
+ if (value.endsWith('px')) {
39
+ const val = Number.parseFloat(value.slice(0, value.length - 2));
40
+ if (!Number.isNaN(val)) {
41
+ return val;
42
+ }
43
+ }
44
+ throw Error(`MUI-Charts: Received an unknown value "${value}". It should be a number, or a string with a percentage value.`);
5
45
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-charts",
3
- "version": "6.18.2",
3
+ "version": "6.18.4",
4
4
  "description": "The community edition of the charts components (MUI X).",
5
5
  "author": "MUI Team",
6
6
  "main": "./index.js",