@mui/x-charts 6.0.0-alpha.6 → 6.0.0-alpha.8

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 (142) hide show
  1. package/BarChart/BarChart.d.ts +19 -2
  2. package/BarChart/BarChart.js +84 -22
  3. package/BarChart/BarElement.d.ts +22 -0
  4. package/BarChart/BarElement.js +21 -10
  5. package/BarChart/BarPlot.d.ts +14 -1
  6. package/BarChart/BarPlot.js +48 -19
  7. package/BarChart/extremums.js +19 -3
  8. package/BarChart/formatter.js +3 -1
  9. package/CHANGELOG.md +213 -28
  10. package/ChartsAxis/ChartsAxis.d.ts +11 -1
  11. package/ChartsAxis/ChartsAxis.js +51 -6
  12. package/ChartsAxisHighlight/ChartsAxisHighlight.d.ts +3 -2
  13. package/ChartsAxisHighlight/ChartsAxisHighlight.js +11 -3
  14. package/ChartsLegend/ChartsLegend.d.ts +25 -2
  15. package/ChartsLegend/ChartsLegend.js +49 -17
  16. package/ChartsTooltip/ChartsAxisTooltipContent.js +13 -9
  17. package/ChartsTooltip/ChartsTooltipTable.d.ts +2 -9
  18. package/ChartsXAxis/ChartsXAxis.js +44 -9
  19. package/ChartsYAxis/ChartsYAxis.js +44 -9
  20. package/LineChart/AreaElement.d.ts +22 -0
  21. package/LineChart/AreaElement.js +31 -11
  22. package/LineChart/AreaPlot.d.ts +14 -1
  23. package/LineChart/AreaPlot.js +29 -3
  24. package/LineChart/LineChart.d.ts +20 -2
  25. package/LineChart/LineChart.js +63 -11
  26. package/LineChart/LineElement.d.ts +22 -0
  27. package/LineChart/LineElement.js +31 -10
  28. package/LineChart/LinePlot.d.ts +14 -1
  29. package/LineChart/LinePlot.js +35 -4
  30. package/LineChart/MarkPlot.d.ts +24 -1
  31. package/LineChart/MarkPlot.js +29 -4
  32. package/PieChart/PieArcLabel.js +0 -1
  33. package/PieChart/PieChart.d.ts +14 -2
  34. package/PieChart/PieChart.js +52 -10
  35. package/PieChart/PiePlot.d.ts +27 -1
  36. package/PieChart/PiePlot.js +29 -6
  37. package/ScatterChart/ScatterChart.d.ts +18 -2
  38. package/ScatterChart/ScatterChart.js +56 -10
  39. package/ScatterChart/ScatterPlot.d.ts +24 -1
  40. package/ScatterChart/ScatterPlot.js +28 -4
  41. package/SparkLineChart/SparkLineChart.d.ts +18 -0
  42. package/SparkLineChart/SparkLineChart.js +29 -6
  43. package/colorPalettes/colorPalettes.js +2 -2
  44. package/context/CartesianContextProvider.js +18 -12
  45. package/esm/BarChart/BarChart.js +88 -26
  46. package/esm/BarChart/BarElement.js +21 -11
  47. package/esm/BarChart/BarPlot.js +49 -20
  48. package/esm/BarChart/extremums.js +18 -2
  49. package/esm/BarChart/formatter.js +3 -1
  50. package/esm/ChartsAxis/ChartsAxis.js +51 -6
  51. package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +11 -3
  52. package/esm/ChartsLegend/ChartsLegend.js +47 -14
  53. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +13 -9
  54. package/esm/ChartsXAxis/ChartsXAxis.js +45 -9
  55. package/esm/ChartsYAxis/ChartsYAxis.js +45 -9
  56. package/esm/LineChart/AreaElement.js +31 -11
  57. package/esm/LineChart/AreaPlot.js +31 -4
  58. package/esm/LineChart/LineChart.js +63 -11
  59. package/esm/LineChart/LineElement.js +31 -11
  60. package/esm/LineChart/LinePlot.js +43 -8
  61. package/esm/LineChart/MarkPlot.js +32 -5
  62. package/esm/PieChart/PieArcLabel.js +0 -1
  63. package/esm/PieChart/PieChart.js +52 -10
  64. package/esm/PieChart/PiePlot.js +31 -6
  65. package/esm/ScatterChart/ScatterChart.js +56 -10
  66. package/esm/ScatterChart/ScatterPlot.js +29 -4
  67. package/esm/SparkLineChart/SparkLineChart.js +29 -6
  68. package/esm/colorPalettes/colorPalettes.js +2 -2
  69. package/esm/context/CartesianContextProvider.js +18 -12
  70. package/esm/hooks/useAxisEvents.js +21 -38
  71. package/esm/hooks/useTicks.js +11 -8
  72. package/esm/internals/components/AxisSharedComponents.js +10 -10
  73. package/hooks/useAxisEvents.js +21 -38
  74. package/hooks/useTicks.d.ts +20 -5
  75. package/hooks/useTicks.js +11 -8
  76. package/index.js +1 -1
  77. package/internals/components/AxisSharedComponents.d.ts +4 -4
  78. package/internals/components/AxisSharedComponents.js +15 -15
  79. package/internals/defaultizeColor.d.ts +1 -0
  80. package/legacy/BarChart/BarChart.js +93 -29
  81. package/legacy/BarChart/BarElement.js +20 -10
  82. package/legacy/BarChart/BarPlot.js +49 -20
  83. package/legacy/BarChart/extremums.js +22 -2
  84. package/legacy/BarChart/formatter.js +3 -1
  85. package/legacy/ChartsAxis/ChartsAxis.js +51 -6
  86. package/legacy/ChartsAxisHighlight/ChartsAxisHighlight.js +11 -3
  87. package/legacy/ChartsLegend/ChartsLegend.js +46 -15
  88. package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +13 -9
  89. package/legacy/ChartsXAxis/ChartsXAxis.js +45 -9
  90. package/legacy/ChartsYAxis/ChartsYAxis.js +45 -9
  91. package/legacy/LineChart/AreaElement.js +30 -10
  92. package/legacy/LineChart/AreaPlot.js +29 -4
  93. package/legacy/LineChart/LineChart.js +63 -11
  94. package/legacy/LineChart/LineElement.js +30 -10
  95. package/legacy/LineChart/LinePlot.js +36 -5
  96. package/legacy/LineChart/MarkPlot.js +30 -5
  97. package/legacy/PieChart/PieArcLabel.js +0 -1
  98. package/legacy/PieChart/PieChart.js +52 -10
  99. package/legacy/PieChart/PiePlot.js +29 -6
  100. package/legacy/ScatterChart/ScatterChart.js +56 -10
  101. package/legacy/ScatterChart/ScatterPlot.js +27 -4
  102. package/legacy/SparkLineChart/SparkLineChart.js +29 -6
  103. package/legacy/colorPalettes/colorPalettes.js +2 -2
  104. package/legacy/context/CartesianContextProvider.js +18 -12
  105. package/legacy/hooks/useAxisEvents.js +21 -37
  106. package/legacy/hooks/useTicks.js +11 -11
  107. package/legacy/index.js +1 -1
  108. package/legacy/internals/components/AxisSharedComponents.js +10 -10
  109. package/models/axis.d.ts +24 -1
  110. package/models/seriesType/bar.d.ts +6 -1
  111. package/modern/BarChart/BarChart.js +85 -23
  112. package/modern/BarChart/BarElement.js +20 -11
  113. package/modern/BarChart/BarPlot.js +48 -19
  114. package/modern/BarChart/extremums.js +18 -2
  115. package/modern/BarChart/formatter.js +3 -1
  116. package/modern/ChartsAxis/ChartsAxis.js +51 -6
  117. package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +11 -3
  118. package/modern/ChartsLegend/ChartsLegend.js +46 -14
  119. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +13 -9
  120. package/modern/ChartsXAxis/ChartsXAxis.js +44 -9
  121. package/modern/ChartsYAxis/ChartsYAxis.js +44 -9
  122. package/modern/LineChart/AreaElement.js +30 -11
  123. package/modern/LineChart/AreaPlot.js +31 -4
  124. package/modern/LineChart/LineChart.js +63 -11
  125. package/modern/LineChart/LineElement.js +30 -11
  126. package/modern/LineChart/LinePlot.js +37 -5
  127. package/modern/LineChart/MarkPlot.js +31 -5
  128. package/modern/PieChart/PieArcLabel.js +0 -1
  129. package/modern/PieChart/PieChart.js +52 -10
  130. package/modern/PieChart/PiePlot.js +30 -6
  131. package/modern/ScatterChart/ScatterChart.js +56 -10
  132. package/modern/ScatterChart/ScatterPlot.js +28 -4
  133. package/modern/SparkLineChart/SparkLineChart.js +29 -6
  134. package/modern/colorPalettes/colorPalettes.js +2 -2
  135. package/modern/context/CartesianContextProvider.js +18 -12
  136. package/modern/hooks/useAxisEvents.js +21 -38
  137. package/modern/hooks/useTicks.js +11 -8
  138. package/modern/index.js +1 -1
  139. package/modern/internals/components/AxisSharedComponents.js +10 -10
  140. package/package.json +5 -5
  141. package/themeAugmentation/components.d.ts +0 -10
  142. package/themeAugmentation/overrides.d.ts +0 -2
