@mui/x-charts 6.0.0-alpha.5 → 6.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 (163) hide show
  1. package/BarChart/BarChart.d.ts +18 -2
  2. package/BarChart/BarChart.js +74 -17
  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 +23 -4
  7. package/BarChart/formatter.js +23 -12
  8. package/CHANGELOG.md +154 -0
  9. package/ChartContainer/index.js +3 -0
  10. package/ChartsAxis/ChartsAxis.d.ts +11 -1
  11. package/ChartsAxis/ChartsAxis.js +51 -6
  12. package/ChartsLegend/ChartsLegend.d.ts +25 -2
  13. package/ChartsLegend/ChartsLegend.js +49 -17
  14. package/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
  15. package/ChartsTooltip/ChartsTooltipTable.d.ts +2 -9
  16. package/ChartsXAxis/ChartsXAxis.js +44 -9
  17. package/ChartsYAxis/ChartsYAxis.js +44 -9
  18. package/LineChart/AreaElement.d.ts +22 -0
  19. package/LineChart/AreaElement.js +31 -11
  20. package/LineChart/AreaPlot.d.ts +14 -1
  21. package/LineChart/AreaPlot.js +32 -5
  22. package/LineChart/LineChart.d.ts +20 -2
  23. package/LineChart/LineChart.js +76 -16
  24. package/LineChart/LineElement.d.ts +22 -0
  25. package/LineChart/LineElement.js +31 -10
  26. package/LineChart/LinePlot.d.ts +14 -1
  27. package/LineChart/LinePlot.js +38 -6
  28. package/LineChart/MarkElement.js +1 -1
  29. package/LineChart/MarkPlot.d.ts +24 -1
  30. package/LineChart/MarkPlot.js +30 -6
  31. package/LineChart/formatter.js +23 -12
  32. package/PieChart/PieArcLabel.js +0 -1
  33. package/PieChart/PieChart.d.ts +14 -2
  34. package/PieChart/PieChart.js +60 -13
  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 +64 -13
  39. package/ScatterChart/ScatterPlot.d.ts +24 -1
  40. package/ScatterChart/ScatterPlot.js +28 -4
  41. package/SparkLineChart/SparkLineChart.d.ts +73 -0
  42. package/SparkLineChart/SparkLineChart.js +218 -0
  43. package/SparkLineChart/index.d.ts +1 -0
  44. package/SparkLineChart/index.js +12 -0
  45. package/SparkLineChart/package.json +6 -0
  46. package/colorPalettes/colorPalettes.js +2 -2
  47. package/context/CartesianContextProvider.d.ts +3 -1
  48. package/context/CartesianContextProvider.js +50 -14
  49. package/context/SeriesContextProvider.d.ts +3 -2
  50. package/context/SeriesContextProvider.js +5 -3
  51. package/esm/BarChart/BarChart.js +77 -17
  52. package/esm/BarChart/BarElement.js +21 -11
  53. package/esm/BarChart/BarPlot.js +23 -4
  54. package/esm/BarChart/formatter.js +23 -12
  55. package/esm/ChartContainer/index.js +3 -0
  56. package/esm/ChartsAxis/ChartsAxis.js +51 -6
  57. package/esm/ChartsLegend/ChartsLegend.js +47 -14
  58. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
  59. package/esm/ChartsXAxis/ChartsXAxis.js +45 -9
  60. package/esm/ChartsYAxis/ChartsYAxis.js +45 -9
  61. package/esm/LineChart/AreaElement.js +31 -11
  62. package/esm/LineChart/AreaPlot.js +33 -5
  63. package/esm/LineChart/LineChart.js +79 -16
  64. package/esm/LineChart/LineElement.js +31 -11
  65. package/esm/LineChart/LinePlot.js +45 -9
  66. package/esm/LineChart/MarkElement.js +1 -1
  67. package/esm/LineChart/MarkPlot.js +31 -6
  68. package/esm/LineChart/formatter.js +23 -13
  69. package/esm/PieChart/PieArcLabel.js +0 -1
  70. package/esm/PieChart/PieChart.js +60 -13
  71. package/esm/PieChart/PiePlot.js +31 -6
  72. package/esm/ScatterChart/ScatterChart.js +64 -13
  73. package/esm/ScatterChart/ScatterPlot.js +29 -4
  74. package/esm/SparkLineChart/SparkLineChart.js +210 -0
  75. package/esm/SparkLineChart/index.js +1 -0
  76. package/esm/colorPalettes/colorPalettes.js +2 -2
  77. package/esm/context/CartesianContextProvider.js +50 -14
  78. package/esm/context/SeriesContextProvider.js +5 -3
  79. package/esm/hooks/useTicks.js +9 -6
  80. package/esm/index.js +1 -0
  81. package/esm/internals/components/AxisSharedComponents.js +10 -10
  82. package/esm/models/index.js +3 -1
  83. package/hooks/useTicks.d.ts +20 -5
  84. package/hooks/useTicks.js +9 -6
  85. package/index.d.ts +1 -0
  86. package/index.js +12 -1
  87. package/internals/components/AxisSharedComponents.d.ts +4 -4
  88. package/internals/components/AxisSharedComponents.js +15 -15
  89. package/internals/defaultizeColor.d.ts +4 -2
  90. package/legacy/BarChart/BarChart.js +75 -17
  91. package/legacy/BarChart/BarElement.js +20 -10
  92. package/legacy/BarChart/BarPlot.js +23 -4
  93. package/legacy/BarChart/formatter.js +23 -10
  94. package/legacy/ChartContainer/index.js +3 -0
  95. package/legacy/ChartsAxis/ChartsAxis.js +51 -6
  96. package/legacy/ChartsLegend/ChartsLegend.js +46 -15
  97. package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
  98. package/legacy/ChartsXAxis/ChartsXAxis.js +45 -9
  99. package/legacy/ChartsYAxis/ChartsYAxis.js +45 -9
  100. package/legacy/LineChart/AreaElement.js +30 -10
  101. package/legacy/LineChart/AreaPlot.js +31 -5
  102. package/legacy/LineChart/LineChart.js +77 -16
  103. package/legacy/LineChart/LineElement.js +30 -10
  104. package/legacy/LineChart/LinePlot.js +38 -6
  105. package/legacy/LineChart/MarkElement.js +1 -1
  106. package/legacy/LineChart/MarkPlot.js +29 -6
  107. package/legacy/LineChart/formatter.js +23 -11
  108. package/legacy/PieChart/PieArcLabel.js +0 -1
  109. package/legacy/PieChart/PieChart.js +60 -13
  110. package/legacy/PieChart/PiePlot.js +29 -6
  111. package/legacy/ScatterChart/ScatterChart.js +64 -13
  112. package/legacy/ScatterChart/ScatterPlot.js +27 -4
  113. package/legacy/SparkLineChart/SparkLineChart.js +214 -0
  114. package/legacy/SparkLineChart/index.js +1 -0
  115. package/legacy/colorPalettes/colorPalettes.js +2 -2
  116. package/legacy/context/CartesianContextProvider.js +59 -15
  117. package/legacy/context/SeriesContextProvider.js +6 -4
  118. package/legacy/hooks/useTicks.js +9 -9
  119. package/legacy/index.js +2 -1
  120. package/legacy/internals/components/AxisSharedComponents.js +10 -10
  121. package/legacy/models/index.js +3 -1
  122. package/models/axis.d.ts +34 -3
  123. package/models/index.d.ts +2 -0
  124. package/models/index.js +11 -0
  125. package/models/seriesType/bar.d.ts +8 -1
  126. package/models/seriesType/common.d.ts +2 -2
  127. package/models/seriesType/config.d.ts +4 -1
  128. package/models/seriesType/line.d.ts +8 -1
  129. package/modern/BarChart/BarChart.js +74 -17
  130. package/modern/BarChart/BarElement.js +20 -11
  131. package/modern/BarChart/BarPlot.js +23 -4
  132. package/modern/BarChart/formatter.js +23 -12
  133. package/modern/ChartContainer/index.js +3 -0
  134. package/modern/ChartsAxis/ChartsAxis.js +51 -6
  135. package/modern/ChartsLegend/ChartsLegend.js +46 -14
  136. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
  137. package/modern/ChartsXAxis/ChartsXAxis.js +44 -9
  138. package/modern/ChartsYAxis/ChartsYAxis.js +44 -9
  139. package/modern/LineChart/AreaElement.js +30 -11
  140. package/modern/LineChart/AreaPlot.js +33 -5
  141. package/modern/LineChart/LineChart.js +76 -16
  142. package/modern/LineChart/LineElement.js +30 -11
  143. package/modern/LineChart/LinePlot.js +39 -6
  144. package/modern/LineChart/MarkElement.js +1 -1
  145. package/modern/LineChart/MarkPlot.js +30 -6
  146. package/modern/LineChart/formatter.js +23 -13
  147. package/modern/PieChart/PieArcLabel.js +0 -1
  148. package/modern/PieChart/PieChart.js +60 -13
  149. package/modern/PieChart/PiePlot.js +30 -6
  150. package/modern/ScatterChart/ScatterChart.js +64 -13
  151. package/modern/ScatterChart/ScatterPlot.js +28 -4
  152. package/modern/SparkLineChart/SparkLineChart.js +210 -0
  153. package/modern/SparkLineChart/index.js +1 -0
  154. package/modern/colorPalettes/colorPalettes.js +2 -2
  155. package/modern/context/CartesianContextProvider.js +50 -14
  156. package/modern/context/SeriesContextProvider.js +5 -3
  157. package/modern/hooks/useTicks.js +9 -6
  158. package/modern/index.js +2 -1
  159. package/modern/internals/components/AxisSharedComponents.js +10 -10
  160. package/modern/models/index.js +3 -1
  161. package/package.json +4 -2
  162. package/themeAugmentation/components.d.ts +0 -10
  163. package/themeAugmentation/overrides.d.ts +0 -2
