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

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 (121) hide show
  1. package/BarChart/BarPlot.js +7 -6
  2. package/BarChart/formatter.js +15 -3
  3. package/CHANGELOG.md +342 -0
  4. package/ChartsAxis/ChartsAxis.js +4 -4
  5. package/ChartsLegend/ChartsLegend.d.ts +1 -1
  6. package/ChartsLegend/ChartsLegend.js +3 -2
  7. package/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  8. package/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
  9. package/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
  10. package/ChartsReferenceLine/common.d.ts +1 -1
  11. package/ChartsText/ChartsText.d.ts +17 -0
  12. package/{internals/components → ChartsText}/ChartsText.js +32 -17
  13. package/ChartsText/index.d.ts +3 -0
  14. package/ChartsText/index.js +12 -0
  15. package/ChartsText/package.json +6 -0
  16. package/ChartsXAxis/ChartsXAxis.js +3 -2
  17. package/ChartsYAxis/ChartsYAxis.js +1 -1
  18. package/LineChart/AreaPlot.js +3 -2
  19. package/LineChart/LineHighlightPlot.js +2 -1
  20. package/LineChart/LinePlot.js +3 -2
  21. package/LineChart/MarkPlot.js +2 -1
  22. package/LineChart/formatter.js +14 -2
  23. package/PieChart/PieArcLabelPlot.d.ts +2 -3
  24. package/PieChart/PieArcLabelPlot.js +0 -1
  25. package/PieChart/PieArcPlot.d.ts +2 -3
  26. package/PieChart/PieArcPlot.js +0 -1
  27. package/PieChart/PieChart.js +4 -4
  28. package/PieChart/PiePlot.js +20 -15
  29. package/PieChart/dataTransform/useTransformData.d.ts +2 -3
  30. package/ResponsiveChartContainer/index.js +2 -2
  31. package/context/CartesianContextProvider.js +2 -2
  32. package/context/SeriesContextProvider.js +1 -1
  33. package/esm/BarChart/BarPlot.js +7 -5
  34. package/esm/BarChart/formatter.js +20 -4
  35. package/esm/ChartsAxis/ChartsAxis.js +4 -4
  36. package/esm/ChartsLegend/ChartsLegend.js +2 -1
  37. package/esm/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  38. package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
  39. package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
  40. package/esm/{internals/components → ChartsText}/ChartsText.js +33 -16
  41. package/esm/ChartsText/index.js +1 -0
  42. package/esm/ChartsXAxis/ChartsXAxis.js +2 -1
  43. package/esm/ChartsYAxis/ChartsYAxis.js +1 -1
  44. package/esm/LineChart/AreaPlot.js +3 -2
  45. package/esm/LineChart/LineHighlightPlot.js +2 -1
  46. package/esm/LineChart/LinePlot.js +3 -2
  47. package/esm/LineChart/MarkPlot.js +2 -1
  48. package/esm/LineChart/formatter.js +16 -3
  49. package/esm/PieChart/PieArcLabelPlot.js +0 -1
  50. package/esm/PieChart/PieArcPlot.js +0 -1
  51. package/esm/PieChart/PieChart.js +4 -4
  52. package/esm/PieChart/PiePlot.js +20 -15
  53. package/esm/ResponsiveChartContainer/index.js +2 -2
  54. package/esm/context/CartesianContextProvider.js +2 -2
  55. package/esm/context/SeriesContextProvider.js +1 -1
  56. package/esm/index.js +1 -0
  57. package/esm/internals/getWordsByLines.js +14 -0
  58. package/esm/internals/utils.js +29 -0
  59. package/index.d.ts +1 -0
  60. package/index.js +12 -1
  61. package/internals/defaultizeColor.d.ts +4 -4
  62. package/internals/{components/ChartsText.d.ts → getWordsByLines.d.ts} +2 -11
  63. package/internals/getWordsByLines.js +21 -0
  64. package/internals/utils.d.ts +7 -0
  65. package/internals/utils.js +30 -0
  66. package/legacy/BarChart/BarPlot.js +7 -5
  67. package/legacy/BarChart/formatter.js +23 -9
  68. package/legacy/ChartsAxis/ChartsAxis.js +4 -4
  69. package/legacy/ChartsLegend/ChartsLegend.js +2 -1
  70. package/legacy/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  71. package/legacy/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
  72. package/legacy/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
  73. package/legacy/{internals/components → ChartsText}/ChartsText.js +38 -22
  74. package/legacy/ChartsText/index.js +1 -0
  75. package/legacy/ChartsXAxis/ChartsXAxis.js +2 -1
  76. package/legacy/ChartsYAxis/ChartsYAxis.js +1 -1
  77. package/legacy/LineChart/AreaPlot.js +3 -2
  78. package/legacy/LineChart/LineHighlightPlot.js +2 -1
  79. package/legacy/LineChart/LinePlot.js +3 -2
  80. package/legacy/LineChart/MarkPlot.js +2 -1
  81. package/legacy/LineChart/formatter.js +19 -8
  82. package/legacy/PieChart/PieArcLabelPlot.js +0 -1
  83. package/legacy/PieChart/PieArcPlot.js +0 -1
  84. package/legacy/PieChart/PieChart.js +4 -4
  85. package/legacy/PieChart/PiePlot.js +20 -15
  86. package/legacy/ResponsiveChartContainer/index.js +2 -2
  87. package/legacy/context/CartesianContextProvider.js +2 -2
  88. package/legacy/context/SeriesContextProvider.js +1 -1
  89. package/legacy/index.js +2 -1
  90. package/legacy/internals/getWordsByLines.js +15 -0
  91. package/legacy/internals/utils.js +29 -0
  92. package/models/axis.d.ts +1 -1
  93. package/models/seriesType/config.d.ts +4 -3
  94. package/models/seriesType/pie.d.ts +29 -7
  95. package/modern/BarChart/BarPlot.js +7 -5
  96. package/modern/BarChart/formatter.js +15 -3
  97. package/modern/ChartsAxis/ChartsAxis.js +4 -4
  98. package/modern/ChartsLegend/ChartsLegend.js +2 -1
  99. package/modern/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  100. package/modern/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
  101. package/modern/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
  102. package/modern/{internals/components → ChartsText}/ChartsText.js +33 -16
  103. package/modern/ChartsText/index.js +1 -0
  104. package/modern/ChartsXAxis/ChartsXAxis.js +2 -1
  105. package/modern/ChartsYAxis/ChartsYAxis.js +1 -1
  106. package/modern/LineChart/AreaPlot.js +3 -2
  107. package/modern/LineChart/LineHighlightPlot.js +2 -1
  108. package/modern/LineChart/LinePlot.js +3 -2
  109. package/modern/LineChart/MarkPlot.js +2 -1
  110. package/modern/LineChart/formatter.js +14 -2
  111. package/modern/PieChart/PieArcLabelPlot.js +0 -1
  112. package/modern/PieChart/PieArcPlot.js +0 -1
  113. package/modern/PieChart/PieChart.js +4 -4
  114. package/modern/PieChart/PiePlot.js +20 -15
  115. package/modern/ResponsiveChartContainer/index.js +2 -2
  116. package/modern/context/CartesianContextProvider.js +2 -2
  117. package/modern/context/SeriesContextProvider.js +1 -1
  118. package/modern/index.js +2 -1
  119. package/modern/internals/getWordsByLines.js +14 -0
  120. package/modern/internals/utils.js +29 -0
  121. package/package.json +4 -4