@@ -8,7 +8,7 @@ import { useThemeProps, useTheme } from '@mui/material/styles';
8
8
  import { CartesianContext } from '../context/CartesianContextProvider';
9
9
  import { DrawingContext } from '../context/DrawingProvider';
10
10
  import useTicks from '../hooks/useTicks';
11
- import { Line, Tick, TickLabel, Label, AxisRoot } from '../internals/components/AxisSharedComponents';
11
+ import { ChartsLine, ChartsTick, ChartsTickLabel, ChartsLabel, AxisRoot } from '../internals/components/AxisSharedComponents';
12
12
  import { getAxisUtilityClass } from '../ChartsAxis/axisClasses';
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -60,7 +60,9 @@ function ChartsYAxis(inProps) {
60
60
  label,
61
61
  labelFontSize,
62
62
  tickSize: tickSizeProp,
63
- valueFormatter
63
+ valueFormatter,
64
+ slots,
65
+ slotProps
64
66
  } = defaultizedProps;
65
67
  const theme = useTheme();
66
68
  const classes = useUtilityClasses(_extends({}, defaultizedProps, {
@@ -83,14 +85,18 @@ function ChartsYAxis(inProps) {
83
85
  x: positionSigne * (tickFontSize + tickSize + 10),
84
86
  y: top + height / 2
85
87
  };
88
+ const Line = slots?.axisLine ?? ChartsLine;
89
+ const Tick = slots?.axisTick ?? ChartsTick;
90
+ const TickLabel = slots?.axisTickLabel ?? ChartsTickLabel;
91
+ const Label = slots?.axisLabel ?? ChartsLabel;
86
92
  return /*#__PURE__*/_jsxs(AxisRoot, {
87
93
  transform: `translate(${position === 'right' ? left + width : left}, 0)`,
88
94
  className: classes.root,
89
- children: [!disableLine && /*#__PURE__*/_jsx(Line, {
95
+ children: [!disableLine && /*#__PURE__*/_jsx(Line, _extends({
90
96
  y1: yScale.range()[0],
91
97
  y2: yScale.range()[1],
92
98
  className: classes.line
93
- }), yTicks.map(({
99
+ }, slotProps?.axisLine)), yTicks.map(({
94
100
  formattedValue,
95
101
  offset,
96
102
  labelOffset
@@ -100,19 +106,20 @@ function ChartsYAxis(inProps) {
100
106
  return /*#__PURE__*/_jsxs("g", {
101
107
  transform: `translate(0, ${offset})`,
102
108
  className: classes.tickContainer,
103
- children: [!disableTicks && /*#__PURE__*/_jsx(Tick, {
109
+ children: [!disableTicks && /*#__PURE__*/_jsx(Tick, _extends({
104
110
  x2: positionSigne * tickSize,
105
111
  className: classes.tick
106
- }), formattedValue !== undefined && /*#__PURE__*/_jsx(TickLabel, {
112
+ }, slotProps?.axisTick)), formattedValue !== undefined && /*#__PURE__*/_jsx(TickLabel, _extends({
107
113
  x: xTickLabel,
108
114
  y: yTickLabel,
109
115
  "transform-origin": `${xTickLabel}px ${yTickLabel}px`,
110
116
  sx: {
111
117
  fontSize: tickFontSize
112
118
  },
113
- className: classes.tickLabel,
119
+ className: classes.tickLabel
120
+ }, slotProps?.axisTickLabel, {
114
121
  children: formattedValue.toLocaleString()
115
- })]
122
+ }))]
116
123
  }, index);
117
124
  }), label && /*#__PURE__*/_jsx(Label, _extends({}, labelRefPoint, {
118
125
  sx: {
@@ -120,7 +127,8 @@ function ChartsYAxis(inProps) {
120
127
  transform: `rotate(${positionSigne * 90}deg)`,
121
128
  transformOrigin: `${labelRefPoint.x}px ${labelRefPoint.y}px`
122
129
  },
123
- className: classes.label,
130
+ className: classes.label
131
+ }, slotProps?.axisLabel, {
124
132
  children: label
125
133
  }))]
126
134
  });
@@ -166,6 +174,16 @@ process.env.NODE_ENV !== "production" ? ChartsYAxis.propTypes = {
166
174
  * Position of the axis.
167
175
  */
168
176
  position: PropTypes.oneOf(['left', 'right']),
177
+ /**
178
+ * The props used for each component slot.
179
+ * @default {}
180
+ */
181
+ slotProps: PropTypes.object,
182
+ /**
183
+ * Overridable component slots.
184
+ * @default {}
185
+ */
186
+ slots: PropTypes.object,
169
187
  /**
170
188
  * The stroke color of the axis line.
171
189
  * @default 'currentColor'
@@ -176,6 +194,23 @@ process.env.NODE_ENV !== "production" ? ChartsYAxis.propTypes = {
176
194
  * @default 12
177
195
  */
178
196
  tickFontSize: PropTypes.number,
197
+ /**
198
+ * Maximal step between two ticks.
199
+ * When using time data, the value is assumed to be in ms.
200
+ * Not supported by categorical axis (band, points).
201
+ */
202
+ tickMaxStep: PropTypes.number,
203
+ /**
204
+ * Maximal step between two ticks.
205
+ * When using time data, the value is assumed to be in ms.
206
+ * Not supported by categorical axis (band, points).
207
+ */
208
+ tickMinStep: PropTypes.number,
209
+ /**
210
+ * The number of ticks. This number is not guaranted.
211
+ * Not supported by categorical axis (band, points).
212
+ */
213
+ tickNumber: PropTypes.number,
179
214
  /**
180
215
  * The size of the ticks.
181
216
  * @default 6
@@ -1,9 +1,10 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["id", "classes", "color", "highlightScope"];
3
+ const _excluded = ["id", "classes", "color", "highlightScope", "slots", "slotProps"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import composeClasses from '@mui/utils/composeClasses';
7
+ import { useSlotProps } from '@mui/base/utils';
7
8
  import generateUtilityClass from '@mui/utils/generateUtilityClass';
8
9
  import { styled } from '@mui/material/styles';
9
10
  import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
@@ -27,7 +28,7 @@ const useUtilityClasses = ownerState => {
27
28
  };
28
29
  return composeClasses(slots, getAreaElementUtilityClass, classes);
29
30
  };
30
- const AreaElementPath = styled('path', {
31
+ export const AreaElementPath = styled('path', {
31
32
  name: 'MuiAreaElement',
32
33
  slot: 'Root',
33
34
  overridesResolver: (_, styles) => styles.root
@@ -59,7 +60,9 @@ function AreaElement(props) {
59
60
  id,
60
61
  classes: innerClasses,
61
62
  color,
62
- highlightScope
63
+ highlightScope,
64
+ slots,
65
+ slotProps
63
66
  } = props,
64
67
  other = _objectWithoutPropertiesLoose(props, _excluded);
65
68
  const getInteractionItemProps = useInteractionItemProps(highlightScope);
@@ -82,13 +85,19 @@ function AreaElement(props) {
82
85
  isHighlighted
83
86
  };
84
87
  const classes = useUtilityClasses(ownerState);
85
- return /*#__PURE__*/_jsx(AreaElementPath, _extends({}, other, {
86
- ownerState: ownerState,
87
- className: classes.root
88
- }, getInteractionItemProps({
89
- type: 'line',
90
- seriesId: id
91
- })));
88
+ const Area = slots?.area ?? AreaElementPath;
89
+ const areaProps = useSlotProps({
90
+ elementType: Area,
91
+ externalSlotProps: slotProps?.area,
92
+ additionalProps: _extends({}, other, getInteractionItemProps({
93
+ type: 'line',
94
+ seriesId: id
95
+ }), {
96
+ className: classes.root
97
+ }),
98
+ ownerState
99
+ });
100
+ return /*#__PURE__*/_jsx(Area, _extends({}, areaProps));
92
101
  }
93
102
  process.env.NODE_ENV !== "production" ? AreaElement.propTypes = {
94
103
  // ----------------------------- Warning --------------------------------
@@ -99,6 +108,16 @@ process.env.NODE_ENV !== "production" ? AreaElement.propTypes = {
99
108
  highlightScope: PropTypes.shape({
100
109
  faded: PropTypes.oneOf(['global', 'none', 'series']),
101
110
  highlighted: PropTypes.oneOf(['item', 'none', 'series'])
102
- })
111
+ }),
112
+ /**
113
+ * The props used for each component slot.
114
+ * @default {}
115
+ */
116
+ slotProps: PropTypes.object,
117
+ /**
118
+ * Overridable component slots.
119
+ * @default {}
120
+ */
121
+ slots: PropTypes.object
103
122
  } : void 0;
104
123
  export { AreaElement };
@@ -1,5 +1,8 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["slots", "slotProps"];
2
4
  import * as React from 'react';
5
+ import PropTypes from 'prop-types';
3
6
  import { area as d3Area } from 'd3-shape';
4
7
  import { SeriesContext } from '../context/SeriesContextProvider';
5
8
  import { CartesianContext } from '../context/CartesianContextProvider';
@@ -7,7 +10,12 @@ import { AreaElement } from './AreaElement';
7
10
  import { getValueToPositionMapper } from '../hooks/useScale';
8
11
  import getCurveFactory from '../internals/getCurve';
9
12
  import { jsx as _jsx } from "react/jsx-runtime";
10
- export function AreaPlot(props) {
13
+ function AreaPlot(props) {
14
+ const {
15
+ slots,
16
+ slotProps
17
+ } = props,
18
+ other = _objectWithoutPropertiesLoose(props, _excluded);
11
19
  const seriesData = React.useContext(SeriesContext).line;
12
20
  const axisData = React.useContext(CartesianContext);
13
21
  if (seriesData === undefined) {
@@ -25,7 +33,7 @@ export function AreaPlot(props) {
25
33
  } = axisData;
26
34
  const defaultXAxisId = xAxisIds[0];
27
35
  const defaultYAxisId = yAxisIds[0];
28
- return /*#__PURE__*/_jsx("g", _extends({}, props, {
36
+ return /*#__PURE__*/_jsx("g", _extends({}, other, {
29
37
  children: stackingGroups.flatMap(({
30
38
  ids: groupIds
31
39
  }) => {
@@ -51,9 +59,28 @@ export function AreaPlot(props) {
51
59
  id: seriesId,
52
60
  d: areaPath.curve(curve)(d3Data) || undefined,
53
61
  color: series[seriesId].color,
54
- highlightScope: series[seriesId].highlightScope
62
+ highlightScope: series[seriesId].highlightScope,
63
+ slots: slots,
64
+ slotProps: slotProps
55
65
  }, seriesId);
56
66
  });
57
67
  })
58
68
  }));
59
- }
69
+ }
70
+ process.env.NODE_ENV !== "production" ? AreaPlot.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
+ * The props used for each component slot.
77
+ * @default {}
78
+ */
79
+ slotProps: PropTypes.object,
80
+ /**
81
+ * Overridable component slots.
82
+ * @default {}
83
+ */
84
+ slots: PropTypes.object
85
+ } : void 0;
86
+ export { AreaPlot };
@@ -34,7 +34,9 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
34
34
  leftAxis,
35
35
  rightAxis,
36
36
  bottomAxis,
37
- children
37
+ children,
38
+ slots,
39
+ slotProps
38
40
  } = props;
39
41
  const id = useId();
40
42
  const clipPathId = `${id}-clip-path`;
@@ -60,13 +62,27 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
60
62
  disableAxisListener: tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none',
61
63
  children: [/*#__PURE__*/_jsxs("g", {
62
64
  clipPath: `url(#${clipPathId})`,
63
- children: [/*#__PURE__*/_jsx(AreaPlot, {}), /*#__PURE__*/_jsx(LinePlot, {})]
65
+ children: [/*#__PURE__*/_jsx(AreaPlot, {
66
+ slots: slots,
67
+ slotProps: slotProps
68
+ }), /*#__PURE__*/_jsx(LinePlot, {
69
+ slots: slots,
70
+ slotProps: slotProps
71
+ })]
64
72
  }), /*#__PURE__*/_jsx(ChartsAxis, {
65
73
  topAxis: topAxis,
66
74
  leftAxis: leftAxis,
67
75
  rightAxis: rightAxis,
68
- bottomAxis: bottomAxis
69
- }), /*#__PURE__*/_jsx(MarkPlot, {}), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend)), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlight)), /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip)), /*#__PURE__*/_jsx(ChartsClipPath, {
76
+ bottomAxis: bottomAxis,
77
+ slots: slots,
78
+ slotProps: slotProps
79
+ }), /*#__PURE__*/_jsx(MarkPlot, {
80
+ slots: slots,
81
+ slotProps: slotProps
82
+ }), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend, {
83
+ slots: slots,
84
+ slotProps: slotProps
85
+ })), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlight)), /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip)), /*#__PURE__*/_jsx(ChartsClipPath, {
70
86
  id: clipPathId
71
87
  }), children]
