@mui/x-charts 6.19.1 → 6.19.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/BarChart/BarChart.js +12 -9
  2. package/BarChart/BarElement.d.ts +43 -23
  3. package/BarChart/BarElement.js +1 -0
  4. package/BarChart/BarPlot.js +9 -10
  5. package/CHANGELOG.md +140 -0
  6. package/ChartsAxis/ChartsAxis.js +4 -4
  7. package/ChartsLegend/ChartsLegend.d.ts +5 -2
  8. package/ChartsLegend/ChartsLegend.js +36 -1
  9. package/ChartsReferenceLine/ChartsReferenceLine.js +8 -4
  10. package/ChartsReferenceLine/common.d.ts +2 -1
  11. package/ChartsSurface.d.ts +2 -2
  12. package/ChartsSurface.js +33 -1
  13. package/ChartsTooltip/ChartsAxisTooltipContent.js +6 -58
  14. package/ChartsTooltip/ChartsItemTooltipContent.js +18 -4
  15. package/ChartsTooltip/ChartsTooltipTable.d.ts +1 -1
  16. package/ChartsTooltip/ChartsTooltipTable.js +2 -0
  17. package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +4 -56
  18. package/ChartsTooltip/DefaultChartsItemTooltipContent.js +17 -3
  19. package/ChartsXAxis/ChartsXAxis.js +13 -9
  20. package/ChartsYAxis/ChartsYAxis.js +1 -1
  21. package/LineChart/AreaElement.d.ts +7 -4
  22. package/LineChart/AreaElement.js +1 -0
  23. package/LineChart/LineChart.d.ts +1 -0
  24. package/LineChart/LineChart.js +13 -9
  25. package/LineChart/LineElement.d.ts +7 -4
  26. package/LineChart/LineElement.js +1 -0
  27. package/LineChart/LineHighlightElement.d.ts +3 -2
  28. package/LineChart/LineHighlightElement.js +2 -1
  29. package/LineChart/MarkElement.d.ts +3 -2
  30. package/LineChart/MarkElement.js +1 -0
  31. package/PieChart/PieArc.d.ts +3 -2
  32. package/PieChart/PieArc.js +1 -0
  33. package/PieChart/PieArcLabel.d.ts +3 -2
  34. package/PieChart/PieArcLabel.js +1 -0
  35. package/PieChart/PieArcLabelPlot.d.ts +5 -0
  36. package/PieChart/PieArcLabelPlot.js +3 -1
  37. package/PieChart/PieArcPlot.d.ts +5 -0
  38. package/PieChart/PieArcPlot.js +2 -1
  39. package/PieChart/PieChart.d.ts +14 -2
  40. package/PieChart/PieChart.js +14 -11
  41. package/ScatterChart/Scatter.js +1 -1
  42. package/ScatterChart/ScatterChart.js +12 -9
  43. package/SparkLineChart/SparkLineChart.d.ts +15 -1
  44. package/SparkLineChart/SparkLineChart.js +11 -3
  45. package/context/CartesianContextProvider.d.ts +1 -1
  46. package/context/CartesianContextProvider.js +15 -12
  47. package/context/DrawingProvider.d.ts +1 -1
  48. package/context/DrawingProvider.js +8 -7
  49. package/context/HighlightProvider.d.ts +2 -2
  50. package/context/HighlightProvider.js +4 -3
  51. package/context/InteractionProvider.d.ts +4 -4
  52. package/context/InteractionProvider.js +4 -3
  53. package/context/SeriesContextProvider.d.ts +3 -1
  54. package/context/SeriesContextProvider.js +7 -6
  55. package/esm/BarChart/BarChart.js +12 -9
  56. package/esm/BarChart/BarElement.js +1 -0
  57. package/esm/BarChart/BarPlot.js +8 -10
  58. package/esm/ChartsAxis/ChartsAxis.js +4 -4
  59. package/esm/ChartsLegend/ChartsLegend.js +38 -2
  60. package/esm/ChartsReferenceLine/ChartsReferenceLine.js +8 -4
  61. package/esm/ChartsSurface.js +35 -2
  62. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +6 -58
  63. package/esm/ChartsTooltip/ChartsItemTooltipContent.js +18 -4
  64. package/esm/ChartsTooltip/ChartsTooltipTable.js +2 -0
  65. package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +4 -56
  66. package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +17 -3
  67. package/esm/ChartsXAxis/ChartsXAxis.js +13 -9
  68. package/esm/ChartsYAxis/ChartsYAxis.js +1 -1
  69. package/esm/LineChart/AreaElement.js +1 -0
  70. package/esm/LineChart/LineChart.js +13 -9
  71. package/esm/LineChart/LineElement.js +1 -0
  72. package/esm/LineChart/LineHighlightElement.js +2 -1
  73. package/esm/LineChart/MarkElement.js +1 -0
  74. package/esm/PieChart/PieArc.js +1 -0
  75. package/esm/PieChart/PieArcLabel.js +1 -0
  76. package/esm/PieChart/PieArcLabelPlot.js +3 -1
  77. package/esm/PieChart/PieArcPlot.js +2 -1
  78. package/esm/PieChart/PieChart.js +14 -11
  79. package/esm/ScatterChart/Scatter.js +1 -1
  80. package/esm/ScatterChart/ScatterChart.js +12 -9
  81. package/esm/SparkLineChart/SparkLineChart.js +11 -3
  82. package/esm/context/CartesianContextProvider.js +15 -12
  83. package/esm/context/DrawingProvider.js +8 -7
  84. package/esm/context/HighlightProvider.js +6 -4
  85. package/esm/context/InteractionProvider.js +6 -4
  86. package/esm/context/SeriesContextProvider.js +9 -7
  87. package/esm/hooks/useDrawingArea.js +7 -3
  88. package/esm/index.js +2 -0
  89. package/hooks/useDrawingArea.d.ts +2 -0
  90. package/hooks/useDrawingArea.js +7 -3
  91. package/index.d.ts +2 -0
  92. package/index.js +23 -1
  93. package/internals/defaultizeColor.d.ts +15 -15
  94. package/internals/defaultizeValueFormatter.d.ts +4 -7
  95. package/internals/stackSeries.d.ts +4 -7
  96. package/legacy/BarChart/BarChart.js +12 -9
  97. package/legacy/BarChart/BarElement.js +1 -0
  98. package/legacy/BarChart/BarPlot.js +10 -10
  99. package/legacy/ChartsAxis/ChartsAxis.js +4 -4
  100. package/legacy/ChartsLegend/ChartsLegend.js +38 -2
  101. package/legacy/ChartsReferenceLine/ChartsReferenceLine.js +6 -4
  102. package/legacy/ChartsReferenceLine/common.js +3 -4
  103. package/legacy/ChartsSurface.js +35 -2
  104. package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +6 -58
  105. package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +18 -4
  106. package/legacy/ChartsTooltip/ChartsTooltipTable.js +8 -7
  107. package/legacy/ChartsTooltip/DefaultChartsAxisTooltipContent.js +4 -56
  108. package/legacy/ChartsTooltip/DefaultChartsItemTooltipContent.js +17 -3
  109. package/legacy/ChartsXAxis/ChartsXAxis.js +12 -8
  110. package/legacy/ChartsYAxis/ChartsYAxis.js +1 -1
  111. package/legacy/LineChart/AreaElement.js +1 -0
  112. package/legacy/LineChart/LineChart.js +13 -9
  113. package/legacy/LineChart/LineElement.js +1 -0
  114. package/legacy/LineChart/LineHighlightElement.js +2 -1
  115. package/legacy/LineChart/MarkElement.js +1 -0
  116. package/legacy/PieChart/PieArc.js +1 -0
  117. package/legacy/PieChart/PieArcLabel.js +1 -0
  118. package/legacy/PieChart/PieArcLabelPlot.js +3 -1
  119. package/legacy/PieChart/PieArcPlot.js +2 -1
  120. package/legacy/PieChart/PieChart.js +14 -11
  121. package/legacy/ScatterChart/Scatter.js +1 -1
  122. package/legacy/ScatterChart/ScatterChart.js +12 -9
  123. package/legacy/SparkLineChart/SparkLineChart.js +11 -3
  124. package/legacy/context/CartesianContextProvider.js +23 -21
  125. package/legacy/context/DrawingProvider.js +6 -6
  126. package/legacy/context/HighlightProvider.js +4 -3
  127. package/legacy/context/InteractionProvider.js +4 -3
  128. package/legacy/context/SeriesContextProvider.js +8 -7
  129. package/legacy/hooks/useDrawingArea.js +7 -3
  130. package/legacy/index.js +3 -1
  131. package/legacy/internals/components/AxisSharedComponents.js +5 -6
  132. package/models/axis.d.ts +7 -2
  133. package/models/seriesType/common.d.ts +2 -1
  134. package/models/seriesType/config.d.ts +7 -12
  135. package/models/seriesType/line.d.ts +2 -2
  136. package/models/seriesType/pie.d.ts +8 -3
  137. package/models/seriesType/scatter.d.ts +5 -2
  138. package/modern/BarChart/BarChart.js +12 -9
  139. package/modern/BarChart/BarElement.js +1 -0
  140. package/modern/BarChart/BarPlot.js +8 -10
  141. package/modern/ChartsAxis/ChartsAxis.js +4 -4
  142. package/modern/ChartsLegend/ChartsLegend.js +38 -2
  143. package/modern/ChartsReferenceLine/ChartsReferenceLine.js +8 -4
  144. package/modern/ChartsSurface.js +35 -2
  145. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +6 -58
  146. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +18 -4
  147. package/modern/ChartsTooltip/ChartsTooltipTable.js +2 -0
  148. package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +4 -56
  149. package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +17 -3
  150. package/modern/ChartsXAxis/ChartsXAxis.js +13 -9
  151. package/modern/ChartsYAxis/ChartsYAxis.js +1 -1
  152. package/modern/LineChart/AreaElement.js +1 -0
  153. package/modern/LineChart/LineChart.js +13 -9
  154. package/modern/LineChart/LineElement.js +1 -0
  155. package/modern/LineChart/LineHighlightElement.js +2 -1
  156. package/modern/LineChart/MarkElement.js +1 -0
  157. package/modern/PieChart/PieArc.js +1 -0
  158. package/modern/PieChart/PieArcLabel.js +1 -0
  159. package/modern/PieChart/PieArcLabelPlot.js +3 -1
  160. package/modern/PieChart/PieArcPlot.js +2 -1
  161. package/modern/PieChart/PieChart.js +14 -11
  162. package/modern/ScatterChart/Scatter.js +1 -1
  163. package/modern/ScatterChart/ScatterChart.js +12 -9
  164. package/modern/SparkLineChart/SparkLineChart.js +11 -3
  165. package/modern/context/CartesianContextProvider.js +15 -12
  166. package/modern/context/DrawingProvider.js +8 -7
  167. package/modern/context/HighlightProvider.js +6 -4
  168. package/modern/context/InteractionProvider.js +6 -4
  169. package/modern/context/SeriesContextProvider.js +9 -7
  170. package/modern/hooks/useDrawingArea.js +7 -3
  171. package/modern/index.js +3 -1
  172. package/package.json +1 -1
