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

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 (134) hide show
  1. package/BarChart/BarPlot.js +7 -6
  2. package/BarChart/formatter.js +15 -3
  3. package/CHANGELOG.md +524 -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/PieArcLabel.d.ts +1 -0
  24. package/PieChart/PieArcLabel.js +7 -8
  25. package/PieChart/PieArcLabelPlot.d.ts +2 -3
  26. package/PieChart/PieArcLabelPlot.js +14 -4
  27. package/PieChart/PieArcPlot.d.ts +2 -3
  28. package/PieChart/PieArcPlot.js +8 -2
  29. package/PieChart/PieChart.js +7 -4
  30. package/PieChart/PiePlot.js +23 -15
  31. package/PieChart/dataTransform/transition.js +9 -2
  32. package/PieChart/dataTransform/useTransformData.d.ts +3 -3
  33. package/PieChart/dataTransform/useTransformData.js +11 -8
  34. package/ResponsiveChartContainer/index.js +2 -2
  35. package/context/CartesianContextProvider.js +2 -2
  36. package/context/SeriesContextProvider.js +1 -1
  37. package/esm/BarChart/BarPlot.js +7 -5
  38. package/esm/BarChart/formatter.js +20 -4
  39. package/esm/ChartsAxis/ChartsAxis.js +4 -4
  40. package/esm/ChartsLegend/ChartsLegend.js +2 -1
  41. package/esm/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  42. package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
  43. package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
  44. package/esm/{internals/components → ChartsText}/ChartsText.js +33 -16
  45. package/esm/ChartsText/index.js +1 -0
  46. package/esm/ChartsXAxis/ChartsXAxis.js +2 -1
  47. package/esm/ChartsYAxis/ChartsYAxis.js +1 -1
  48. package/esm/LineChart/AreaPlot.js +3 -2
  49. package/esm/LineChart/LineHighlightPlot.js +2 -1
  50. package/esm/LineChart/LinePlot.js +3 -2
  51. package/esm/LineChart/MarkPlot.js +2 -1
  52. package/esm/LineChart/formatter.js +16 -3
  53. package/esm/PieChart/PieArcLabel.js +7 -8
  54. package/esm/PieChart/PieArcLabelPlot.js +14 -4
  55. package/esm/PieChart/PieArcPlot.js +8 -2
  56. package/esm/PieChart/PieChart.js +7 -4
  57. package/esm/PieChart/PiePlot.js +23 -15
  58. package/esm/PieChart/dataTransform/transition.js +9 -2
  59. package/esm/PieChart/dataTransform/useTransformData.js +12 -9
  60. package/esm/ResponsiveChartContainer/index.js +2 -2
  61. package/esm/context/CartesianContextProvider.js +2 -2
  62. package/esm/context/SeriesContextProvider.js +1 -1
  63. package/esm/index.js +1 -0
  64. package/esm/internals/getWordsByLines.js +14 -0
  65. package/esm/internals/utils.js +29 -0
  66. package/index.d.ts +1 -0
  67. package/index.js +12 -1
  68. package/internals/defaultizeColor.d.ts +7 -4
  69. package/internals/{components/ChartsText.d.ts → getWordsByLines.d.ts} +2 -11
  70. package/internals/getWordsByLines.js +21 -0
  71. package/internals/utils.d.ts +7 -0
  72. package/internals/utils.js +30 -0
  73. package/legacy/BarChart/BarPlot.js +7 -5
  74. package/legacy/BarChart/formatter.js +23 -9
  75. package/legacy/ChartsAxis/ChartsAxis.js +4 -4
  76. package/legacy/ChartsLegend/ChartsLegend.js +2 -1
  77. package/legacy/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  78. package/legacy/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
  79. package/legacy/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
  80. package/legacy/{internals/components → ChartsText}/ChartsText.js +38 -22
  81. package/legacy/ChartsText/index.js +1 -0
  82. package/legacy/ChartsXAxis/ChartsXAxis.js +2 -1
  83. package/legacy/ChartsYAxis/ChartsYAxis.js +1 -1
  84. package/legacy/LineChart/AreaPlot.js +3 -2
  85. package/legacy/LineChart/LineHighlightPlot.js +2 -1
  86. package/legacy/LineChart/LinePlot.js +3 -2
  87. package/legacy/LineChart/MarkPlot.js +2 -1
  88. package/legacy/LineChart/formatter.js +19 -8
  89. package/legacy/PieChart/PieArcLabel.js +7 -8
  90. package/legacy/PieChart/PieArcLabelPlot.js +14 -5
  91. package/legacy/PieChart/PieArcPlot.js +9 -2
  92. package/legacy/PieChart/PieChart.js +7 -4
  93. package/legacy/PieChart/PiePlot.js +23 -15
  94. package/legacy/PieChart/dataTransform/transition.js +9 -2
  95. package/legacy/PieChart/dataTransform/useTransformData.js +12 -9
  96. package/legacy/ResponsiveChartContainer/index.js +2 -2
  97. package/legacy/context/CartesianContextProvider.js +2 -2
  98. package/legacy/context/SeriesContextProvider.js +1 -1
  99. package/legacy/index.js +2 -1
  100. package/legacy/internals/getWordsByLines.js +15 -0
  101. package/legacy/internals/utils.js +29 -0
  102. package/models/axis.d.ts +1 -1
  103. package/models/seriesType/config.d.ts +4 -3
  104. package/models/seriesType/pie.d.ts +43 -7
  105. package/modern/BarChart/BarPlot.js +7 -5
  106. package/modern/BarChart/formatter.js +15 -3
  107. package/modern/ChartsAxis/ChartsAxis.js +4 -4
  108. package/modern/ChartsLegend/ChartsLegend.js +2 -1
  109. package/modern/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  110. package/modern/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
  111. package/modern/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
  112. package/modern/{internals/components → ChartsText}/ChartsText.js +33 -16
  113. package/modern/ChartsText/index.js +1 -0
  114. package/modern/ChartsXAxis/ChartsXAxis.js +2 -1
  115. package/modern/ChartsYAxis/ChartsYAxis.js +1 -1
  116. package/modern/LineChart/AreaPlot.js +3 -2
  117. package/modern/LineChart/LineHighlightPlot.js +2 -1
  118. package/modern/LineChart/LinePlot.js +3 -2
  119. package/modern/LineChart/MarkPlot.js +2 -1
  120. package/modern/LineChart/formatter.js +14 -2
  121. package/modern/PieChart/PieArcLabel.js +7 -8
  122. package/modern/PieChart/PieArcLabelPlot.js +14 -4
  123. package/modern/PieChart/PieArcPlot.js +8 -2
  124. package/modern/PieChart/PieChart.js +7 -4
  125. package/modern/PieChart/PiePlot.js +23 -15
  126. package/modern/PieChart/dataTransform/transition.js +9 -2
  127. package/modern/PieChart/dataTransform/useTransformData.js +11 -8
  128. package/modern/ResponsiveChartContainer/index.js +2 -2
  129. package/modern/context/CartesianContextProvider.js +2 -2
  130. package/modern/context/SeriesContextProvider.js +1 -1
  131. package/modern/index.js +2 -1
  132. package/modern/internals/getWordsByLines.js +14 -0
  133. package/modern/internals/utils.js +29 -0
  134. package/package.json +5 -5