@@ -17,9 +17,10 @@ var _DrawingProvider = require("../context/DrawingProvider");
17
17
  var _useTicks = _interopRequireDefault(require("../hooks/useTicks"));
18
18
  var _axisClasses = require("../ChartsAxis/axisClasses");
19
19
  var _AxisSharedComponents = require("../internals/components/AxisSharedComponents");
20
- var _ChartsText = require("../internals/components/ChartsText");
20
+ var _ChartsText = require("../ChartsText");
21
21
  var _geometry = require("../internals/geometry");
22
22
  var _useMounted = require("../hooks/useMounted");
23
+ var _getWordsByLines = require("../internals/getWordsByLines");
23
24
  var _jsxRuntime = require("react/jsx-runtime");
24
25
  const _excluded = ["scale", "tickNumber"];
25
26
  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); }
@@ -51,7 +52,7 @@ function addLabelDimension(xTicks, {
51
52
  height: 0
52
53
  });
53
54
  }
54
- const tickSizes = (0, _ChartsText.getWordsByLines)({
55
+ const tickSizes = (0, _getWordsByLines.getWordsByLines)({
55
56
  style,
56
57
  needsComputation: true,
57
58
  text: tick.formattedValue
@@ -16,7 +16,7 @@ var _CartesianContextProvider = require("../context/CartesianContextProvider");
16
16
  var _DrawingProvider = require("../context/DrawingProvider");
17
17
  var _useTicks = _interopRequireDefault(require("../hooks/useTicks"));
18
18
  var _AxisSharedComponents = require("../internals/components/AxisSharedComponents");
19
- var _ChartsText = require("../internals/components/ChartsText");
19
+ var _ChartsText = require("../ChartsText");
20
20
  var _axisClasses = require("../ChartsAxis/axisClasses");
21
21
  var _jsxRuntime = require("react/jsx-runtime");
22
22
  const _excluded = ["scale", "tickNumber"];
@@ -15,6 +15,7 @@ var _CartesianContextProvider = require("../context/CartesianContextProvider");
15
15
  var _AreaElement = require("./AreaElement");
16
16
  var _useScale = require("../hooks/useScale");
17
17
  var _getCurve = _interopRequireDefault(require("../internals/getCurve"));
18
+ var _constants = require("../constants");
18
19
  var _jsxRuntime = require("react/jsx-runtime");
19
20
  const _excluded = ["slots", "slotProps"];
20
21
  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); }
@@ -70,10 +71,10 @@ function AreaPlot(props) {
70
71
  const xData = xAxis[xAxisKey].data;
71
72
  if (process.env.NODE_ENV !== 'production') {
72
73
  if (xData === undefined) {
73
- throw new Error(`Axis of id "${xAxisKey}" should have data property to be able to display a line plot.`);
74
+ throw new Error(`MUI-X-Charts: ${xAxisKey === _constants.DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisKey}"`} should have data property to be able to display a line plot.`);
74
75
  }
75
76
  if (xData.length < stackedData.length) {
76
- throw new Error(`MUI: data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items)`);
77
+ throw new Error(`MUI-X-Charts: The data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items)`);
77
78
  }
78
79
  }
79
80
  const areaPath = (0, _d3Shape.area)().x(d => xScale(d.x)).defined((_, i) => connectNulls || data[i] != null).y0(d => d.y && yScale(d.y[0])).y1(d => d.y && yScale(d.y[1]));
@@ -14,6 +14,7 @@ var _CartesianContextProvider = require("../context/CartesianContextProvider");
14
14
  var _LineHighlightElement = require("./LineHighlightElement");
15
15
  var _useScale = require("../hooks/useScale");
16
16
  var _InteractionProvider = require("../context/InteractionProvider");
17
+ var _constants = require("../constants");
17
18
  var _jsxRuntime = require("react/jsx-runtime");
18
19
  const _excluded = ["slots", "slotProps"];
19
20
  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); }
@@ -78,7 +79,7 @@ function LineHighlightPlot(props) {
78
79
  const yScale = yAxis[yAxisKey].scale;
79
80
  const xData = xAxis[xAxisKey].data;
80
81
  if (xData === undefined) {
81
- throw new Error(`Axis of id "${xAxisKey}" should have data property to be able to display a line plot.`);
82
+ throw new Error(`MUI-X-Charts: ${xAxisKey === _constants.DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisKey}"`} should have data property to be able to display a line plot.`);
82
83
  }
83
84
  const x = xScale(xData[highlightedIndex]);
84
85
  const y = yScale(stackedData[highlightedIndex][1]); // This should not be undefined since y should not be a band scale
@@ -15,6 +15,7 @@ var _CartesianContextProvider = require("../context/CartesianContextProvider");
15
15
  var _LineElement = require("./LineElement");
16
16
  var _useScale = require("../hooks/useScale");
17
17
  var _getCurve = _interopRequireDefault(require("../internals/getCurve"));
18
+ var _constants = require("../constants");
18
19
  var _jsxRuntime = require("react/jsx-runtime");
19
20
  const _excluded = ["slots", "slotProps"];
20
21
  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); }