72
88
  });
@@ -78,7 +94,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
78
94
  // ----------------------------------------------------------------------
79
95
  axisHighlight: PropTypes.shape({
80
96
  x: PropTypes.oneOf(['band', 'line', 'none']),
81
- y: PropTypes.oneOf(['line', 'none'])
97
+ y: PropTypes.oneOf(['band', 'line', 'none'])
82
98
  }),
83
99
  /**
84
100
  * Indicate which axis to display the bottom of the charts.
@@ -94,8 +110,13 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
94
110
  label: PropTypes.string,
95
111
  labelFontSize: PropTypes.number,
96
112
  position: PropTypes.oneOf(['bottom', 'top']),
113
+ slotProps: PropTypes.object,
114
+ slots: PropTypes.object,
97
115
  stroke: PropTypes.string,
98
116
  tickFontSize: PropTypes.number,
117
+ tickMaxStep: PropTypes.number,
118
+ tickMinStep: PropTypes.number,
119
+ tickNumber: PropTypes.number,
99
120
  tickSize: PropTypes.number
100
121
  }), PropTypes.string]),
101
122
  children: PropTypes.node,
@@ -122,8 +143,13 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
122
143
  label: PropTypes.string,
123
144
  labelFontSize: PropTypes.number,
124
145
  position: PropTypes.oneOf(['left', 'right']),
146
+ slotProps: PropTypes.object,
147
+ slots: PropTypes.object,
125
148
  stroke: PropTypes.string,
126
149
  tickFontSize: PropTypes.number,
150
+ tickMaxStep: PropTypes.number,
151
+ tickMinStep: PropTypes.number,
152
+ tickNumber: PropTypes.number,
127
153
  tickSize: PropTypes.number
128
154
  }), PropTypes.string]),
129
155
  legend: PropTypes.shape({
@@ -140,6 +166,8 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
140
166
  horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
141
167
  vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
142
168
  }),
169
+ slotProps: PropTypes.object,
170
+ slots: PropTypes.object,
143
171
  spacing: PropTypes.number
144
172
  }),
145
173
  margin: PropTypes.shape({
@@ -162,8 +190,13 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
162
190
  label: PropTypes.string,
163
191
  labelFontSize: PropTypes.number,
164
192
  position: PropTypes.oneOf(['left', 'right']),
193
+ slotProps: PropTypes.object,
194
+ slots: PropTypes.object,
165
195
  stroke: PropTypes.string,
166
196
  tickFontSize: PropTypes.number,
197
+ tickMaxStep: PropTypes.number,
198
+ tickMinStep: PropTypes.number,
199
+ tickNumber: PropTypes.number,
167
200
  tickSize: PropTypes.number
168
201
  }), PropTypes.string]),
169
202
  series: PropTypes.arrayOf(PropTypes.shape({
@@ -186,6 +219,16 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
186
219
  xAxisKey: PropTypes.string,
187
220
  yAxisKey: PropTypes.string
188
221
  })).isRequired,
222
+ /**
223
+ * The props used for each component slot.
224
+ * @default {}
225
+ */
226
+ slotProps: PropTypes.object,
227
+ /**
228
+ * Overridable component slots.
229
+ * @default {}
230
+ */
231
+ slots: PropTypes.object,
189
232
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
190
233
  title: PropTypes.string,