@@ -9,7 +9,7 @@ import { CartesianContext } from '../context/CartesianContextProvider';
9
9
  import { DrawingContext } from '../context/DrawingProvider';
10
10
  import useTicks from '../hooks/useTicks';
11
11
  import { getAxisUtilityClass } from '../ChartsAxis/axisClasses';
12
- import { Line, Tick, TickLabel, Label, AxisRoot } from '../internals/components/AxisSharedComponents';
12
+ import { ChartsLine, ChartsTick, ChartsTickLabel, ChartsLabel, AxisRoot } from '../internals/components/AxisSharedComponents';
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { jsxs as _jsxs } from "react/jsx-runtime";
15
15
  const useUtilityClasses = ownerState => {
@@ -60,7 +60,9 @@ function ChartsXAxis(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 ChartsXAxis(inProps) {
83
85
  x: left + width / 2,
84
86
  y: positionSigne * (tickFontSize + tickSize + 10)
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(0, ${position === 'bottom' ? top + height : top})`,
88
94
  className: classes.root,
89
- children: [!disableLine && /*#__PURE__*/_jsx(Line, {
95
+ children: [!disableLine && /*#__PURE__*/_jsx(Line, _extends({
90
96
  x1: xScale.range()[0],
91
97
  x2: xScale.range()[1],
92
98
  className: classes.line
93
- }), xTicks.map(({
99
+ }, slotProps?.axisLine)), xTicks.map(({
94
100
  formattedValue,
95
101
  offset,
96
102
  labelOffset
@@ -100,26 +106,28 @@ function ChartsXAxis(inProps) {
100
106
  return /*#__PURE__*/_jsxs("g", {
101
107
  transform: `translate(${offset}, 0)`,
102
108
  className: classes.tickContainer,
103
- children: [!disableTicks && /*#__PURE__*/_jsx(Tick, {
109
+ children: [!disableTicks && /*#__PURE__*/_jsx(Tick, _extends({
104
110
  y2: 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
115
- })]
122
+ }))]
116
123
  }, index);
117
124
  }), label && /*#__PURE__*/_jsx(Label, _extends({}, labelRefPoint, {
118
125
  sx: {
119
126
  fontSize: labelFontSize,
120
127
  transformOrigin: `${labelRefPoint.x}px ${labelRefPoint.y}px`
121
128
  },
122
- className: classes.label,
129
+ className: classes.label
130
+ }, slotProps?.axisLabel, {
123
131
  children: label
124
132
  }))]
125
133
  });
@@ -165,6 +173,16 @@ process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
165
173
  * Position of the axis.
166
174
  */
167
175
  position: PropTypes.oneOf(['bottom', 'top']),
176
+ /**
177
+ * The props used for each component slot.
178
+ * @default {}
179
+ */
180
+ slotProps: PropTypes.object,
181
+ /**
182
+ * Overridable component slots.
183
+ * @default {}
184
+ */
185
+ slots: PropTypes.object,
168
186
  /**
169
187
  * The stroke color of the axis line.
170
188
  * @default 'currentColor'
@@ -175,6 +193,23 @@ process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
175
193
  * @default 12
176
194
  */
177
195
  tickFontSize: PropTypes.number,
196
+ /**
197
+ * Maximal step between two ticks.
198
+ * When using time data, the value is assumed to be in ms.
199
+ * Not supported by categorical axis (band, points).
200
+ */
201
+ tickMaxStep: PropTypes.number,
202
+ /**
203
+ * Maximal step between two ticks.
204
+ * When using time data, the value is assumed to be in ms.
205
+ * Not supported by categorical axis (band, points).
206
+ */
207
+ tickMinStep: PropTypes.number,
208
+ /**
209
+ * The number of ticks. This number is not guaranted.
210
+ * Not supported by categorical axis (band, points).
211
+ */
212
+ tickNumber: PropTypes.number,
178
213
  /**
179
214
  * The size of the ticks.
180
215
  * @default 6
@@ -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,4 +1,8 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["slots", "slotProps"];
1
4
  import * as React from 'react';
5
+ import PropTypes from 'prop-types';
2
6
  import { area as d3Area } from 'd3-shape';
3
7
  import { SeriesContext } from '../context/SeriesContextProvider';
4
8
  import { CartesianContext } from '../context/CartesianContextProvider';
@@ -6,7 +10,12 @@ import { AreaElement } from './AreaElement';
6
10
  import { getValueToPositionMapper } from '../hooks/useScale';
7
11
  import getCurveFactory from '../internals/getCurve';
8
12
  import { jsx as _jsx } from "react/jsx-runtime";
9
- export function AreaPlot() {
13
+ function AreaPlot(props) {
14
+ const {
15
+ slots,
16
+ slotProps
17
+ } = props,
18
+ other = _objectWithoutPropertiesLoose(props, _excluded);
10
19
  const seriesData = React.useContext(SeriesContext).line;
11
20
  const axisData = React.useContext(CartesianContext);
12
21
  if (seriesData === undefined) {
@@ -24,7 +33,7 @@ export function AreaPlot() {
24
33
  } = axisData;
25
34
  const defaultXAxisId = xAxisIds[0];
26
35
  const defaultYAxisId = yAxisIds[0];
27
- return /*#__PURE__*/_jsx("g", {
36
+ return /*#__PURE__*/_jsx("g", _extends({}, other, {
28
37
  children: stackingGroups.flatMap(({
29
38
  ids: groupIds
30
39
  }) => {
@@ -50,9 +59,28 @@ export function AreaPlot() {
50
59
  id: seriesId,
51
60
  d: areaPath.curve(curve)(d3Data) || undefined,
52
61
  color: series[seriesId].color,
53
- highlightScope: series[seriesId].highlightScope
62
+ highlightScope: series[seriesId].highlightScope,
63
+ slots: slots,
64
+ slotProps: slotProps
54
65
  }, seriesId);
55
66
  });
56
67
  })
57
- });
58
- }
68
+ }));
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 };
@@ -23,6 +23,7 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
23
23
  height,
24
24
  margin,
25
25
  colors,
26
+ dataset,
26
27
  sx,
27
28
  tooltip,
28
29
  axisHighlight = {
@@ -33,7 +34,9 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
33
34
  leftAxis,
34
35
  rightAxis,
35
36
  bottomAxis,
36
- children
37
+ children,
38
+ slots,
39
+ slotProps
37
40
  } = props;
38
41
  const id = useId();
39
42
  const clipPathId = `${id}-clip-path`;
@@ -49,22 +52,37 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
49
52
  id: DEFAULT_X_AXIS_KEY,
50
53
  scaleType: 'point',
51
54
  data: Array.from({
52
- length: Math.max(...series.map(s => s.data.length))
55
+ length: Math.max(...series.map(s => (s.data ?? dataset ?? []).length))
53
56
  }, (_, index) => index)
54
57
  }],
55
58
  yAxis: yAxis,
56
59
  colors: colors,
60
+ dataset: dataset,
57
61
  sx: sx,
58
62
  disableAxisListener: tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none',
59
63
  children: [/*#__PURE__*/_jsxs("g", {
60
64
  clipPath: `url(#${clipPathId})`,
61
- 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
+ })]
62
72
  }), /*#__PURE__*/_jsx(ChartsAxis, {
63
73
  topAxis: topAxis,
64
74
  leftAxis: leftAxis,
65
75
  rightAxis: rightAxis,
66
- bottomAxis: bottomAxis
67
- }), /*#__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, {
68
86
  id: clipPathId
69
87
  }), children]
70
88
  });
@@ -92,8 +110,13 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
92
110
  label: PropTypes.string,
93
111
  labelFontSize: PropTypes.number,
94
112
  position: PropTypes.oneOf(['bottom', 'top']),
113
+ slotProps: PropTypes.object,
114
+ slots: PropTypes.object,
95
115
  stroke: PropTypes.string,
96
116
  tickFontSize: PropTypes.number,
117
+ tickMaxStep: PropTypes.number,
118
+ tickMinStep: PropTypes.number,
119
+ tickNumber: PropTypes.number,
97
120
  tickSize: PropTypes.number
98
121
  }), PropTypes.string]),
99
122
  children: PropTypes.node,
@@ -102,6 +125,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
102
125
  * Color palette used to colorize multiple series.
103
126
  */