@@ -69,10 +70,10 @@ function LinePlot(props) {
69
70
  const xData = xAxis[xAxisKey].data;
70
71
  if (process.env.NODE_ENV !== 'production') {
71
72
  if (xData === undefined) {
72
- throw new Error(`Axis of id "${xAxisKey}" should have data property to be able to display a line plot`);
73
+ throw new Error(`MUI-X-Charts: ${xAxisKey === _constants.DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisKey}"`} should have data property to be able to display a line plot`);
73
74
  }
74
75
  if (xData.length < stackedData.length) {
75
- throw new Error(`MUI: data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items)`);
76
+ throw new Error(`MUI-X-Charts: The data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items)`);
76
77
  }
77
78
  }
78
79
  const linePath = (0, _d3Shape.line)().x(d => xScale(d.x)).defined((_, i) => connectNulls || data[i] != null).y(d => yScale(d.y[1]));
@@ -13,6 +13,7 @@ var _SeriesContextProvider = require("../context/SeriesContextProvider");
13
13
  var _CartesianContextProvider = require("../context/CartesianContextProvider");
14
14
  var _MarkElement = require("./MarkElement");
15
15
  var _useScale = require("../hooks/useScale");
16
+ var _constants = require("../constants");
16
17
  var _jsxRuntime = require("react/jsx-runtime");
17
18
  const _excluded = ["slots", "slotProps"];
18
19
  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); }
@@ -84,7 +85,7 @@ function MarkPlot(props) {
84
85
  return true;
85
86
  };
86
87
  if (xData === undefined) {
87
- throw new Error(`Axis of id "${xAxisKey}" should have data property to be able to display a line plot`);
88
+ throw new Error(`MUI-X-Charts: ${xAxisKey === _constants.DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisKey}"`} should have data property to be able to display a line plot`);
88
89
  }