@@ -15,10 +15,10 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
15
15
  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; }
16
16
  function ChartsReferenceLine(props) {
17
17
  if (props.x !== undefined && props.y !== undefined) {
18
- throw new Error('MUI-X: The ChartsReferenceLine can not have both `x` and `y` props set.');
18
+ throw new Error('MUI-X-Charts: The ChartsReferenceLine can not have both `x` and `y` props set.');
19
19
  }
20
20
  if (props.x === undefined && props.y === undefined) {
21
- throw new Error('MUI-X: The ChartsReferenceLine should have a value in `x` or `y` prop.');
21
+ throw new Error('MUI-X-Charts: The ChartsReferenceLine should have a value in `x` or `y` prop.');
22
22
  }
23
23
  if (props.x !== undefined) {
24
24
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsXReferenceLine.ChartsXReferenceLine, (0, _extends2.default)({}, props));
@@ -11,7 +11,7 @@ var React = _interopRequireWildcard(require("react"));
11
11
  var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
12
12
  var _hooks = require("../hooks");
13
13
  var _common = require("./common");
14
- var _ChartsText = require("../internals/components/ChartsText");
14
+ var _ChartsText = require("../ChartsText");
15
15
  var _chartsReferenceLineClasses = require("./chartsReferenceLineClasses");
16
16
  var _jsxRuntime = require("react/jsx-runtime");
17
17
  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); }
@@ -11,7 +11,7 @@ var React = _interopRequireWildcard(require("react"));
11
11
  var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