191
234
  tooltip: PropTypes.shape({
@@ -208,8 +251,13 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
208
251
  label: PropTypes.string,
209
252
  labelFontSize: PropTypes.number,
210
253
  position: PropTypes.oneOf(['bottom', 'top']),
254
+ slotProps: PropTypes.object,
255
+ slots: PropTypes.object,
211
256
  stroke: PropTypes.string,
212
257
  tickFontSize: PropTypes.number,
258
+ tickMaxStep: PropTypes.number,
259
+ tickMinStep: PropTypes.number,
260
+ tickNumber: PropTypes.number,
213
261
  tickSize: PropTypes.number
214
262
  }), PropTypes.string]),
215
263
  viewBox: PropTypes.shape({
@@ -232,15 +280,17 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
232
280
  label: PropTypes.string,
233
281
  labelFontSize: PropTypes.number,
234
282
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
235
- maxTicks: PropTypes.number,
236
283
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
237
- minTicks: PropTypes.number,
238
284
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
239
285
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
286
+ slotProps: PropTypes.object,
287
+ slots: PropTypes.object,
240
288
  stroke: PropTypes.string,
241
289
  tickFontSize: PropTypes.number,
290
+ tickMaxStep: PropTypes.number,
291
+ tickMinStep: PropTypes.number,
292
+ tickNumber: PropTypes.number,
242
293
  tickSize: PropTypes.number,
243
- tickSpacing: PropTypes.number,
244
294
  valueFormatter: PropTypes.func
245
295
  })),