89
90
  return xData?.map((x, index) => {
90
91
  const value = data[index] == null ? null : stackedData[index][1];
@@ -9,6 +9,8 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
9
9
  var _d3Shape = require("d3-shape");
10
10
  var _stackSeries = require("../internals/stackSeries");
11
11
  var _defaultizeValueFormatter = _interopRequireDefault(require("../internals/defaultizeValueFormatter"));
12
+ let warnedOnce = false;
13
+
12
14
  // For now it's a copy past of bar charts formatter, but maybe will diverge later
13
15
  const formatter = (params, dataset) => {
14
16
  const {
@@ -32,7 +34,7 @@ const formatter = (params, dataset) => {
32
34
  }
33
35
  });
34
36
  } else if (dataset === undefined && process.env.NODE_ENV !== 'production') {
35
- throw new Error([`MUI: line series with id='${id}' has no data.`, 'Either provide a data property to the series or use the dataset prop.'].join('\n'));
37
+ throw new Error([`MUI-X-Charts: line series with id='${id}' has no data.`, 'Either provide a data property to the series or use the dataset prop.'].join('\n'));
36
38
  }
37
39
  });
38
40
  const completedSeries = {};
@@ -52,7 +54,17 @@ const formatter = (params, dataset) => {
52
54
  ids.forEach((id, index) => {
53
55
  const dataKey = series[id].dataKey;
54
56
  completedSeries[id] = (0, _extends2.default)({}, series[id], {
55
- data: dataKey ? dataset.map(d => d[dataKey]) : series[id].data,
57
+ data: dataKey ? dataset.map(data => {
58
+ const value = data[dataKey];
59
+ if (typeof value !== 'number') {
60
+ if (process.env.NODE_ENV !== 'production' && !warnedOnce && value !== null) {
61
+ warnedOnce = true;
62
+ console.error([`MUI-X charts: your dataset key "${dataKey}" is used for plotting line, but contains nonnumerical elements.`, 'Line plots only support numbers and null values.']);
63
+ }
64
+ return 0;
65
+ }
66
+ return value;
67
+ }) : series[id].data,
56
68
  stackedData: stackedSeries[index].map(([a, b]) => [a, b])
57
69
  });
58
70
  });
@@ -1,14 +1,13 @@
1
1
  import * as React from 'react';
2
- import { DefaultizedPieSeriesType } from '../models/seriesType/pie';
2
+ import { ComputedPieRadius, DefaultizedPieSeriesType } from '../models/seriesType/pie';
3
3
  import { PieArcLabelProps } from './PieArcLabel';
4
- import { DefaultizedProps } from '../models/helpers';
5
4
  export interface PieArcLabelPlotSlots {
6
5
  pieArcLabel?: React.JSXElementConstructor<PieArcLabelProps>;
7
6
  }
8
7
  export interface PieArcLabelPlotSlotProps {
9
8
  pieArcLabel?: Partial<PieArcLabelProps>;
10
9
  }
11
- export interface PieArcLabelPlotProps extends DefaultizedProps<Pick<DefaultizedPieSeriesType, 'data' | 'faded' | 'highlighted' | 'innerRadius' | 'outerRadius' | 'cornerRadius' | 'paddingAngle' | 'arcLabel' | 'arcLabelMinAngle' | 'id' | 'highlightScope'>, 'outerRadius'> {
10
+ export interface PieArcLabelPlotProps extends Pick<DefaultizedPieSeriesType, 'data' | 'faded' | 'highlighted' | 'cornerRadius' | 'paddingAngle' | 'arcLabel' | 'arcLabelMinAngle' | 'id' | 'highlightScope'>, ComputedPieRadius {
12
11
  /**
13
12
  * Overridable component slots.
14
13
  * @default {}
@@ -161,7 +161,6 @@ process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
161
161
  innerRadius: _propTypes.default.number,
162
162
  /**
163
163
  * The radius between circle center and the end of the arc.
164
- * @default R_max The maximal radius that fit into the drawing area.
165
164
  */
166
165
  outerRadius: _propTypes.default.number.isRequired,
167
166
  /**
@@ -1,14 +1,13 @@
1
1
  import * as React from 'react';
2
2
  import { PieArcProps } from './PieArc';
3
- import { DefaultizedPieSeriesType, DefaultizedPieValueType, PieItemIdentifier } from '../models/seriesType/pie';
4
- import { DefaultizedProps } from '../models/helpers';
3
+ import { ComputedPieRadius, DefaultizedPieSeriesType, DefaultizedPieValueType, PieItemIdentifier } from '../models/seriesType/pie';
5
4
  export interface PieArcPlotSlots {
6
5
  pieArc?: React.JSXElementConstructor<PieArcProps>;
7
6
  }
8
7
  export interface PieArcPlotSlotProps {
9
8
  pieArc?: Partial<PieArcProps>;
10
9
  }
11
- export interface PieArcPlotProps extends DefaultizedProps<Pick<DefaultizedPieSeriesType, 'data' | 'faded' | 'highlighted' | 'innerRadius' | 'outerRadius' | 'cornerRadius' | 'paddingAngle' | 'id' | 'highlightScope'>, 'outerRadius'> {
10
+ export interface PieArcPlotProps extends Pick<DefaultizedPieSeriesType, 'data' | 'faded' | 'highlighted' | 'cornerRadius' | 'paddingAngle' | 'id' | 'highlightScope'>, ComputedPieRadius {
12
11
  /**
13
12
  * Overridable component slots.
14
13
  * @default {}
@@ -153,7 +153,6 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
153
153
  onClick: _propTypes.default.func,
154
154
  /**
155
155
  * The radius between circle center and the end of the arc.
156
- * @default R_max The maximal radius that fit into the drawing area.
157
156
  */
158
157
  outerRadius: _propTypes.default.number.isRequired,
159
158
  /**
@@ -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[];
@@ -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
  }
@@ -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
@@ -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
  });
@@ -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);
@@ -12,7 +12,8 @@ import { DrawingContext } from '../context/DrawingProvider';
12
12
  import { getSeriesToDisplay } from './utils';
13
13
  import { SeriesContext } from '../context/SeriesContextProvider';
14
14
  import { getLegendUtilityClass } from './chartsLegendClasses';
15
- import { ChartsText, getWordsByLines } from '../internals/components/ChartsText';
15
+ import { ChartsText } from '../ChartsText';
16
+ import { getWordsByLines } from '../internals/getWordsByLines';
16
17
  import { jsx as _jsx } from "react/jsx-runtime";
17
18
  import { jsxs as _jsxs } from "react/jsx-runtime";
18
19
  const useUtilityClasses = ownerState => {
@@ -6,10 +6,10 @@ import { ChartsYReferenceLine } from './ChartsYReferenceLine';
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
7
7
  function ChartsReferenceLine(props) {
8
8
  if (props.x !== undefined && props.y !== undefined) {
9
- throw new Error('MUI-X: The ChartsReferenceLine can not have both `x` and `y` props set.');
9
+ throw new Error('MUI-X-Charts: The ChartsReferenceLine can not have both `x` and `y` props set.');
10
10
  }
11
11
  if (props.x === undefined && props.y === undefined) {
12
- throw new Error('MUI-X: The ChartsReferenceLine should have a value in `x` or `y` prop.');
12
+ throw new Error('MUI-X-Charts: The ChartsReferenceLine should have a value in `x` or `y` prop.');
13
13
  }
14
14
  if (props.x !== undefined) {
15
15
  return /*#__PURE__*/_jsx(ChartsXReferenceLine, _extends({}, props));
@@ -3,7 +3,7 @@ import * as React from 'react';
3
3
  import composeClasses from '@mui/utils/composeClasses';
4
4
  import { useDrawingArea, useXScale } from '../hooks';
5
5
  import { ReferenceLineRoot } from './common';
6
- import { ChartsText } from '../internals/components/ChartsText';
6
+ import { ChartsText } from '../ChartsText';
7
7
  import { getReferenceLineUtilityClass } from './chartsReferenceLineClasses';
8
8
  import { jsx as _jsx } from "react/jsx-runtime";
9
9
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -3,7 +3,7 @@ import * as React from 'react';
3
3
  import composeClasses from '@mui/utils/composeClasses';
4
4
  import { useDrawingArea, useYScale } from '../hooks';
5
5
  import { ReferenceLineRoot } from './common';
6
- import { ChartsText } from '../internals/components/ChartsText';
6
+ import { ChartsText } from '../ChartsText';
7
7
  import { getReferenceLineUtilityClass } from './chartsReferenceLineClasses';
8
8
  import { jsx as _jsx } from "react/jsx-runtime";
9
9
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -1,23 +1,15 @@
1
- import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
3
  const _excluded = ["x", "y", "style", "text", "ownerState"],
4
4
  _excluded2 = ["angle", "textAnchor", "dominantBaseline"];
5
5
  import * as React from 'react';
6
- import { getStringSize } from '../domUtils';
6
+ import PropTypes from 'prop-types';
7
+ import { getWordsByLines } from '../internals/getWordsByLines';
7
8
  import { jsx as _jsx } from "react/jsx-runtime";
8
- export function getWordsByLines({
9
- style,
10
- needsComputation,
11
- text
12
- }) {
13
- return text.split('\n').map(subText => _extends({
14
- text: subText
15
- }, needsComputation ? getStringSize(subText, style) : {
16
- width: 0,
17
- height: 0
18
- }));
19
- }
20
- export function ChartsText(props) {
9
+ /**
10
+ * Helper component to manage multiline text in SVG
11
+ */
12
+ function ChartsText(props) {
21
13
  const {
22
14
  x,
23
15
  y,
@@ -74,4 +66,29 @@ export function ChartsText(props) {
74
66
  children: line.text
75
67
  }, index))
76
68
  }));
77
- }
69
+ }
70
+ process.env.NODE_ENV !== "production" ? ChartsText.propTypes = {
71
+ // ----------------------------- Warning --------------------------------
72
+ // | These PropTypes are generated from the TypeScript type definitions |
73
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
74
+ // ----------------------------------------------------------------------
75
+ /**
76
+ * Height of a text line (in `em`).
77
+ */
78
+ lineHeight: PropTypes.number,
79
+ /**
80
+ * If `true`, the line width is computed.
81
+ * @default false
82
+ */
83
+ needsComputation: PropTypes.bool,
84
+ ownerState: PropTypes.any,
85
+ /**
86
+ * Style applied to text elements.
87
+ */
88
+ style: PropTypes.object,
89
+ /**
90
+ * Text displayed.
91
+ */
92
+ text: PropTypes.string.isRequired
93
+ } : void 0;
94
+ export { ChartsText };
@@ -0,0 +1 @@
1
+ export { ChartsText } from './ChartsText';
@@ -11,9 +11,10 @@ import { DrawingContext } from '../context/DrawingProvider';
11
11
  import useTicks from '../hooks/useTicks';