104
127
  colors: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.func]),
128
+ dataset: PropTypes.arrayOf(PropTypes.object),
105
129
  desc: PropTypes.string,
106
130
  disableAxisListener: PropTypes.bool,
107
131
  height: PropTypes.number,
@@ -119,8 +143,13 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
119
143
  label: PropTypes.string,
120
144
  labelFontSize: PropTypes.number,
121
145
  position: PropTypes.oneOf(['left', 'right']),
146
+ slotProps: PropTypes.object,
147
+ slots: PropTypes.object,
122
148
  stroke: PropTypes.string,
123
149
  tickFontSize: PropTypes.number,
150
+ tickMaxStep: PropTypes.number,
151
+ tickMinStep: PropTypes.number,
152
+ tickNumber: PropTypes.number,
124
153
  tickSize: PropTypes.number
125
154
  }), PropTypes.string]),
126
155
  legend: PropTypes.shape({
@@ -137,6 +166,8 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
137
166
  horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
138
167
  vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
139
168
  }),
169
+ slotProps: PropTypes.object,
170
+ slots: PropTypes.object,
140
171
  spacing: PropTypes.number
141
172
  }),
142
173
  margin: PropTypes.shape({
@@ -159,15 +190,21 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
159
190
  label: PropTypes.string,
160
191
  labelFontSize: PropTypes.number,
161
192
  position: PropTypes.oneOf(['left', 'right']),
193
+ slotProps: PropTypes.object,
194
+ slots: PropTypes.object,
162
195
  stroke: PropTypes.string,
163
196
  tickFontSize: PropTypes.number,
197
+ tickMaxStep: PropTypes.number,
198
+ tickMinStep: PropTypes.number,
199
+ tickNumber: PropTypes.number,
164
200
  tickSize: PropTypes.number
165
201
  }), PropTypes.string]),