12
12
  var _hooks = require("../hooks");
13
13
  var _common = require("./common");
14
- var _ChartsText = require("../internals/components/ChartsText");
14
+ var _ChartsText = require("../ChartsText");
15
15
  var _chartsReferenceLineClasses = require("./chartsReferenceLineClasses");
16
16
  var _jsxRuntime = require("react/jsx-runtime");
17
17
  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); }
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { ChartsReferenceLineClasses } from './chartsReferenceLineClasses';
3
- import { ChartsTextStyle } from '../internals/components/ChartsText';
3
+ import { ChartsTextStyle } from '../ChartsText';
4
4
  export type CommonChartsReferenceLineProps = {
5
5
  /**
6
6
  * The alignment if the label is in the chart drawing area.
@@ -0,0 +1,17 @@
1
+ import * as React from 'react';
2
+ import { GetWordsByLinesParams } from '../internals/getWordsByLines';
3
+ export interface ChartsTextProps extends Omit<React.SVGTextElementAttributes<SVGTextElement>, 'width' | 'ref' | 'style' | 'dominantBaseline'>, GetWordsByLinesParams {
4
+ /**
5
+ * Height of a text line (in `em`).
6
+ */
7
+ lineHeight?: number;
8
+ ownerState?: any;
9
+ }
10
+ /**
11
+ * Helper component to manage multiline text in SVG
12
+ */
13
+ declare function ChartsText(props: ChartsTextProps): React.JSX.Element;
14
+ declare namespace ChartsText {
15
+ var propTypes: any;
16
+ }
17
+ export { ChartsText };
@@ -5,28 +5,19 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.ChartsText = ChartsText;
8
- exports.getWordsByLines = getWordsByLines;
9
- var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
10
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
11
10
  var React = _interopRequireWildcard(require("react"));
12
- var _domUtils = require("../domUtils");
11
+ var _propTypes = _interopRequireDefault(require("prop-types"));
12
+ var _getWordsByLines = require("../internals/getWordsByLines");
13
13
  var _jsxRuntime = require("react/jsx-runtime");
14
14
  const _excluded = ["x", "y", "style", "text", "ownerState"],
15
15
  _excluded2 = ["angle", "textAnchor", "dominantBaseline"];
16
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); }
17
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; }
18
- function getWordsByLines({
19
- style,
20
- needsComputation,
21
- text
22
- }) {
23
- return text.split('\n').map(subText => (0, _extends2.default)({
24
- text: subText
25
- }, needsComputation ? (0, _domUtils.getStringSize)(subText, style) : {
26
- width: 0,
27
- height: 0
28
- }));
29
- }
18
+ /**
19
+ * Helper component to manage multiline text in SVG
20
+ */
30
21
  function ChartsText(props) {
31
22
  const {
32
23
  x,
@@ -42,7 +33,7 @@ function ChartsText(props) {
42
33
  dominantBaseline
43
34
  } = _ref,
44
35
  style = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded2);
45
- const wordsByLines = React.useMemo(() => getWordsByLines({
36
+ const wordsByLines = React.useMemo(() => (0, _getWordsByLines.getWordsByLines)({
46
37
  style,
47
38
  needsComputation: text.includes('\n'),
48
39
  text
@@ -84,4 +75,28 @@ function ChartsText(props) {
84
75
  children: line.text
85
76
  }, index))
86
77
  }));
87
- }
78
+ }
79
+ process.env.NODE_ENV !== "production" ? ChartsText.propTypes = {
80
+ // ----------------------------- Warning --------------------------------
81
+ // | These PropTypes are generated from the TypeScript type definitions |
82
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
83
+ // ----------------------------------------------------------------------
84
+ /**
85
+ * Height of a text line (in `em`).
86
+ */
87
+ lineHeight: _propTypes.default.number,
88
+ /**
89
+ * If `true`, the line width is computed.
90
+ * @default false
91
+ */
92
+ needsComputation: _propTypes.default.bool,
93
+ ownerState: _propTypes.default.any,
94
+ /**
95
+ * Style applied to text elements.
96
+ */
97
+ style: _propTypes.default.object,
98
+ /**
99
+ * Text displayed.
100
+ */
101
+ text: _propTypes.default.string.isRequired
102
+ } : void 0;
@@ -0,0 +1,3 @@
1
+ export { ChartsText } from './ChartsText';
2
+ export type { ChartsTextProps } from './ChartsText';
3
+ export type { ChartsTextStyle } from '../internals/getWordsByLines';
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "ChartsText", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _ChartsText.ChartsText;
10
+ }
11
+ });
12
+ var _ChartsText = require("./ChartsText");
@@ -0,0 +1,6 @@
1
+ {
2
+ "sideEffects": false,
3
+ "module": "../esm/ChartsText/index.js",
4
+ "main": "./index.js",
5
+ "types": "./index.d.ts"
6
+ }
@@ -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 null;
65
+ }
66
+ return value;
67
+ }) : series[id].data,
56
68
  stackedData: stackedSeries[index].map(([a, b]) => [a, b])