246
296
  yAxis: PropTypes.arrayOf(PropTypes.shape({
@@ -256,15 +306,17 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
256
306
  label: PropTypes.string,
257
307
  labelFontSize: PropTypes.number,
258
308
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
259
- maxTicks: PropTypes.number,
260
309
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
261
- minTicks: PropTypes.number,
262
310
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
263
311
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
312
+ slotProps: PropTypes.object,
313
+ slots: PropTypes.object,
264
314
  stroke: PropTypes.string,
265
315
  tickFontSize: PropTypes.number,
316
+ tickMaxStep: PropTypes.number,
317
+ tickMinStep: PropTypes.number,
318
+ tickNumber: PropTypes.number,
266
319
  tickSize: PropTypes.number,
267
- tickSpacing: PropTypes.number,
268
320
  valueFormatter: PropTypes.func
269
321
  }))
270
322
  } : void 0;
@@ -1,10 +1,11 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["id", "classes", "color", "highlightScope"];
3
+ const _excluded = ["id", "classes", "color", "highlightScope", "slots", "slotProps"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import { color as d3Color } from 'd3-color';
7
7
  import composeClasses from '@mui/utils/composeClasses';
8
+ import { useSlotProps } from '@mui/base/utils';
8
9
  import generateUtilityClass from '@mui/utils/generateUtilityClass';
9
10
  import { styled } from '@mui/material/styles';
10
11
  import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
@@ -27,7 +28,7 @@ const useUtilityClasses = ownerState => {
27
28
  };
28
29
  return composeClasses(slots, getLineElementUtilityClass, classes);
29
30
  };