166
202
  series: PropTypes.arrayOf(PropTypes.shape({
167
203
  area: PropTypes.bool,
168
204
  color: PropTypes.string,
169
205
  curve: PropTypes.oneOf(['catmullRom', 'linear', 'monotoneX', 'monotoneY', 'natural', 'step', 'stepAfter', 'stepBefore']),
170
- data: PropTypes.arrayOf(PropTypes.number).isRequired,
206
+ data: PropTypes.arrayOf(PropTypes.number),
207
+ dataKey: PropTypes.string,
171
208
  highlightScope: PropTypes.shape({
172
209
  faded: PropTypes.oneOf(['global', 'none', 'series']),
173
210
  highlighted: PropTypes.oneOf(['item', 'none', 'series'])
@@ -182,6 +219,16 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
182
219
  xAxisKey: PropTypes.string,
183
220
  yAxisKey: PropTypes.string
184
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,
185
232
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
186
233
  title: PropTypes.string,
187
234
  tooltip: PropTypes.shape({
@@ -204,8 +251,13 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
204
251
  label: PropTypes.string,
205
252
  labelFontSize: PropTypes.number,
206
253
  position: PropTypes.oneOf(['bottom', 'top']),
254
+ slotProps: PropTypes.object,
255
+ slots: PropTypes.object,
207
256
  stroke: PropTypes.string,
208
257
  tickFontSize: PropTypes.number,
258
+ tickMaxStep: PropTypes.number,
259
+ tickMinStep: PropTypes.number,
260
+ tickNumber: PropTypes.number,
209
261
  tickSize: PropTypes.number
210
262
  }), PropTypes.string]),
211
263
  viewBox: PropTypes.shape({
@@ -219,44 +271,52 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
219
271
  axisId: PropTypes.string,
220
272
  classes: PropTypes.object,
221
273
  data: PropTypes.array,
274
+ dataKey: PropTypes.string,
222
275
  disableLine: PropTypes.bool,
223
276
  disableTicks: PropTypes.bool,
224
277
  fill: PropTypes.string,
278
+ hideTooltip: PropTypes.bool,
225
279
  id: PropTypes.string,
226
280
  label: PropTypes.string,
227
281
  labelFontSize: PropTypes.number,
228
- max: PropTypes.number,
229
- maxTicks: PropTypes.number,
230
- min: PropTypes.number,
231
- minTicks: PropTypes.number,
282
+ max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
283
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
232
284
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
233
285
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
286
+ slotProps: PropTypes.object,
287
+ slots: PropTypes.object,
234
288
  stroke: PropTypes.string,
235
289
  tickFontSize: PropTypes.number,
290
+ tickMaxStep: PropTypes.number,
291
+ tickMinStep: PropTypes.number,
292
+ tickNumber: PropTypes.number,
236
293
  tickSize: PropTypes.number,
237
- tickSpacing: PropTypes.number,
238
294
  valueFormatter: PropTypes.func
239
295
  })),
240
296
  yAxis: PropTypes.arrayOf(PropTypes.shape({
241
297
  axisId: PropTypes.string,
242
298
  classes: PropTypes.object,
243
299
  data: PropTypes.array,
300
+ dataKey: PropTypes.string,
244
301
  disableLine: PropTypes.bool,
245
302
  disableTicks: PropTypes.bool,
246
303
  fill: PropTypes.string,
304
+ hideTooltip: PropTypes.bool,
247
305
  id: PropTypes.string,
248
306
  label: PropTypes.string,
249
307
  labelFontSize: PropTypes.number,
250
- max: PropTypes.number,
251
- maxTicks: PropTypes.number,
252
- min: PropTypes.number,
253
- minTicks: PropTypes.number,
308
+ max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
309
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
254
310
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
255
311
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
312
+ slotProps: PropTypes.object,
313
+ slots: PropTypes.object,
256
314
  stroke: PropTypes.string,
257
315
  tickFontSize: PropTypes.number,
316
+ tickMaxStep: PropTypes.number,
317
+ tickMinStep: PropTypes.number,
318
+ tickNumber: PropTypes.number,
258
319
  tickSize: PropTypes.number,
259
- tickSpacing: PropTypes.number,
260
320
  valueFormatter: PropTypes.func
261
321
  }))
262
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 };