57
69
  });
58
70
  });
@@ -23,6 +23,7 @@ export type PieArcLabelProps = PieArcLabelOwnerState & React.ComponentPropsWitho
23
23
  endAngle: SpringValue<number>;
24
24
  innerRadius: SpringValue<number>;
25
25
  outerRadius: SpringValue<number>;
26
+ arcLabelRadius: SpringValue<number>;
26
27
  cornerRadius: SpringValue<number>;
27
28
  paddingAngle: SpringValue<number>;
28
29
  } & {
@@ -18,7 +18,7 @@ var _generateUtilityClass = _interopRequireDefault(require("@mui/utils/generateU
18
18
  var _styles = require("@mui/material/styles");
19
19
  var _generateUtilityClasses = _interopRequireDefault(require("@mui/utils/generateUtilityClasses"));
20
20
  var _jsxRuntime = require("react/jsx-runtime");
21
- const _excluded = ["id", "classes", "color", "startAngle", "endAngle", "paddingAngle", "innerRadius", "outerRadius", "cornerRadius", "formattedArcLabel", "isHighlighted", "isFaded", "style"];
21
+ const _excluded = ["id", "classes", "color", "startAngle", "endAngle", "paddingAngle", "arcLabelRadius", "cornerRadius", "formattedArcLabel", "isHighlighted", "isFaded", "style"];
22
22
  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); }
23
23
  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; }