12
12
  import { getAxisUtilityClass } from '../ChartsAxis/axisClasses';
13
13
  import { AxisRoot } from '../internals/components/AxisSharedComponents';
14
- import { ChartsText, getWordsByLines } from '../internals/components/ChartsText';
14
+ import { ChartsText } from '../ChartsText';
15
15
  import { getMinXTranslation } from '../internals/geometry';
16
16
  import { useMounted } from '../hooks/useMounted';
17
+ import { getWordsByLines } from '../internals/getWordsByLines';
17
18
  import { jsx as _jsx } from "react/jsx-runtime";
18
19
  import { jsxs as _jsxs } from "react/jsx-runtime";
19
20
  const useUtilityClasses = ownerState => {
@@ -10,7 +10,7 @@ import { CartesianContext } from '../context/CartesianContextProvider';
10
10
  import { DrawingContext } from '../context/DrawingProvider';
11
11
  import useTicks from '../hooks/useTicks';
12
12
  import { AxisRoot } from '../internals/components/AxisSharedComponents';
13
- import { ChartsText } from '../internals/components/ChartsText';
13
+ import { ChartsText } from '../ChartsText';
14
14
  import { getAxisUtilityClass } from '../ChartsAxis/axisClasses';
15
15
  import { jsx as _jsx } from "react/jsx-runtime";
16
16
  import { jsxs as _jsxs } from "react/jsx-runtime";