@mui/x-charts 6.18.3 → 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 (121) hide show
  1. package/BarChart/BarPlot.js +7 -6
  2. package/BarChart/formatter.js +15 -3
  3. package/CHANGELOG.md +133 -1
  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 +40 -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 +13 -0
  65. package/internals/utils.js +42 -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 +40 -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 +40 -0
  121. package/package.json +1 -1
@@ -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 PieArcPlotSlotsComponent {
6
5
  pieArc?: React.JSXElementConstructor<PieArcProps>;
7
6
  }
8
7
  export interface PieArcPlotSlotComponentProps {
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);
@@ -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 => {
@@ -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";
@@ -9,6 +9,7 @@ import { CartesianContext } from '../context/CartesianContextProvider';
9
9
  import { AreaElement } from './AreaElement';
10
10
  import { getValueToPositionMapper } from '../hooks/useScale';
11
11
  import getCurveFactory from '../internals/getCurve';
12
+ import { DEFAULT_X_AXIS_KEY } from '../constants';
12
13
  import { jsx as _jsx } from "react/jsx-runtime";
13
14
  /**
14
15
  * Demos:
@@ -62,10 +63,10 @@ function AreaPlot(props) {
62
63
  const xData = xAxis[xAxisKey].data;
63
64
  if (process.env.NODE_ENV !== 'production') {
64
65
  if (xData === undefined) {
65
- throw new Error(`Axis of id "${xAxisKey}" should have data property to be able to display a line plot.`);
66
+ throw new Error(`MUI-X-Charts: ${xAxisKey === 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.`);
66
67
  }
67
68
  if (xData.length < stackedData.length) {
68
- throw new Error(`MUI: data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items)`);
69
+ 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)`);
69
70
  }
70
71
  }
71
72
  const areaPath = d3Area().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]));
@@ -8,6 +8,7 @@ import { CartesianContext } from '../context/CartesianContextProvider';
8
8
  import { LineHighlightElement } from './LineHighlightElement';
9
9
  import { getValueToPositionMapper } from '../hooks/useScale';
10
10
  import { InteractionContext } from '../context/InteractionProvider';
11
+ import { DEFAULT_X_AXIS_KEY } from '../constants';
11
12
  import { jsx as _jsx } from "react/jsx-runtime";
12
13
  /**
13
14
  * Demos:
@@ -70,7 +71,7 @@ function LineHighlightPlot(props) {
70
71
  const yScale = yAxis[yAxisKey].scale;
71
72
  const xData = xAxis[xAxisKey].data;
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 === 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
  const x = xScale(xData[highlightedIndex]);
76
77
  const y = yScale(stackedData[highlightedIndex][1]); // This should not be undefined since y should not be a band scale
@@ -9,6 +9,7 @@ import { CartesianContext } from '../context/CartesianContextProvider';
9
9
  import { LineElement } from './LineElement';
10
10
  import { getValueToPositionMapper } from '../hooks/useScale';
11
11
  import getCurveFactory from '../internals/getCurve';
12
+ import { DEFAULT_X_AXIS_KEY } from '../constants';
12
13
  import { jsx as _jsx } from "react/jsx-runtime";
13
14
  /**
14
15
  * Demos:
@@ -61,10 +62,10 @@ function LinePlot(props) {
61
62
  const xData = xAxis[xAxisKey].data;
62
63
  if (process.env.NODE_ENV !== 'production') {
63
64
  if (xData === undefined) {
64
- throw new Error(`Axis of id "${xAxisKey}" should have data property to be able to display a line plot`);
65
+ throw new Error(`MUI-X-Charts: ${xAxisKey === 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`);
65
66
  }
66
67
  if (xData.length < stackedData.length) {
67
- throw new Error(`MUI: data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items)`);
68
+ 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)`);
68
69
  }
69
70
  }
70
71
  const linePath = d3Line().x(d => xScale(d.x)).defined((_, i) => connectNulls || data[i] != null).y(d => yScale(d.y[1]));
@@ -7,6 +7,7 @@ import { SeriesContext } from '../context/SeriesContextProvider';
7
7
  import { CartesianContext } from '../context/CartesianContextProvider';
8
8
  import { MarkElement } from './MarkElement';
9
9
  import { getValueToPositionMapper } from '../hooks/useScale';
10
+ import { DEFAULT_X_AXIS_KEY } from '../constants';
10
11
  import { jsx as _jsx } from "react/jsx-runtime";
11
12
  /**
12
13
  * Demos:
@@ -76,7 +77,7 @@ function MarkPlot(props) {
76
77
  return true;
77
78
  };
78
79
  if (xData === undefined) {
79
- throw new Error(`Axis of id "${xAxisKey}" should have data property to be able to display a line plot`);
80
+ throw new Error(`MUI-X-Charts: ${xAxisKey === 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`);
80
81
  }
81
82
  return xData == null ? void 0 : xData.map((x, index) => {
82
83
  const value = data[index] == null ? null : stackedData[index][1];
@@ -2,8 +2,11 @@ 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 warnedOnce = false;
6
+
5
7
  // For now it's a copy past of bar charts formatter, but maybe will diverge later
6
8
  const formatter = (params, dataset) => {
9
+ var _ref;
7
10
  const {
8
11
  seriesOrder,
9
12
  series
@@ -11,7 +14,7 @@ const formatter = (params, dataset) => {
11
14
  const stackingGroups = getStackingGroups(params);
12
15
 
13
16
  // Create a data set with format adapted to d3
14
- const d3Dataset = dataset != null ? dataset : [];
17
+ const d3Dataset = (_ref = dataset) != null ? _ref : [];
15
18
  seriesOrder.forEach(id => {
16
19
  const data = series[id].data;
17
20
  if (data !== undefined) {
@@ -25,7 +28,7 @@ const formatter = (params, dataset) => {
25
28
  }
26
29
  });
27
30
  } else if (dataset === undefined && process.env.NODE_ENV !== 'production') {
28
- 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'));
31
+ 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'));
29
32
  }
30
33
  });
31
34
  const completedSeries = {};
@@ -48,7 +51,17 @@ const formatter = (params, dataset) => {
48
51
  ids.forEach((id, index) => {
49
52
  const dataKey = series[id].dataKey;
50
53
  completedSeries[id] = _extends({}, series[id], {
51
- 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' && !warnedOnce && value !== null) {
58
+ warnedOnce = true;
59
+ 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.']);
60
+ }
61
+ return 0;
62
+ }
63
+ return value;
64
+ }) : series[id].data,
52
65
  stackedData: stackedSeries[index].map(([a, b]) => [a, b])
53
66
  });
54
67
  });
@@ -154,7 +154,6 @@ process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
154
154
  innerRadius: PropTypes.number,
155
155
  /**
156
156
  * The radius between circle center and the end of the arc.
157
- * @default R_max The maximal radius that fit into the drawing area.
158
157
  */
159
158
  outerRadius: PropTypes.number.isRequired,
160
159
  /**
@@ -145,7 +145,6 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
145
145
  onClick: PropTypes.func,
146
146
  /**
147
147
  * The radius between circle center and the end of the arc.
148
- * @default R_max The maximal radius that fit into the drawing area.
149
148
  */
150
149
  outerRadius: PropTypes.number.isRequired,
151
150
  /**
@@ -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,