24
24
  function getPieArcLabelUtilityClass(slot) {
@@ -52,7 +52,7 @@ const PieArcLabelRoot = (0, _styles.styled)(_web.animated.text, {
52
52
  * Helper to compute label position.
53
53
  * It's not an inline function because we need it in inerpolation.
54
54
  */
55
- const getLabelPosition = (formattedArcLabel, variable) => (startAngle, endAngle, padAngle, innerRadius, outerRadius, cornerRadius) => {
55
+ const getLabelPosition = (formattedArcLabel, variable) => (startAngle, endAngle, padAngle, arcLabelRadius, cornerRadius) => {
56
56
  if (!formattedArcLabel) {
57
57
  return 0;
58
58
  }
@@ -60,8 +60,8 @@ const getLabelPosition = (formattedArcLabel, variable) => (startAngle, endAngle,
60
60
  padAngle,
61
61
  startAngle,
62
62
  endAngle,
63
- innerRadius,
64
- outerRadius
63
+ innerRadius: arcLabelRadius,
64
+ outerRadius: arcLabelRadius
65
65
  });
66
66
  if (variable === 'x') {
67
67
  return x;
@@ -76,8 +76,7 @@ function PieArcLabel(props) {
76
76
  startAngle,
77
77
  endAngle,
78
78
  paddingAngle,
79
- innerRadius,
80
- outerRadius,
79
+ arcLabelRadius,
81
80
  cornerRadius,
82
81
  formattedArcLabel,
83
82
  isHighlighted,
@@ -97,8 +96,8 @@ function PieArcLabel(props) {
97
96
  className: classes.root
98
97
  }, other, {
99
98
  style: (0, _extends2.default)({
100
- x: (0, _web.to)([startAngle, endAngle, paddingAngle, innerRadius, outerRadius, cornerRadius], getLabelPosition(formattedArcLabel, 'x')),
101
- y: (0, _web.to)([startAngle, endAngle, paddingAngle, innerRadius, outerRadius, cornerRadius], getLabelPosition(formattedArcLabel, 'y'))
99
+ x: (0, _web.to)([startAngle, endAngle, paddingAngle, arcLabelRadius, cornerRadius], getLabelPosition(formattedArcLabel, 'x')),
100
+ y: (0, _web.to)([startAngle, endAngle, paddingAngle, arcLabelRadius, cornerRadius], getLabelPosition(formattedArcLabel, 'y'))
102
101
  }, style),
103
102
  children: formattedArcLabel
104
103
  }));
@@ -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 {}
@@ -14,8 +14,8 @@ var _transition = require("./dataTransform/transition");
14
14
  var _useTransformData = require("./dataTransform/useTransformData");
15
15
  var _PieArcLabel = require("./PieArcLabel");
16
16
  var _jsxRuntime = require("react/jsx-runtime");
17
- const _excluded = ["slots", "slotProps", "innerRadius", "outerRadius", "cornerRadius", "paddingAngle", "id", "highlightScope", "highlighted", "faded", "data", "arcLabel", "arcLabelMinAngle", "skipAnimation"],
18
- _excluded2 = ["startAngle", "endAngle", "paddingAngle", "innerRadius", "outerRadius", "cornerRadius"];
17
+ const _excluded = ["slots", "slotProps", "innerRadius", "outerRadius", "arcLabelRadius", "cornerRadius", "paddingAngle", "id", "highlightScope", "highlighted", "faded", "data", "arcLabel", "arcLabelMinAngle", "skipAnimation"],
18
+ _excluded2 = ["startAngle", "endAngle", "paddingAngle", "innerRadius", "outerRadius", "arcLabelRadius", "cornerRadius"];
19
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); }
20
20
  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; }
21
21
  const RATIO = 180 / Math.PI;
@@ -36,8 +36,9 @@ function PieArcLabelPlot(props) {
36
36
  const {
37
37
  slots,
38
38
  slotProps,
39
- innerRadius = 0,
39
+ innerRadius,
40
40
  outerRadius,
41
+ arcLabelRadius,
41
42
  cornerRadius = 0,
42
43
  paddingAngle = 0,
43
44
  id,
@@ -55,6 +56,7 @@ function PieArcLabelPlot(props) {
55
56
  const transformedData = (0, _useTransformData.useTransformData)({
56
57
  innerRadius,
57
58
  outerRadius,
59
+ arcLabelRadius,
58
60
  cornerRadius,
59
61
  paddingAngle,
60
62
  id,
@@ -78,6 +80,7 @@ function PieArcLabelPlot(props) {
78
80
  paddingAngle: pA,
79
81
  innerRadius: iR,
80
82
  outerRadius: oR,
83
+ arcLabelRadius: aLR,
81
84
  cornerRadius: cR
82
85
  } = _ref,
83
86
  style = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded2);
@@ -87,6 +90,7 @@ function PieArcLabelPlot(props) {
87
90
  paddingAngle: pA,
88
91
  innerRadius: iR,
89
92
  outerRadius: oR,
93
+ arcLabelRadius: aLR,
90
94
  cornerRadius: cR,
91
95
  style: style,
92
96
  id: id,
@@ -111,6 +115,11 @@ process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
111
115
  * The minimal angle required to display the arc label.
112
116
  */
113
117
  arcLabelMinAngle: _propTypes.default.number,
118
+ /**
119
+ * The radius between circle center and the arc label in px.
120
+ * @default (innerRadius - outerRadius) / 2
121
+ */
122
+ arcLabelRadius: _propTypes.default.number,
114
123
  /**
115
124
  * The radius applied to arc corners (similar to border radius).
116
125
  * @default 0
@@ -132,6 +141,7 @@ process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
132
141
  */
133
142
  faded: _propTypes.default.shape({
134
143
  additionalRadius: _propTypes.default.number,
144
+ arcLabelRadius: _propTypes.default.number,
135
145
  color: _propTypes.default.string,
136
146
  cornerRadius: _propTypes.default.number,
137
147
  innerRadius: _propTypes.default.number,
@@ -143,6 +153,7 @@ process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
143
153
  */
144
154
  highlighted: _propTypes.default.shape({
145
155
  additionalRadius: _propTypes.default.number,
156
+ arcLabelRadius: _propTypes.default.number,
146
157
  color: _propTypes.default.string,
147
158
  cornerRadius: _propTypes.default.number,
148
159
  innerRadius: _propTypes.default.number,
@@ -161,7 +172,6 @@ process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
161
172
  innerRadius: _propTypes.default.number,
162
173
  /**
163
174
  * 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
175
  */
166
176
  outerRadius: _propTypes.default.number.isRequired,
167
177
  /**
@@ -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 {}
@@ -15,7 +15,7 @@ var _transition = require("./dataTransform/transition");
15
15
  var _useTransformData = require("./dataTransform/useTransformData");
16
16
  var _jsxRuntime = require("react/jsx-runtime");
17
17
  const _excluded = ["slots", "slotProps", "innerRadius", "outerRadius", "cornerRadius", "paddingAngle", "id", "highlightScope", "highlighted", "faded", "data", "onClick", "skipAnimation"],
18
- _excluded2 = ["startAngle", "endAngle", "paddingAngle", "innerRadius", "outerRadius", "cornerRadius"];
18
+ _excluded2 = ["startAngle", "endAngle", "paddingAngle", "innerRadius", "arcLabelRadius", "outerRadius", "cornerRadius"];
19
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); }
20
20
  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; }
21
21
  function PieArcPlot(props) {
@@ -96,6 +96,11 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
96
96
  // | These PropTypes are generated from the TypeScript type definitions |
97
97
  // | To update them edit the TypeScript types and run "yarn proptypes" |
98
98
  // ----------------------------------------------------------------------
99
+ /**
100
+ * The radius between circle center and the arc label in px.
101
+ * @default (innerRadius - outerRadius) / 2
102
+ */
103
+ arcLabelRadius: _propTypes.default.number,
99
104
  /**
100
105
  * The radius applied to arc corners (similar to border radius).
101
106
  * @default 0
@@ -117,6 +122,7 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
117
122
  */
118
123
  faded: _propTypes.default.shape({
119
124
  additionalRadius: _propTypes.default.number,
125
+ arcLabelRadius: _propTypes.default.number,
120
126
  color: _propTypes.default.string,
121
127
  cornerRadius: _propTypes.default.number,
122
128
  innerRadius: _propTypes.default.number,
@@ -128,6 +134,7 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
128
134
  */
129
135
  highlighted: _propTypes.default.shape({
130
136
  additionalRadius: _propTypes.default.number,
137
+ arcLabelRadius: _propTypes.default.number,
131
138
  color: _propTypes.default.string,
132
139
  cornerRadius: _propTypes.default.number,
133
140
  innerRadius: _propTypes.default.number,
@@ -153,7 +160,6 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
153
160
  onClick: _propTypes.default.func,
154
161
  /**
155
162
  * 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
163
  */
158
164
  outerRadius: _propTypes.default.number.isRequired,
159
165
  /**
@@ -246,10 +246,11 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
246
246
  series: _propTypes.default.arrayOf(_propTypes.default.shape({
247
247
  arcLabel: _propTypes.default.oneOfType([_propTypes.default.oneOf(['formattedValue', 'label', 'value']), _propTypes.default.func]),
248
248
  arcLabelMinAngle: _propTypes.default.number,
249
+ arcLabelRadius: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
249
250
  color: _propTypes.default.string,
250
251
  cornerRadius: _propTypes.default.number,
251
- cx: _propTypes.default.number,
252
- cy: _propTypes.default.number,
252
+ cx: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
253
+ cy: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
253
254
  data: _propTypes.default.arrayOf(_propTypes.default.shape({
254
255
  color: _propTypes.default.string,
255
256
  id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
@@ -259,6 +260,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
259
260
  endAngle: _propTypes.default.number,
260
261
  faded: _propTypes.default.shape({
261
262
  additionalRadius: _propTypes.default.number,
263
+ arcLabelRadius: _propTypes.default.number,
262
264
  color: _propTypes.default.string,
263
265
  cornerRadius: _propTypes.default.number,
264
266
  innerRadius: _propTypes.default.number,
@@ -267,6 +269,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
267
269
  }),
268
270
  highlighted: _propTypes.default.shape({
269
271
  additionalRadius: _propTypes.default.number,
272
+ arcLabelRadius: _propTypes.default.number,
270
273
  color: _propTypes.default.string,
271
274
  cornerRadius: _propTypes.default.number,
272
275
  innerRadius: _propTypes.default.number,
@@ -278,8 +281,8 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
278
281
  highlighted: _propTypes.default.oneOf(['item', 'none', 'series'])
279
282
  }),
280
283
  id: _propTypes.default.string,
281
- innerRadius: _propTypes.default.number,
282
- outerRadius: _propTypes.default.number,
284
+ innerRadius: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
285
+ outerRadius: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
283
286
  paddingAngle: _propTypes.default.number,
284
287
  sortingValues: _propTypes.default.oneOfType([_propTypes.default.oneOf(['asc', 'desc', 'none']), _propTypes.default.func]),
285
288
  startAngle: _propTypes.default.number,