@@ -10,11 +10,12 @@ import { LinePlotSlotsComponent, LinePlotSlotComponentProps } from '../LineChart
10
10
  import { MarkPlotSlotsComponent, MarkPlotSlotComponentProps } from '../LineChart/MarkPlot';
11
11
  import { LineHighlightPlotSlotsComponent, LineHighlightPlotSlotComponentProps } from '../LineChart/LineHighlightPlot';
12
12
  import { BarPlotSlotsComponent, BarPlotSlotComponentProps } from '../BarChart/BarPlot';
13
+ import { CardinalDirections } from '../models/layout';
13
14
  export interface SparkLineChartSlotsComponent extends AreaPlotSlotsComponent, LinePlotSlotsComponent, MarkPlotSlotsComponent, LineHighlightPlotSlotsComponent, BarPlotSlotsComponent, ChartsTooltipSlotsComponent {
14
15
  }
15
16
  export interface SparkLineChartSlotComponentProps extends AreaPlotSlotComponentProps, LinePlotSlotComponentProps, MarkPlotSlotComponentProps, LineHighlightPlotSlotComponentProps, BarPlotSlotComponentProps, ChartsTooltipSlotComponentProps {
16
17
  }
17
- export interface SparkLineChartProps extends Omit<ResponsiveChartContainerProps, 'series' | 'xAxis' | 'yAxis'> {
18
+ export interface SparkLineChartProps extends Omit<ResponsiveChartContainerProps, 'series' | 'xAxis' | 'yAxis' | 'margin'> {
18
19
  /**
19
20
  * The xAxis configuration.
20
21
  * Notice it is a single configuration object, not an array of configuration.
@@ -35,6 +36,7 @@ export interface SparkLineChartProps extends Omit<ResponsiveChartContainerProps,
35
36
  * Formatter used by the tooltip.
36
37
  * @param {number} value The value to format.
37
38
  * @returns {string} the formatted value.
39
+ * @default (v: number) => v.toString()
38
40
  */
39
41
  valueFormatter?: (value: number) => string;
40
42
  /**
@@ -59,6 +61,18 @@ export interface SparkLineChartProps extends Omit<ResponsiveChartContainerProps,
59
61
  * @default 'linear'
60
62
  */
61
63
  curve?: LineSeriesType['curve'];
64
+ /**
65
+ * The margin between the SVG and the drawing area.
66
+ * It's used for leaving some space for extra information such as the x- and y-axis or legend.
67
+ * Accepts an object with the optional properties: `top`, `bottom`, `left`, and `right`.
68
+ * @default {
69
+ * top: 5,
70
+ * bottom: 5,
71
+ * left: 5,
72
+ * right: 5,
73
+ * }
74
+ */
75
+ margin?: Partial<CardinalDirections<number>>;
62
76
  /**
63
77
  * Overridable component slots.
64
78
  * @default {}
@@ -127,6 +127,7 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
127
127
  className: _propTypes.default.string,
128
128
  /**
129
129
  * Color palette used to colorize multiple series.
130
+ * @default blueberryTwilightPalette
130
131
  */
131
132
  colors: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.string), _propTypes.default.func]),
