@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
@@ -8,6 +8,7 @@ exports.PieArcPlot = PieArcPlot;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
9
  var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
10
10
  var React = _interopRequireWildcard(require("react"));
11
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
12
  var _web = require("@react-spring/web");
12
13
  var _PieArc = require("./PieArc");
13
14
  var _transition = require("./dataTransform/transition");
@@ -89,4 +90,89 @@ function PieArcPlot(props) {
89
90
  }, slotProps?.pieArc));
90
91
  })
91
92
  }));
92
- }
93
+ }
94
+ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
95
+ // ----------------------------- Warning --------------------------------
96
+ // | These PropTypes are generated from the TypeScript type definitions |
97
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
98
+ // ----------------------------------------------------------------------
99
+ /**
100
+ * The radius applied to arc corners (similar to border radius).
101
+ * @default 0
102
+ */
103
+ cornerRadius: _propTypes.default.number,
104
+ data: _propTypes.default.arrayOf(_propTypes.default.shape({
105
+ color: _propTypes.default.string.isRequired,
106
+ endAngle: _propTypes.default.number.isRequired,
107
+ formattedValue: _propTypes.default.string.isRequired,
108
+ id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
109
+ index: _propTypes.default.number.isRequired,
110
+ label: _propTypes.default.string,
111
+ padAngle: _propTypes.default.number.isRequired,
112
+ startAngle: _propTypes.default.number.isRequired,
113
+ value: _propTypes.default.number.isRequired
114
+ })).isRequired,
115
+ /**
116
+ * Override the arc attibutes when it is faded.
117
+ */
118
+ faded: _propTypes.default.shape({
119
+ additionalRadius: _propTypes.default.number,
120
+ color: _propTypes.default.string,
121
+ cornerRadius: _propTypes.default.number,
122
+ innerRadius: _propTypes.default.number,
123
+ outerRadius: _propTypes.default.number,
124
+ paddingAngle: _propTypes.default.number
125
+ }),
126
+ /**
127
+ * Override the arc attibutes when it is highlighted.
128
+ */
129
+ highlighted: _propTypes.default.shape({
130
+ additionalRadius: _propTypes.default.number,
131
+ color: _propTypes.default.string,
132
+ cornerRadius: _propTypes.default.number,
133
+ innerRadius: _propTypes.default.number,
134
+ outerRadius: _propTypes.default.number,
135
+ paddingAngle: _propTypes.default.number
136
+ }),
137
+ highlightScope: _propTypes.default.shape({
138
+ faded: _propTypes.default.oneOf(['global', 'none', 'series']),
139
+ highlighted: _propTypes.default.oneOf(['item', 'none', 'series'])
140
+ }),
141
+ id: _propTypes.default.string.isRequired,
142
+ /**
143
+ * The radius between circle center and the begining of the arc.
144
+ * @default 0
145
+ */
146
+ innerRadius: _propTypes.default.number,
147
+ /**
148
+ * Callback fired when a pie item is clicked.
149
+ * @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
150
+ * @param {PieItemIdentifier} pieItemIdentifier The pie item identifier.
151
+ * @param {DefaultizedPieValueType} item The pie item.
152
+ */
153
+ onClick: _propTypes.default.func,
154
+ /**
155
+ * The radius between circle center and the end of the arc.
156
+ */
157
+ outerRadius: _propTypes.default.number.isRequired,
158
+ /**
159
+ * The padding angle (deg) between two arcs.
160
+ * @default 0
161
+ */
162
+ paddingAngle: _propTypes.default.number,
163
+ /**
164
+ * If `true`, animations are skiped.
165
+ * @default false
166
+ */
167
+ skipAnimation: _propTypes.default.bool,
168
+ /**
169
+ * The props used for each component slot.
170
+ * @default {}
171
+ */
172
+ slotProps: _propTypes.default.object,
173
+ /**
174
+ * Overridable component slots.
175
+ * @default {}
176
+ */
177
+ slots: _propTypes.default.object
178
+ } : void 0;
@@ -248,8 +248,8 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
248
248
  arcLabelMinAngle: _propTypes.default.number,
249
249
  color: _propTypes.default.string,
250
250
  cornerRadius: _propTypes.default.number,