30
- const LineElementPath = styled('path', {
31
+ export const LineElementPath = styled('path', {
31
32
  name: 'MuiLineElement',
32
33
  slot: 'Root',
33
34
  overridesResolver: (_, styles) => styles.root
@@ -61,7 +62,9 @@ function LineElement(props) {
61
62
  id,
62
63
  classes: innerClasses,
63
64
  color,
64
- highlightScope
65
+ highlightScope,
66
+ slots,
67
+ slotProps
65
68
  } = props,
66
69
  other = _objectWithoutPropertiesLoose(props, _excluded);
67
70
  const getInteractionItemProps = useInteractionItemProps(highlightScope);
@@ -84,13 +87,19 @@ function LineElement(props) {
84
87
  isHighlighted
85
88
  };
86
89
  const classes = useUtilityClasses(ownerState);
87
- return /*#__PURE__*/_jsx(LineElementPath, _extends({}, other, {
88
- ownerState: ownerState,
89
- className: classes.root
90
- }, getInteractionItemProps({
91
- type: 'line',
92
- seriesId: id
93
- })));
90
+ const Line = slots?.line ?? LineElementPath;
91
+ const lineProps = useSlotProps({
92
+ elementType: Line,
93
+ externalSlotProps: slotProps?.line,
94
+ additionalProps: _extends({}, other, getInteractionItemProps({
95
+ type: 'line',
96
+ seriesId: id
97
+ }), {
98
+ className: classes.root
99
+ }),
100
+ ownerState
101
+ });
102
+ return /*#__PURE__*/_jsx(Line, _extends({}, lineProps));
94
103
  }
95
104
  process.env.NODE_ENV !== "production" ? LineElement.propTypes = {
96
105
  // ----------------------------- Warning --------------------------------
@@ -101,6 +110,16 @@ process.env.NODE_ENV !== "production" ? LineElement.propTypes = {
101
110
  highlightScope: PropTypes.shape({
102
111
  faded: PropTypes.oneOf(['global', 'none', 'series']),
103
112
  highlighted: PropTypes.oneOf(['item', 'none', 'series'])
104
- })
113
+ }),
114
+ /**
115
+ * The props used for each component slot.
116
+ * @default {}
117
+ */
118
+ slotProps: PropTypes.object,
119
+ /**
120
+ * Overridable component slots.
121
+ * @default {}
122
+ */
123
+ slots: PropTypes.object
105
124
  } : void 0;
106
125
  export { LineElement };
@@ -1,5 +1,8 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["slots", "slotProps"];
2
4
  import * as React from 'react';
5
+ import PropTypes from 'prop-types';
3
6
  import { line as d3Line } from 'd3-shape';
4
7
  import { SeriesContext } from '../context/SeriesContextProvider';
5
8
  import { CartesianContext } from '../context/CartesianContextProvider';
@@ -7,7 +10,12 @@ import { LineElement } from './LineElement';
7
10
  import { getValueToPositionMapper } from '../hooks/useScale';
8
11
  import getCurveFactory from '../internals/getCurve';
9
12
  import { jsx as _jsx } from "react/jsx-runtime";
10
- export function LinePlot(props) {
13
+ function LinePlot(props) {
14
+ const {
15
+ slots,
16
+ slotProps
17
+ } = props,
18
+ other = _objectWithoutPropertiesLoose(props, _excluded);
11
19
  const seriesData = React.useContext(SeriesContext).line;
12
20
  const axisData = React.useContext(CartesianContext);
13
21
  if (seriesData === undefined) {
@@ -25,7 +33,7 @@ export function LinePlot(props) {
25
33
  } = axisData;
26
34
  const defaultXAxisId = xAxisIds[0];
27
35
  const defaultYAxisId = yAxisIds[0];
28
- return /*#__PURE__*/_jsx("g", _extends({}, props, {
36
+ return /*#__PURE__*/_jsx("g", _extends({}, other, {
29
37
  children: stackingGroups.flatMap(({
30
38
  ids: groupIds
31
39
  }) => {
@@ -42,18 +50,42 @@ export function LinePlot(props) {
42
50
  throw new Error(`Axis of id "${xAxisKey}" should have data property to be able to display a line plot`);
43
51
  }
44
52
  const linePath = d3Line().x(d => xScale(d.x)).y(d => yScale(d.y[1]));
53
+ if (process.env.NODE_ENV !== 'production') {
54
+ if (xData.length !== stackedData.length) {
55
+ throw new Error(`MUI: data length of the x axis (${xData.length} items) does not match length of series (${stackedData.length} items)`);
56
+ }
57
+ }
45
58
  const curve = getCurveFactory(series[seriesId].curve);
46
59
  const d3Data = xData?.map((x, index) => ({
47
60
  x,
48
- y: stackedData[index]
61
+ y: stackedData[index] ?? [0, 0]
49
62
  }));
50
63
  return /*#__PURE__*/_jsx(LineElement, {
51
64
  id: seriesId,
52
65
  d: linePath.curve(curve)(d3Data) || undefined,
53
66
  color: series[seriesId].color,
54
- highlightScope: series[seriesId].highlightScope
67
+ highlightScope: series[seriesId].highlightScope,
68
+ slots: slots,
69
+ slotProps: slotProps
55
70
  }, seriesId);
56
71
  });
57
72
  })
58
73
  }));
59
- }
74
+ }
75
+ process.env.NODE_ENV !== "production" ? LinePlot.propTypes = {
76
+ // ----------------------------- Warning --------------------------------
77
+ // | These PropTypes are generated from the TypeScript type definitions |
78
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
79
+ // ----------------------------------------------------------------------
80
+ /**
81
+ * The props used for each component slot.
82
+ * @default {}
83
+ */
84
+ slotProps: PropTypes.object,
85
+ /**
86
+ * Overridable component slots.
87
+ * @default {}
88
+ */
89
+ slots: PropTypes.object
90
+ } : void 0;
91
+ export { LinePlot };
@@ -1,13 +1,22 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["slots", "slotProps"];
2
4
  import * as React from 'react';
5
+ import PropTypes from 'prop-types';
3
6
  import { SeriesContext } from '../context/SeriesContextProvider';
4
7
  import { CartesianContext } from '../context/CartesianContextProvider';
5
8
  import { MarkElement } from './MarkElement';
6
9
  import { getValueToPositionMapper } from '../hooks/useScale';
7
10
  import { jsx as _jsx } from "react/jsx-runtime";
8
- export function MarkPlot(props) {
11
+ function MarkPlot(props) {
12
+ const {
13
+ slots,
14
+ slotProps
15
+ } = props,
16
+ other = _objectWithoutPropertiesLoose(props, _excluded);
9
17
  const seriesData = React.useContext(SeriesContext).line;
10
18
  const axisData = React.useContext(CartesianContext);
19
+ const Mark = slots?.mark ?? MarkElement;
11
20
  if (seriesData === undefined) {
12
21
  return null;
13
22
  }
@@ -23,7 +32,7 @@ export function MarkPlot(props) {
23
32
  } = axisData;
24
33
  const defaultXAxisId = xAxisIds[0];
25
34
  const defaultYAxisId = yAxisIds[0];
26
- return /*#__PURE__*/_jsx("g", _extends({}, props, {
35
+ return /*#__PURE__*/_jsx("g", _extends({}, other, {
27
36
  children: stackingGroups.flatMap(({
28
37
  ids: groupIds
29
38
  }) => {
@@ -64,7 +73,7 @@ export function MarkPlot(props) {
64
73
  x,
65
74
  y,
66
75
  index
67
- }) => /*#__PURE__*/_jsx(MarkElement, {
76
+ }) => /*#__PURE__*/_jsx(Mark, _extends({
68
77
  id: seriesId,
69
78
  dataIndex: index,
70
79
  shape: "circle",
@@ -72,8 +81,25 @@ export function MarkPlot(props) {
72
81
  x: x,
73
82
  y: y,
74
83
  highlightScope: series[seriesId].highlightScope
75
- }, `${seriesId}-${index}`));
84
+ }, slotProps?.mark), `${seriesId}-${index}`));
76
85
  });
77
86
  })
78
87
  }));
79
- }
88
+ }
89
+ process.env.NODE_ENV !== "production" ? MarkPlot.propTypes = {
90
+ // ----------------------------- Warning --------------------------------
91
+ // | These PropTypes are generated from the TypeScript type definitions |
92
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
93
+ // ----------------------------------------------------------------------
94
+ /**
95
+ * The props used for each component slot.
96
+ * @default {}
97
+ */
98
+ slotProps: PropTypes.object,
99
+ /**
100
+ * Overridable component slots.
101
+ * @default {}
102
+ */
103
+ slots: PropTypes.object
104
+ } : void 0;
105
+ export { MarkPlot };
@@ -35,7 +35,6 @@ const PieArcLabelRoot = styled('text', {
35
35
  theme
36
36
  }) => ({
37
37
  fill: theme.palette.text.primary,
38
- alignmentBaseline: 'baseline',
39
38
  textAnchor: 'middle'
40
39
  }));
41
40
  export default function PieArcLabel(props) {