132
133
  /**
@@ -157,7 +158,12 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
157
158
  * The margin between the SVG and the drawing area.
158
159
  * It's used for leaving some space for extra information such as the x- and y-axis or legend.
159
160
  * Accepts an object with the optional properties: `top`, `bottom`, `left`, and `right`.
160
- * @default object Depends on the charts type.
161
+ * @default {
162
+ * top: 5,
163
+ * bottom: 5,
164
+ * left: 5,
165
+ * right: 5,
166
+ * }
161
167
  */
162
168
  margin: _propTypes.default.shape({
163
169
  bottom: _propTypes.default.number,
@@ -206,6 +212,7 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
206
212
  * Formatter used by the tooltip.
207
213
  * @param {number} value The value to format.
208
214
  * @returns {string} the formatted value.
215
+ * @default (v: number) => v.toString()
209
216
  */
210
217
  valueFormatter: _propTypes.default.func,
211
218
  viewBox: _propTypes.default.shape({
@@ -224,7 +231,7 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
224
231
  * Notice it is a single configuration object, not an array of configuration.
225
232
  */
226
233
  xAxis: _propTypes.default.shape({
227
- axisId: _propTypes.default.string,
234
+ axisId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
228
235
  classes: _propTypes.default.object,
229
236
  data: _propTypes.default.array,
230
237
  dataKey: _propTypes.default.string,
@@ -232,13 +239,14 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
232
239
  disableTicks: _propTypes.default.bool,
233
240
  fill: _propTypes.default.string,
234
241
  hideTooltip: _propTypes.default.bool,
235
- id: _propTypes.default.string,
242
+ id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
236
243
  label: _propTypes.default.string,
237
244
  labelFontSize: _propTypes.default.number,
238
245
  labelStyle: _propTypes.default.object,
239
246
  max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
240
247
  min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
241
248
  position: _propTypes.default.oneOf(['bottom', 'left', 'right', 'top']),
249
+ reverse: _propTypes.default.bool,
242
250
  scaleType: _propTypes.default.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
243
251
  slotProps: _propTypes.default.object,
244
252
  slots: _propTypes.default.object,
@@ -50,7 +50,7 @@ export declare const CartesianContext: React.Context<{
50
50
  *
51
51
  * - [CartesianContextProvider API](https://mui.com/x/api/charts/cartesian-context-provider/)
52
52
  */
53
- declare function CartesianContextProvider({ xAxis: inXAxis, yAxis: inYAxis, dataset, children, }: CartesianContextProviderProps): React.JSX.Element;
53
+ declare function CartesianContextProvider(props: CartesianContextProviderProps): React.JSX.Element;
54
54
  declare namespace CartesianContextProvider {
55
55
  var propTypes: any;
56
56
  }
@@ -48,12 +48,13 @@ const CartesianContext = exports.CartesianContext = /*#__PURE__*/React.createCon
48
48
  *
49
49
  * - [CartesianContextProvider API](https://mui.com/x/api/charts/cartesian-context-provider/)
50
50
  */
51
- function CartesianContextProvider({
52
- xAxis: inXAxis,
53
- yAxis: inYAxis,
54
- dataset,
55
- children
56
- }) {
51
+ function CartesianContextProvider(props) {
52
+ const {
53
+ xAxis: inXAxis,
54
+ yAxis: inYAxis,
55
+ dataset,
56
+ children
57
+ } = props;
57
58
  const formattedSeries = React.useContext(_SeriesContextProvider.SeriesContext);
58
59
  const drawingArea = React.useContext(_DrawingProvider.DrawingContext);
59
60
  const xAxis = React.useMemo(() => inXAxis?.map(axisConfig => {
@@ -116,7 +117,7 @@ function CartesianContextProvider({
116
117
  allXAxis.forEach((axis, axisIndex) => {
117
118
  const isDefaultAxis = axisIndex === 0;
118
119
  const [minData, maxData] = getAxisExtremum(axis, xExtremumGetters, isDefaultAxis);
119
- const range = [drawingArea.left, drawingArea.left + drawingArea.width];
120
+ const range = axis.reverse ? [drawingArea.left + drawingArea.width, drawingArea.left] : [drawingArea.left, drawingArea.left + drawingArea.width];
120
121
  if ((0, _axis.isBandScaleConfig)(axis)) {
121
122
  const categoryGapRatio = axis.categoryGapRatio ?? DEFAULT_CATEGORY_GAP_RATIO;
122
123
  const barGapRatio = axis.barGapRatio ?? DEFAULT_BAR_GAP_RATIO;
@@ -165,7 +166,7 @@ function CartesianContextProvider({
165
166
  allYAxis.forEach((axis, axisIndex) => {
166
167
  const isDefaultAxis = axisIndex === 0;
167
168
  const [minData, maxData] = getAxisExtremum(axis, yExtremumGetters, isDefaultAxis);
168
- const range = [drawingArea.top + drawingArea.height, drawingArea.top];
169
+ const range = axis.reverse ? [drawingArea.top, drawingArea.top + drawingArea.height] : [drawingArea.top + drawingArea.height, drawingArea.top];
169
170
  if ((0, _axis.isBandScaleConfig)(axis)) {
170
171
  const categoryGapRatio = axis.categoryGapRatio ?? DEFAULT_CATEGORY_GAP_RATIO;
171
172
  completedYAxis[axis.id] = (0, _extends2.default)({
@@ -234,7 +235,7 @@ process.env.NODE_ENV !== "production" ? CartesianContextProvider.propTypes = {
234
235
  * If not provided, a default axis config is used with id set to `DEFAULT_X_AXIS_KEY`.
235
236
  */
236
237
  xAxis: _propTypes.default.arrayOf(_propTypes.default.shape({
237
- axisId: _propTypes.default.string,
238
+ axisId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
238
239
  classes: _propTypes.default.object,
239
240
  data: _propTypes.default.array,
240
241
  dataKey: _propTypes.default.string,
@@ -242,13 +243,14 @@ process.env.NODE_ENV !== "production" ? CartesianContextProvider.propTypes = {
242
243
  disableTicks: _propTypes.default.bool,
243
244
  fill: _propTypes.default.string,
244
245
  hideTooltip: _propTypes.default.bool,
245
- id: _propTypes.default.string,
246
+ id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
246
247
  label: _propTypes.default.string,
247
248
  labelFontSize: _propTypes.default.number,
248
249
  labelStyle: _propTypes.default.object,
249
250
  max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
250
251
  min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
251
252
  position: _propTypes.default.oneOf(['bottom', 'left', 'right', 'top']),
253
+ reverse: _propTypes.default.bool,
252
254
  scaleType: _propTypes.default.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
253
255
  slotProps: _propTypes.default.object,
254
256
  slots: _propTypes.default.object,
@@ -268,7 +270,7 @@ process.env.NODE_ENV !== "production" ? CartesianContextProvider.propTypes = {
268
270
  * If not provided, a default axis config is used with id set to `DEFAULT_Y_AXIS_KEY`.
269
271
  */
270
272
  yAxis: _propTypes.default.arrayOf(_propTypes.default.shape({
271
- axisId: _propTypes.default.string,
273
+ axisId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
272
274
  classes: _propTypes.default.object,
273
275
  data: _propTypes.default.array,
274
276
  dataKey: _propTypes.default.string,
@@ -276,13 +278,14 @@ process.env.NODE_ENV !== "production" ? CartesianContextProvider.propTypes = {
276
278
  disableTicks: _propTypes.default.bool,
277
279
  fill: _propTypes.default.string,
278
280
  hideTooltip: _propTypes.default.bool,
279
- id: _propTypes.default.string,
281
+ id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
280
282
  label: _propTypes.default.string,
281
283
  labelFontSize: _propTypes.default.number,
282
284
  labelStyle: _propTypes.default.object,
283
285
  max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
284
286
  min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
285
287
  position: _propTypes.default.oneOf(['bottom', 'left', 'right', 'top']),
288
+ reverse: _propTypes.default.bool,
286
289
  scaleType: _propTypes.default.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
287
290
  slotProps: _propTypes.default.object,
288
291
  slots: _propTypes.default.object,
@@ -40,7 +40,7 @@ export declare const SVGContext: React.Context<React.RefObject<SVGSVGElement>>;
40
40
  *
41
41
  * - [DrawingProvider API](https://mui.com/x/api/charts/drawing-provider/)
42
42
  */
43
- declare function DrawingProvider({ width, height, margin, svgRef, children }: DrawingProviderProps): React.JSX.Element;
43
+ declare function DrawingProvider(props: DrawingProviderProps): React.JSX.Element;
44
44
  declare namespace DrawingProvider {
45
45
  var propTypes: any;
46
46
  }
@@ -34,13 +34,14 @@ const SVGContext = exports.SVGContext = /*#__PURE__*/React.createContext({
34
34
  *
35
35
  * - [DrawingProvider API](https://mui.com/x/api/charts/drawing-provider/)
36
36
  */
37
- function DrawingProvider({
38
- width,
39
- height,
40
- margin,
41
- svgRef,
42
- children
43
- }) {
37
+ function DrawingProvider(props) {
38
+ const {
39
+ width,
40
+ height,
41
+ margin,
42
+ svgRef,
43
+ children
44
+ } = props;
44
45
  const drawingArea = (0, _useChartDimensions.default)(width, height, margin);
45
46
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(SVGContext.Provider, {
46
47
  value: svgRef,
@@ -41,5 +41,5 @@ type HighlighState = {
41
41
  dispatch: React.Dispatch<HighlighActions>;
42
42
  };
43
43
  export declare const HighlighContext: React.Context<HighlighState>;
44
- export declare function HighlightProvider({ children }: HighlightProviderProps): React.JSX.Element;
45
- export {};
44
+ declare function HighlightProvider(props: HighlightProviderProps): React.JSX.Element;
45
+ export { HighlightProvider };
@@ -39,9 +39,10 @@ const dataReducer = (prevState, action) => {
39
39
  return prevState;
40
40
  }
41
41
  };
42
- function HighlightProvider({
43
- children
44
- }) {
42
+ function HighlightProvider(props) {
43
+ const {
44
+ children
45
+ } = props;
45
46
  const [data, dispatch] = React.useReducer(dataReducer, {
46
47
  item: null,
47
48
  scope: defaultScope
@@ -6,11 +6,11 @@ export interface InteractionProviderProps {
6
6
  export type ItemInteractionData<T extends ChartSeriesType> = ChartItemIdentifier<T>;
7
7
  export type AxisInteractionData = {
8
8
  x: null | {
9
- value: number | Date;
9
+ value: number | string | Date;
10
10
  index?: number;
11
11
  };
12
12
  y: null | {
13
- value: number | Date;
13
+ value: number | string | Date;
14
14
  index?: number;
15
15
  };
16
16
  };
@@ -36,5 +36,5 @@ type InteractionState = {
36
36
  dispatch: React.Dispatch<InteractionActions>;
37
37
  };
38
38
  export declare const InteractionContext: React.Context<InteractionState>;
39
- export declare function InteractionProvider({ children }: InteractionProviderProps): React.JSX.Element;
40
- export {};
39
+ declare function InteractionProvider(props: InteractionProviderProps): React.JSX.Element;
40
+ export { InteractionProvider };
@@ -41,9 +41,10 @@ const dataReducer = (prevState, action) => {
41
41
  return prevState;
42
42
  }
43
43
  };
44
- function InteractionProvider({
45
- children
46
- }) {
44
+ function InteractionProvider(props) {
45
+ const {
46
+ children
47
+ } = props;
47
48
  const [data, dispatch] = React.useReducer(dataReducer, {
48
49
  item: null,
49
50
  axis: {
@@ -12,6 +12,7 @@ export type SeriesContextProviderProps = {
12
12
  series: AllSeriesType[];
13
13
  /**
14
14
  * Color palette used to colorize multiple series.
15
+ * @default blueberryTwilightPalette
15
16
  */
16
17
  colors?: ChartsColorPalette;
17
18
  children: React.ReactNode;
@@ -20,4 +21,5 @@ export type FormattedSeries = {
20
21
  [type in ChartSeriesType]?: FormatterResult<type>;
21
22
  };
22
23
  export declare const SeriesContext: React.Context<FormattedSeries>;
23
- export declare function SeriesContextProvider({ series, dataset, colors, children, }: SeriesContextProviderProps): React.JSX.Element;
24
+ declare function SeriesContextProvider(props: SeriesContextProviderProps): React.JSX.Element;
25
+ export { SeriesContextProvider };
@@ -65,12 +65,13 @@ const formatSeries = (series, colors, dataset) => {
65
65
  });
66
66
  return formattedSeries;
67
67
  };
68
- function SeriesContextProvider({
69
- series,
70
- dataset,
71
- colors = _colorPalettes.blueberryTwilightPalette,
72
- children
73
- }) {
68
+ function SeriesContextProvider(props) {
69
+ const {
70
+ series,
71
+ dataset,
72
+ colors = _colorPalettes.blueberryTwilightPalette,
73
+ children
74
+ } = props;
74
75
  const theme = (0, _styles.useTheme)();
75
76
  const formattedSeries = React.useMemo(() => formatSeries(series, typeof colors === 'function' ? colors(theme.palette.mode) : colors, dataset), [series, colors, theme.palette.mode, dataset]);
76
77
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(SeriesContext.Provider, {
@@ -131,7 +131,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
131
131
  * @default xAxisIds[0] The id of the first provided axis
132
132
  */
133
133
  bottomAxis: PropTypes.oneOfType([PropTypes.shape({
134
- axisId: PropTypes.string,
134
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
135
135
  classes: PropTypes.object,
136
136
  disableLine: PropTypes.bool,
137
137
  disableTicks: PropTypes.bool,
@@ -156,6 +156,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
156
156
  className: PropTypes.string,
157
157
  /**
158
158
  * Color palette used to colorize multiple series.
159
+ * @default blueberryTwilightPalette
159
160
  */
160
161
  colors: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.func]),
161
162
  /**
@@ -181,7 +182,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
181
182
  * @default yAxisIds[0] The id of the first provided axis
182
183
  */
183
184
  leftAxis: PropTypes.oneOfType([PropTypes.shape({
184
- axisId: PropTypes.string,
185
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
185
186
  classes: PropTypes.object,
186
187
  disableLine: PropTypes.bool,
187
188
  disableTicks: PropTypes.bool,
@@ -234,7 +235,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
234
235
  * @default null
235
236
  */
236
237
  rightAxis: PropTypes.oneOfType([PropTypes.shape({
237
- axisId: PropTypes.string,
238
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
238
239
  classes: PropTypes.object,
239
240
  disableLine: PropTypes.bool,
240
241
  disableTicks: PropTypes.bool,
@@ -263,7 +264,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
263
264
  faded: PropTypes.oneOf(['global', 'none', 'series']),
264
265
  highlighted: PropTypes.oneOf(['item', 'none', 'series'])
265
266
  }),
266
- id: PropTypes.string,
267
+ id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
267
268
  label: PropTypes.string,
268
269
  layout: PropTypes.oneOf(['horizontal', 'vertical']),
269
270
  stack: PropTypes.string,
@@ -305,7 +306,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
305
306
  * @default null
306
307
  */
307
308
  topAxis: PropTypes.oneOfType([PropTypes.shape({
308
- axisId: PropTypes.string,
309
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
309
310
  classes: PropTypes.object,
310
311
  disableLine: PropTypes.bool,
311
312
  disableTicks: PropTypes.bool,
@@ -342,7 +343,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
342
343
  * If not provided, a default axis config is used with id set to `DEFAULT_X_AXIS_KEY`.
343
344
  */
344
345
  xAxis: PropTypes.arrayOf(PropTypes.shape({
345
- axisId: PropTypes.string,
346
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
346
347
  classes: PropTypes.object,
347
348
  data: PropTypes.array,
348
349
  dataKey: PropTypes.string,
@@ -350,13 +351,14 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
350
351
  disableTicks: PropTypes.bool,
351
352
  fill: PropTypes.string,
352
353
  hideTooltip: PropTypes.bool,
353
- id: PropTypes.string,
354
+ id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
354
355
  label: PropTypes.string,
355
356
  labelFontSize: PropTypes.number,
356
357
  labelStyle: PropTypes.object,
357
358
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
358
359
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
359
360
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
361
+ reverse: PropTypes.bool,
360
362
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
361
363
  slotProps: PropTypes.object,
362
364
  slots: PropTypes.object,
@@ -376,7 +378,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
376
378
  * If not provided, a default axis config is used with id set to `DEFAULT_Y_AXIS_KEY`.
377
379
  */
378
380
  yAxis: PropTypes.arrayOf(PropTypes.shape({
379
- axisId: PropTypes.string,
381
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
380
382
  classes: PropTypes.object,
381
383
  data: PropTypes.array,
382
384
  dataKey: PropTypes.string,
@@ -384,13 +386,14 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
384
386
  disableTicks: PropTypes.bool,
385
387
  fill: PropTypes.string,
386
388
  hideTooltip: PropTypes.bool,
387
- id: PropTypes.string,
389
+ id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
388
390
  label: PropTypes.string,
389
391
  labelFontSize: PropTypes.number,
390
392
  labelStyle: PropTypes.object,
391
393
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
392
394
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
393
395
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
396
+ reverse: PropTypes.bool,
394
397
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
395
398
  slotProps: PropTypes.object,
396
399
  slots: PropTypes.object,
@@ -103,6 +103,7 @@ process.env.NODE_ENV !== "production" ? BarElement.propTypes = {
103
103
  faded: PropTypes.oneOf(['global', 'none', 'series']),
104
104
  highlighted: PropTypes.oneOf(['item', 'none', 'series'])
105
105
  }),
106
+ id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
106
107
  /**
107
108
  * The props used for each component slot.
108
109
  * @default {}
@@ -9,7 +9,7 @@ import { CartesianContext } from '../context/CartesianContextProvider';
9
9
  import { BarElement } from './BarElement';
10
10
  import { isBandScaleConfig } from '../models/axis';
11
11
  import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from '../constants';
12
-
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
13
  /**
14
14
  * Solution of the equations
15
15
  * W = barWidth * N + offset * (N-1)
@@ -19,7 +19,6 @@ import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from '../constants';
19
19
  * @param gapRatio The ratio of the gap between bars over the bar width.
20
20
  * @returns The bar width and the offset between bars.
21
21
  */
22
- import { jsx as _jsx } from "react/jsx-runtime";
23
22
  function getBandSize({
24
23
  bandWidth: W,
25
24
  numberOfGroups: N,
@@ -104,20 +103,19 @@ const useCompletedData = () => {
104
103
  } = series[seriesId];
105
104
  return stackedData.map((values, dataIndex) => {
106
105
  var _xAxis$xAxisKey$data, _yAxis$yAxisKey$data;
107
- const bottom = Math.min(...values);
108
- const top = Math.max(...values);
106
+ const valueCoordinates = values.map(v => verticalLayout ? yScale(v) : xScale(v));
107
+ const minValueCoord = Math.min(...valueCoordinates);
108
+ const maxValueCoord = Math.max(...valueCoordinates);
109
109
  return {
110
- bottom,
111
- top,
112
110
  seriesId,
113
111
  dataIndex,
114
112
  layout: series[seriesId].layout,
115
- x: verticalLayout ? xScale((_xAxis$xAxisKey$data = xAxis[xAxisKey].data) == null ? void 0 : _xAxis$xAxisKey$data[dataIndex]) + barOffset : xScale(bottom),
116
- y: verticalLayout ? yScale(top) : yScale((_yAxis$yAxisKey$data = yAxis[yAxisKey].data) == null ? void 0 : _yAxis$yAxisKey$data[dataIndex]) + barOffset,
113
+ x: verticalLayout ? xScale((_xAxis$xAxisKey$data = xAxis[xAxisKey].data) == null ? void 0 : _xAxis$xAxisKey$data[dataIndex]) + barOffset : minValueCoord,
114
+ y: verticalLayout ? minValueCoord : yScale((_yAxis$yAxisKey$data = yAxis[yAxisKey].data) == null ? void 0 : _yAxis$yAxisKey$data[dataIndex]) + barOffset,
117
115
  xOrigin: xScale(0),
118
116
  yOrigin: yScale(0),
119
- height: verticalLayout ? Math.abs(yScale(bottom) - yScale(top)) : barWidth,
120
- width: verticalLayout ? barWidth : Math.abs(xScale(bottom) - xScale(top)),
117
+ height: verticalLayout ? maxValueCoord - minValueCoord : barWidth,
118
+ width: verticalLayout ? barWidth : maxValueCoord - minValueCoord,
121
119
  color,
122
120
  highlightScope: series[seriesId].highlightScope
123
121
  };
@@ -101,7 +101,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
101
101
  * @default xAxisIds[0] The id of the first provided axis
102
102
  */
103
103
  bottomAxis: PropTypes.oneOfType([PropTypes.shape({
104
- axisId: PropTypes.string,
104
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
105
105
  classes: PropTypes.object,
106
106
  disableLine: PropTypes.bool,
107
107
  disableTicks: PropTypes.bool,
@@ -128,7 +128,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
128
128
  * @default yAxisIds[0] The id of the first provided axis
129
129
  */
130
130
  leftAxis: PropTypes.oneOfType([PropTypes.shape({
131
- axisId: PropTypes.string,
131
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
132
132
  classes: PropTypes.object,
133
133
  disableLine: PropTypes.bool,
134
134
  disableTicks: PropTypes.bool,
@@ -155,7 +155,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
155
155
  * @default null
156
156
  */
157
157
  rightAxis: PropTypes.oneOfType([PropTypes.shape({
158
- axisId: PropTypes.string,
158
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
159
159
  classes: PropTypes.object,
160
160
  disableLine: PropTypes.bool,
161
161
  disableTicks: PropTypes.bool,
@@ -192,7 +192,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
192
192
  * @default null
193
193
  */
194
194
  topAxis: PropTypes.oneOfType([PropTypes.shape({
195
- axisId: PropTypes.string,
195
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
196
196
  classes: PropTypes.object,
197
197
  disableLine: PropTypes.bool,
198
198
  disableTicks: PropTypes.bool,
@@ -3,6 +3,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
3
3
  const _excluded = ["rotate", "dominantBaseline"],
4
4
  _excluded2 = ["label"];
5
5
  import * as React from 'react';
6
+ import PropTypes from 'prop-types';
6
7
  import { useSlotProps } from '@mui/base/utils';
7
8
  import { NoSsr } from '@mui/base/NoSsr';
8
9
  import { unstable_composeClasses as composeClasses } from '@mui/utils';
@@ -234,7 +235,7 @@ function DefaultChartsLegend(props) {
234
235
  })
235
236
  });
236
237
  }
237
- export function ChartsLegend(inProps) {
238
+ function ChartsLegend(inProps) {
238
239
  var _slots$legend;
239
240
  const props = useThemeProps({
240
241
  props: _extends({}, defaultProps, inProps),
@@ -270,4 +271,39 @@ export function ChartsLegend(inProps) {
270
271
  ownerState: {}
271
272
  });
272
273
  return /*#__PURE__*/_jsx(ChartLegendRender, _extends({}, chartLegendRenderProps));
273
- }
274
+ }
275
+ process.env.NODE_ENV !== "production" ? ChartsLegend.propTypes = {
276
+ // ----------------------------- Warning --------------------------------
277
+ // | These PropTypes are generated from the TypeScript type definitions |
278
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
279
+ // ----------------------------------------------------------------------
280
+ /**
281
+ * Override or extend the styles applied to the component.
282
+ */
283
+ classes: PropTypes.object,
284
+ /**
285
+ * The direction of the legend layout.
286
+ * The default depends on the chart.
287
+ */
288
+ direction: PropTypes.oneOf(['column', 'row']),
289
+ /**
290
+ * Set to true to hide the legend.
291
+ * @default false
292
+ */
293
+ hidden: PropTypes.bool,
294
+ position: PropTypes.shape({
295
+ horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
296
+ vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
297
+ }),
298
+ /**
299
+ * The props used for each component slot.
300
+ * @default {}
301
+ */
302
+ slotProps: PropTypes.object,
303
+ /**
304
+ * Overridable component slots.
305
+ * @default {}
306
+ */
307
+ slots: PropTypes.object
308
+ } : void 0;
309
+ export { ChartsLegend };
@@ -5,13 +5,17 @@ import { ChartsXReferenceLine } from './ChartsXReferenceLine';
5
5
  import { ChartsYReferenceLine } from './ChartsYReferenceLine';
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
7
7
  function ChartsReferenceLine(props) {
8
- if (props.x !== undefined && props.y !== undefined) {
8
+ const {
9
+ x,
10
+ y
11
+ } = props;
12
+ if (x !== undefined && y !== undefined) {
9
13
  throw new Error('MUI-X-Charts: The ChartsReferenceLine can not have both `x` and `y` props set.');
10
14
  }
11
- if (props.x === undefined && props.y === undefined) {
15
+ if (x === undefined && y === undefined) {
12
16
  throw new Error('MUI-X-Charts: The ChartsReferenceLine should have a value in `x` or `y` prop.');
13
17
  }
14
- if (props.x !== undefined) {
18
+ if (x !== undefined) {
15
19
  return /*#__PURE__*/_jsx(ChartsXReferenceLine, _extends({}, props));
16
20
  }
17
21
  return /*#__PURE__*/_jsx(ChartsYReferenceLine, _extends({}, props));
@@ -25,7 +29,7 @@ process.env.NODE_ENV !== "production" ? ChartsReferenceLine.propTypes = {
25
29
  * The id of the axis used for the reference value.
26
30
  * @default The `id` of the first defined axis.
27
31
  */
28
- axisId: PropTypes.string,
32
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
29
33
  /**
30
34
  * Override or extend the styles applied to the component.
31
35
  */
@@ -2,6 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
3
  const _excluded = ["children", "width", "height", "viewBox", "disableAxisListener", "className"];
4
4
  import { styled } from '@mui/material/styles';
5
+ import PropTypes from 'prop-types';
5
6
  import * as React from 'react';
6
7
  import { useAxisEvents } from './hooks/useAxisEvents';
7
8
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -10,7 +11,7 @@ const ChartChartsSurfaceStyles = styled('svg', {
10
11
  name: 'MuiChartsSurface',
11
12
  slot: 'Root'
12
13
  })(() => ({}));
13
- export const ChartsSurface = /*#__PURE__*/React.forwardRef(function ChartsSurface(props, ref) {
14
+ const ChartsSurface = /*#__PURE__*/React.forwardRef(function ChartsSurface(props, ref) {
14
15
  const {
15
16
  children,
16
17
  width,
@@ -38,4 +39,36 @@ export const ChartsSurface = /*#__PURE__*/React.forwardRef(function ChartsSurfac
38
39
  children: props.desc
39
40
  }), children]
40
41
  }));
41
- });
42
+ });
43
+ process.env.NODE_ENV !== "production" ? ChartsSurface.propTypes = {
44
+ // ----------------------------- Warning --------------------------------
45
+ // | These PropTypes are generated from the TypeScript type definitions |
46
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
47
+ // ----------------------------------------------------------------------
48
+ children: PropTypes.node,
49
+ className: PropTypes.string,
50
+ desc: PropTypes.string,
51
+ /**
52
+ * If `true`, the charts will not listen to the mouse move event.
53
+ * It might break interactive features, but will improve performance.
54
+ * @default false
55
+ */
56
+ disableAxisListener: PropTypes.bool,
57
+ /**
58
+ * The height of the chart in px.
59
+ */
60
+ height: PropTypes.number.isRequired,
61
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
62
+ title: PropTypes.string,
63
+ viewBox: PropTypes.shape({
64
+ height: PropTypes.number,
65
+ width: PropTypes.number,
66
+ x: PropTypes.number,
67
+ y: PropTypes.number
68
+ }),
69
+ /**
70
+ * The width of the chart in px.
71
+ */
72
+ width: PropTypes.number.isRequired
73
+ } : void 0;
74
+ export { ChartsSurface };