251
- cx: _propTypes.default.number,
252
- cy: _propTypes.default.number,
251
+ cx: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
252
+ cy: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
253
253
  data: _propTypes.default.arrayOf(_propTypes.default.shape({
254
254
  color: _propTypes.default.string,
255
255
  id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
@@ -278,8 +278,8 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
278
278
  highlighted: _propTypes.default.oneOf(['item', 'none', 'series'])
279
279
  }),
280
280
  id: _propTypes.default.string,
281
- innerRadius: _propTypes.default.number,
282
- outerRadius: _propTypes.default.number,
281
+ innerRadius: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
282
+ outerRadius: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
283
283
  paddingAngle: _propTypes.default.number,
284
284
  sortingValues: _propTypes.default.oneOfType([_propTypes.default.oneOf(['asc', 'desc', 'none']), _propTypes.default.func]),
285
285
  startAngle: _propTypes.default.number,
@@ -11,6 +11,7 @@ var _SeriesContextProvider = require("../context/SeriesContextProvider");
11
11
  var _DrawingProvider = require("../context/DrawingProvider");
12
12
  var _PieArcPlot = require("./PieArcPlot");
13
13
  var _PieArcLabelPlot = require("./PieArcLabelPlot");
14
+ var _utils = require("../internals/utils");
14
15
  var _jsxRuntime = require("react/jsx-runtime");
15
16
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
16
17
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -42,10 +43,6 @@ function PiePlot(props) {
42
43
  return null;
43
44
  }
44
45
  const availableRadius = Math.min(width, height) / 2;
45
- const center = {
46
- x: left + width / 2,
47
- y: top + height / 2
48
- };
49
46
  const {
50
47
  series,
51
48
  seriesOrder
@@ -53,22 +50,26 @@ function PiePlot(props) {
53
50
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("g", {
54
51
  children: [seriesOrder.map(seriesId => {
55
52
  const {
56
- innerRadius,
57
- outerRadius,
53
+ innerRadius: innerRadiusParam,
54
+ outerRadius: outerRadiusParam,
58
55
  cornerRadius,
59
56
  paddingAngle,
60
57
  data,
61
- cx,
62
- cy,
58
+ cx: cxParam,
59
+ cy: cyParam,
63
60
  highlighted,
64
61
  faded,
65
62
  highlightScope
66
63
  } = series[seriesId];
64
+ const outerRadius = (0, _utils.getPercentageValue)(outerRadiusParam ?? availableRadius, availableRadius);
65
+ const innerRadius = (0, _utils.getPercentageValue)(innerRadiusParam ?? 0, availableRadius);
66
+ const cx = (0, _utils.getPercentageValue)(cxParam ?? '50%', width);
67
+ const cy = (0, _utils.getPercentageValue)(cyParam ?? '50%', height);
67
68
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {
68
- transform: `translate(${cx === undefined ? center.x : left + cx}, ${cy === undefined ? center.y : top + cy})`,
69
+ transform: `translate(${left + cx}, ${top + cy})`,
69
70
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PieArcPlot.PieArcPlot, {
70
71
  innerRadius: innerRadius,
71
- outerRadius: outerRadius ?? availableRadius,
72
+ outerRadius: outerRadius,
72
73
  cornerRadius: cornerRadius,
73
74
  paddingAngle: paddingAngle,
74
75
  id: seriesId,
@@ -84,19 +85,23 @@ function PiePlot(props) {
84
85
  }, seriesId);
85
86
  }), seriesOrder.map(seriesId => {
86
87
  const {
87
- innerRadius,
88
- outerRadius,
88
+ innerRadius: innerRadiusParam,
89
+ outerRadius: outerRadiusParam,
89
90
  cornerRadius,
90
91
  paddingAngle,
91
92
  arcLabel,
92
93
  arcLabelMinAngle,
93
94
  data,
94
- cx,
95
- cy,
95
+ cx: cxParam,
96
+ cy: cyParam,
96
97
  highlightScope
97
98
  } = series[seriesId];
99
+ const outerRadius = (0, _utils.getPercentageValue)(outerRadiusParam ?? availableRadius, availableRadius);
100
+ const innerRadius = (0, _utils.getPercentageValue)(innerRadiusParam ?? 0, availableRadius);
101
+ const cx = (0, _utils.getPercentageValue)(cxParam ?? '50%', width);
102
+ const cy = (0, _utils.getPercentageValue)(cyParam ?? '50%', height);
98
103
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {
99
- transform: `translate(${cx === undefined ? center.x : left + cx}, ${cy === undefined ? center.y : top + cy})`,
104
+ transform: `translate(${left + cx}, ${top + cy})`,
100
105
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PieArcLabelPlot.PieArcLabelPlot, {
101
106
  innerRadius: innerRadius,
102
107
  outerRadius: outerRadius ?? availableRadius,
@@ -1,5 +1,4 @@
1
- import { DefaultizedPieSeriesType, DefaultizedPieValueType } from '../../models/seriesType/pie';
2
- import { DefaultizedProps } from '../../models/helpers';
1
+ import { ComputedPieRadius, DefaultizedPieSeriesType, DefaultizedPieValueType } from '../../models/seriesType/pie';
3
2
  export interface AnimatedObject {
4
3
  innerRadius: number;
5
4
  outerRadius: number;
@@ -12,4 +11,4 @@ export interface ValueWithHighlight extends DefaultizedPieValueType, AnimatedObj
12
11
  isFaded: boolean;
13
12
  isHighlighted: boolean;
14
13
  }
15
- export declare function useTransformData(series: DefaultizedProps<Pick<DefaultizedPieSeriesType, 'innerRadius' | 'outerRadius' | 'cornerRadius' | 'paddingAngle' | 'id' | 'highlightScope' | 'highlighted' | 'faded' | 'data'>, 'outerRadius'>): ValueWithHighlight[];
14
+ export declare function useTransformData(series: Pick<DefaultizedPieSeriesType, 'cornerRadius' | 'paddingAngle' | 'id' | 'highlightScope' | 'highlighted' | 'faded' | 'data'> & ComputedPieRadius): ValueWithHighlight[];
@@ -1,6 +1,6 @@
1
- export { PiePlot } from './PiePlot';
2
- export { PieChart } from './PieChart';
3
- export { PieArcLabel, getPieArcLabelUtilityClass, pieArcLabelClasses } from './PieArcLabel';
4
- export type { PieArcLabelClassKey, PieArcLabelClasses, PieArcLabelProps } from './PieArcLabel';
5
- export { PieArc, getPieArcUtilityClass, pieArcClasses } from './PieArc';
6
- export type { PieArcClassKey, PieArcClasses, PieArcProps } 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';
package/PieChart/index.js CHANGED
@@ -3,55 +3,69 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "PieArc", {
7
- enumerable: true,
8
- get: function () {
9
- return _PieArc.PieArc;
10
- }
11
- });
12
- Object.defineProperty(exports, "PieArcLabel", {
13
- enumerable: true,
14
- get: function () {
15
- return _PieArcLabel.PieArcLabel;
16
- }
17
- });
18
- Object.defineProperty(exports, "PieChart", {
19
- enumerable: true,
20
- get: function () {
21
- return _PieChart.PieChart;
22
- }
23
- });
24
- Object.defineProperty(exports, "PiePlot", {
25
- enumerable: true,
26
- get: function () {
27
- return _PiePlot.PiePlot;
28
- }
6
+ var _PieChart = require("./PieChart");
7
+ Object.keys(_PieChart).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _PieChart[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _PieChart[key];
14
+ }
15
+ });
29
16
  });
30
- Object.defineProperty(exports, "getPieArcLabelUtilityClass", {
31
- enumerable: true,
32
- get: function () {
33
- return _PieArcLabel.getPieArcLabelUtilityClass;
34
- }
17
+ var _PiePlot = require("./PiePlot");
18
+ Object.keys(_PiePlot).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _PiePlot[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _PiePlot[key];
25
+ }
26
+ });
35
27
  });
36
- Object.defineProperty(exports, "getPieArcUtilityClass", {
37
- enumerable: true,
38
- get: function () {
39
- return _PieArc.getPieArcUtilityClass;
40
- }
28
+ var _PieArcPlot = require("./PieArcPlot");
29
+ Object.keys(_PieArcPlot).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (key in exports && exports[key] === _PieArcPlot[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function () {
35
+ return _PieArcPlot[key];
36
+ }
37
+ });
41
38
  });
42
- Object.defineProperty(exports, "pieArcClasses", {
43
- enumerable: true,
44
- get: function () {
45
- return _PieArc.pieArcClasses;
46
- }
39
+ var _PieArcLabelPlot = require("./PieArcLabelPlot");
40
+ Object.keys(_PieArcLabelPlot).forEach(function (key) {
41
+ if (key === "default" || key === "__esModule") return;
42
+ if (key in exports && exports[key] === _PieArcLabelPlot[key]) return;
43
+ Object.defineProperty(exports, key, {
44
+ enumerable: true,
45
+ get: function () {
46
+ return _PieArcLabelPlot[key];
47
+ }
48
+ });
47
49
  });
48
- Object.defineProperty(exports, "pieArcLabelClasses", {
49
- enumerable: true,
50
- get: function () {
51
- return _PieArcLabel.pieArcLabelClasses;
52
- }
50
+ var _PieArc = require("./PieArc");
51
+ Object.keys(_PieArc).forEach(function (key) {
52
+ if (key === "default" || key === "__esModule") return;
53
+ if (key in exports && exports[key] === _PieArc[key]) return;
54
+ Object.defineProperty(exports, key, {
55
+ enumerable: true,
56
+ get: function () {
57
+ return _PieArc[key];
58
+ }
59
+ });
53
60
  });
54
- var _PiePlot = require("./PiePlot");
55
- var _PieChart = require("./PieChart");
56
61
  var _PieArcLabel = require("./PieArcLabel");
57
- var _PieArc = require("./PieArc");
62
+ Object.keys(_PieArcLabel).forEach(function (key) {
63
+ if (key === "default" || key === "__esModule") return;
64
+ if (key in exports && exports[key] === _PieArcLabel[key]) return;
65
+ Object.defineProperty(exports, key, {
66
+ enumerable: true,
67
+ get: function () {
68
+ return _PieArcLabel[key];
69
+ }
70
+ });
71
+ });
@@ -69,11 +69,11 @@ const useChartDimensions = (inWidth, inHeight) => {
69
69
  }, [computeSize, inHeight, inWidth]);
70
70
  if (process.env.NODE_ENV !== 'production') {
71
71
  if (displayError.current && inWidth === undefined && width === 0) {
72
- console.error(`MUI: Charts does not have \`width\` prop, and its container has no \`width\` defined.`);
72
+ console.error(`MUI-X-Charts: ChartContainer does not have \`width\` prop, and its container has no \`width\` defined.`);
73
73
  displayError.current = false;
74
74
  }
75
75
  if (displayError.current && inHeight === undefined && height === 0) {
76
- console.error(`MUI: Charts does not have \`height\` prop, and its container has no \`height\` defined.`);
76
+ console.error(`MUI-X-Charts: ChartContainer does not have \`height\` prop, and its container has no \`height\` defined.`);
77
77
  displayError.current = false;
78
78
  }
79
79
  }
@@ -87,7 +87,7 @@ process.env.NODE_ENV !== "production" ? Scatter.propTypes = {
87
87
  color: _propTypes.default.string.isRequired,
88
88
  markerSize: _propTypes.default.number.isRequired,
89
89
  series: _propTypes.default.shape({
90
- color: _propTypes.default.string,
90
+ color: _propTypes.default.string.isRequired,
91
91
  data: _propTypes.default.arrayOf(_propTypes.default.shape({
92
92
  id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
93
93
  x: _propTypes.default.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';
@@ -3,24 +3,36 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "Scatter", {
7
- enumerable: true,
8
- get: function () {
9
- return _Scatter.Scatter;
10
- }
11
- });
12
- Object.defineProperty(exports, "ScatterChart", {
13
- enumerable: true,
14
- get: function () {
15
- return _ScatterChart.ScatterChart;
16
- }
17
- });
18
- Object.defineProperty(exports, "ScatterPlot", {
19
- enumerable: true,
20
- get: function () {
21
- return _ScatterPlot.ScatterPlot;
22
- }
6
+ var _ScatterChart = require("./ScatterChart");
7
+ Object.keys(_ScatterChart).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _ScatterChart[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _ScatterChart[key];
14
+ }
15
+ });
23
16
  });
24
17
  var _ScatterPlot = require("./ScatterPlot");
25
- var _ScatterChart = require("./ScatterChart");
26
- var _Scatter = require("./Scatter");
18
+ Object.keys(_ScatterPlot).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _ScatterPlot[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _ScatterPlot[key];
25
+ }
26
+ });
27
+ });
28
+ var _Scatter = require("./Scatter");
29
+ Object.keys(_Scatter).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (key in exports && exports[key] === _Scatter[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function () {
35
+ return _Scatter[key];
36
+ }
37
+ });
38
+ });
@@ -62,7 +62,7 @@ function CartesianContextProvider({
62
62
  return axisConfig;
63
63
  }
64
64
  if (dataset === undefined) {
65
- throw Error('MUI: x-axis uses `dataKey` but no `dataset` is provided.');
65
+ throw Error('MUI-X-Charts: x-axis uses `dataKey` but no `dataset` is provided.');
66
66
  }
67
67
  return (0, _extends2.default)({}, axisConfig, {
68
68
  data: dataset.map(d => d[dataKey])
@@ -74,7 +74,7 @@ function CartesianContextProvider({
74
74
  return axisConfig;
75
75
  }
76
76
  if (dataset === undefined) {
77
- throw Error('MUI: y-axis uses `dataKey` but no `dataset` is provided.');
77
+ throw Error('MUI-X-Charts: y-axis uses `dataKey` but no `dataset` is provided.');
78
78
  }
79
79
  return (0, _extends2.default)({}, axisConfig, {
80
80
  data: dataset.map(d => d[dataKey])
@@ -49,7 +49,7 @@ const formatSeries = (series, colors, dataset) => {
49
49
  };
50
50
  }
51
51
  if (seriesGroups[type]?.series[id] !== undefined) {
52
- throw new Error(`MUI: series' id "${id}" is not unique`);
52
+ throw new Error(`MUI-X-Charts: series' id "${id}" is not unique`);
53
53
  }
54
54
  seriesGroups[type].series[id] = (0, _extends2.default)({
55
55
  id
@@ -2,6 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
3
  const _excluded = ["id", "dataIndex", "classes", "color", "highlightScope", "slots", "slotProps", "style"];
4
4
  import * as React from 'react';
5
+ import PropTypes from 'prop-types';
5
6
  import composeClasses from '@mui/utils/composeClasses';
6
7
  import { useSlotProps } from '@mui/base/utils';
7
8
  import generateUtilityClass from '@mui/utils/generateUtilityClass';
@@ -39,7 +40,7 @@ export const BarElementPath = styled(animated.rect, {
39
40
  transition: 'opacity 0.2s ease-in, fill 0.2s ease-in',
40
41
  opacity: ownerState.isFaded && 0.3 || 1
41
42
  }));
42
- export function BarElement(props) {
43
+ function BarElement(props) {
43
44
  var _slots$bar;
44
45
  const {
45
46
  id,
@@ -90,4 +91,27 @@ export function BarElement(props) {
90
91
  ownerState
91
92
  });
92
93
  return /*#__PURE__*/_jsx(Bar, _extends({}, barProps));
93
- }
94
+ }
95
+ process.env.NODE_ENV !== "production" ? BarElement.propTypes = {
96
+ // ----------------------------- Warning --------------------------------
97
+ // | These PropTypes are generated from the TypeScript type definitions |
98
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
99
+ // ----------------------------------------------------------------------
100
+ classes: PropTypes.object,
101
+ dataIndex: PropTypes.number.isRequired,
102
+ highlightScope: PropTypes.shape({
103
+ faded: PropTypes.oneOf(['global', 'none', 'series']),
104
+ highlighted: PropTypes.oneOf(['item', 'none', 'series'])
105
+ }),
106
+ /**
107
+ * The props used for each component slot.
108
+ * @default {}
109
+ */
110
+ slotProps: PropTypes.object,
111
+ /**
112
+ * Overridable component slots.
113
+ * @default {}
114
+ */
115
+ slots: PropTypes.object
116
+ } : void 0;
117
+ export { BarElement };
@@ -8,7 +8,8 @@ import { SeriesContext } from '../context/SeriesContextProvider';
8
8
  import { CartesianContext } from '../context/CartesianContextProvider';
9
9
  import { BarElement } from './BarElement';
10
10
  import { isBandScaleConfig } from '../models/axis';
11
- import { jsx as _jsx } from "react/jsx-runtime";
11
+ import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from '../constants';
12
+
12
13
  /**
13
14
  * Solution of the equations
14
15
  * W = barWidth * N + offset * (N-1)
@@ -18,6 +19,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
18
19
  * @param gapRatio The ratio of the gap between bars over the bar width.
19
20
  * @returns The bar width and the offset between bars.
20
21
  */
22
+ import { jsx as _jsx } from "react/jsx-runtime";
21
23
  function getBandSize({
22
24
  bandWidth: W,
23
25
  numberOfGroups: N,
@@ -69,18 +71,18 @@ const useCompletedData = () => {
69
71
  let baseScaleConfig;
70
72
  if (verticalLayout) {
71
73
  if (!isBandScaleConfig(xAxisConfig)) {
72
- throw new Error(`Axis with id "${xAxisKey}" shoud be of type "band" to display the bar series of id "${seriesId}"`);
74
+ throw new Error(`MUI-X-Charts: ${xAxisKey === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisKey}"`} shoud be of type "band" to display the bar series of id "${seriesId}"`);
73
75
  }
74
76
  if (xAxis[xAxisKey].data === undefined) {
75
- throw new Error(`Axis with id "${xAxisKey}" shoud have data property`);
77
+ throw new Error(`MUI-X-Charts: ${xAxisKey === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisKey}"`} shoud have data property`);
76
78
  }
77
79
  baseScaleConfig = xAxisConfig;
78
80
  } else {
79
81
  if (!isBandScaleConfig(yAxisConfig)) {
80
- throw new Error(`Axis with id "${yAxisKey}" shoud be of type "band" to display the bar series of id "${seriesId}"`);
82
+ throw new Error(`MUI-X-Charts: ${yAxisKey === DEFAULT_Y_AXIS_KEY ? 'The first `yAxis`' : `The y-axis with id "${yAxisKey}"`} shoud be of type "band" to display the bar series of id "${seriesId}"`);
81
83
  }
82
84
  if (yAxis[yAxisKey].data === undefined) {
83
- throw new Error(`Axis with id "${xAxisKey}" shoud have data property`);
85
+ throw new Error(`MUI-X-Charts: ${yAxisKey === DEFAULT_Y_AXIS_KEY ? 'The first `yAxis`' : `The y-axis with id "${yAxisKey}"`} shoud have data property`);
84
86
  }
85
87
  baseScaleConfig = yAxisConfig;
86
88
  }
@@ -2,7 +2,9 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import { stack as d3Stack } from 'd3-shape';
3
3
  import { getStackingGroups } from '../internals/stackSeries';
4
4
  import defaultizeValueFormatter from '../internals/defaultizeValueFormatter';
5
+ let warnOnce = false;
5
6
  const formatter = (params, dataset) => {
7
+ var _ref;
6
8
  const {
7
9
  seriesOrder,
8
10
  series
@@ -10,7 +12,7 @@ const formatter = (params, dataset) => {
10
12
  const stackingGroups = getStackingGroups(params);
11
13
 
12
14
  // Create a data set with format adapted to d3
13
- const d3Dataset = dataset != null ? dataset : [];
15
+ const d3Dataset = (_ref = dataset) != null ? _ref : [];
14
16
  seriesOrder.forEach(id => {
15
17
  const data = series[id].data;
16
18
  if (data !== undefined) {
@@ -24,7 +26,7 @@ const formatter = (params, dataset) => {
24
26
  }
25
27
  });
26
28
  } else if (dataset === undefined) {
27
- throw new Error([`MUI: bar series with id='${id}' has no data.`, 'Either provide a data property to the series or use the dataset prop.'].join('\n'));
29
+ throw new Error([`MUI-X-Charts: bar series with id='${id}' has no data.`, 'Either provide a data property to the series or use the dataset prop.'].join('\n'));
28
30
  }
29
31
  });
30
32
  const completedSeries = {};
@@ -39,13 +41,27 @@ const formatter = (params, dataset) => {
39
41
  // Use dataKey if needed and available
40
42
  const dataKey = series[id].dataKey;
41
43
  return series[id].data === undefined && dataKey !== undefined ? dataKey : id;
42
- })).order(stackingOrder).offset(stackingOffset)(d3Dataset);
44
+ })).value((d, key) => {
45
+ var _d$key;
46
+ return (_d$key = d[key]) != null ? _d$key : 0;
47
+ }) // defaultize null value to 0
48
+ .order(stackingOrder).offset(stackingOffset)(d3Dataset);
43
49
  ids.forEach((id, index) => {
44
50
  const dataKey = series[id].dataKey;
45
51
  completedSeries[id] = _extends({
46
52
  layout: 'vertical'
47
53
  }, series[id], {
48
- data: dataKey ? dataset.map(d => d[dataKey]) : series[id].data,
54
+ data: dataKey ? dataset.map(data => {
55
+ const value = data[dataKey];
56
+ if (typeof value !== 'number') {
57
+ if (process.env.NODE_ENV !== 'production' && !warnOnce && value !== null) {
58
+ warnOnce = true;
59
+ console.error([`MUI-X charts: your dataset key "${dataKey}" is used for plotting bars, but contains nonnumerical elements.`, 'Bar plots only support numbers and null values.']);
60
+ }
61
+ return 0;
62
+ }
63
+ return value;
64
+ }) : series[id].data,
49
65
  stackedData: stackedSeries[index].map(([a, b]) => [a, b])
50
66
  });
51
67
  });
@@ -1,2 +1,3 @@
1
- export { BarPlot } from './BarPlot';
2
- export { BarChart } from './BarChart';
1
+ export * from './BarChart';
2
+ export * from './BarPlot';
3
+ export * from './BarElement';
@@ -59,16 +59,16 @@ function ChartsAxis(props) {
59
59
  const topId = getAxisId(topAxis);
60
60
  const rightId = getAxisId(rightAxis);
61
61
  if (topId !== null && !xAxis[topId]) {
62
- throw Error(`MUI: id used for top axis "${topId}" is not defined`);
62
+ throw Error([`MUI-X-Charts: id used for top axis "${topId}" is not defined.`, `Available ids are: ${xAxisIds.join(', ')}.`].join('\n'));
63
63
  }
64
64
  if (leftId !== null && !yAxis[leftId]) {
65
- throw Error(`MUI: id used for left axis "${leftId}" is not defined`);
65
+ throw Error([`MUI-X-Charts: id used for left axis "${leftId}" is not defined.`, `Available ids are: ${yAxisIds.join(', ')}.`].join('\n'));
66
66
  }
67
67
  if (rightId !== null && !yAxis[rightId]) {
68
- throw Error(`MUI: id used for right axis "${rightId}" is not defined`);
68
+ throw Error([`MUI-X-Charts: id used for right axis "${rightId}" is not defined.`, `Available ids are: ${yAxisIds.join(', ')}.`].join('\n'));
69
69
  }
70
70
  if (bottomId !== null && !xAxis[bottomId]) {
71
- throw Error(`MUI: id used for bottom axis "${bottomId}" is not defined`);
71
+ throw Error([`MUI-X-Charts: id used for bottom axis "${bottomId}" is not defined.`, `Available ids are: ${xAxisIds.join(', ')}.`].join('\n'));
72
72
  }
73
73
  const topAxisProps = mergeProps(topAxis, slots, slotProps);
74
74
  const bottomAxisProps = mergeProps(bottomAxis, slots, slotProps);
@@ -11,7 +11,8 @@ import { DrawingContext } from '../context/DrawingProvider';
11
11
  import { getSeriesToDisplay } from './utils';
12
12
  import { SeriesContext } from '../context/SeriesContextProvider';
13
13
  import { getLegendUtilityClass } from './chartsLegendClasses';
14
- import { ChartsText, getWordsByLines } from '../internals/components/ChartsText';
14
+ import { ChartsText } from '../ChartsText';
15
+ import { getWordsByLines } from '../internals/getWordsByLines';
15
16
  import { jsx as _jsx } from "react/jsx-runtime";
16
17
  import { jsxs as _jsxs } from "react/jsx-runtime";
17
18
  const useUtilityClasses = ownerState => {