@mui/x-charts 6.19.3 → 6.19.5

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 (128) hide show
  1. package/BarChart/BarChart.js +11 -9
  2. package/BarChart/BarElement.d.ts +6 -3
  3. package/BarChart/BarElement.js +1 -0
  4. package/BarChart/BarPlot.js +9 -10
  5. package/CHANGELOG.md +117 -0
  6. package/ChartsAxis/ChartsAxis.js +4 -4
  7. package/ChartsLegend/ChartsLegend.js +0 -101
  8. package/ChartsReferenceLine/ChartsReferenceLine.js +1 -1
  9. package/ChartsReferenceLine/common.d.ts +2 -1
  10. package/ChartsTooltip/ChartsAxisTooltipContent.js +4 -4
  11. package/ChartsTooltip/ChartsItemTooltipContent.js +3 -3
  12. package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -2
  13. package/ChartsTooltip/DefaultChartsItemTooltipContent.js +2 -2
  14. package/ChartsXAxis/ChartsXAxis.js +13 -9
  15. package/ChartsYAxis/ChartsYAxis.js +1 -1
  16. package/LineChart/AreaElement.d.ts +7 -4
  17. package/LineChart/AreaElement.js +1 -0
  18. package/LineChart/LineChart.js +11 -9
  19. package/LineChart/LineElement.d.ts +7 -4
  20. package/LineChart/LineElement.js +1 -0
  21. package/LineChart/LineHighlightElement.d.ts +3 -2
  22. package/LineChart/LineHighlightElement.js +2 -1
  23. package/LineChart/MarkElement.d.ts +3 -2
  24. package/LineChart/MarkElement.js +1 -0
  25. package/PieChart/PieArc.d.ts +3 -2
  26. package/PieChart/PieArc.js +1 -0
  27. package/PieChart/PieArcLabel.d.ts +3 -2
  28. package/PieChart/PieArcLabel.js +1 -0
  29. package/PieChart/PieArcLabelPlot.js +1 -1
  30. package/PieChart/PieArcPlot.js +1 -1
  31. package/PieChart/PieChart.js +11 -9
  32. package/ScatterChart/Scatter.js +1 -1
  33. package/ScatterChart/ScatterChart.js +11 -9
  34. package/SparkLineChart/SparkLineChart.d.ts +7 -1
  35. package/SparkLineChart/SparkLineChart.js +14 -5
  36. package/context/CartesianContextProvider.js +8 -6
  37. package/context/InteractionProvider.d.ts +2 -2
  38. package/esm/BarChart/BarChart.js +11 -9
  39. package/esm/BarChart/BarElement.js +1 -0
  40. package/esm/BarChart/BarPlot.js +8 -10
  41. package/esm/ChartsAxis/ChartsAxis.js +4 -4
  42. package/esm/ChartsLegend/ChartsLegend.js +0 -101
  43. package/esm/ChartsReferenceLine/ChartsReferenceLine.js +1 -1
  44. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +4 -4
  45. package/esm/ChartsTooltip/ChartsItemTooltipContent.js +3 -3
  46. package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -2
  47. package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +2 -2
  48. package/esm/ChartsXAxis/ChartsXAxis.js +13 -9
  49. package/esm/ChartsYAxis/ChartsYAxis.js +1 -1
  50. package/esm/LineChart/AreaElement.js +1 -0
  51. package/esm/LineChart/LineChart.js +11 -9
  52. package/esm/LineChart/LineElement.js +1 -0
  53. package/esm/LineChart/LineHighlightElement.js +2 -1
  54. package/esm/LineChart/MarkElement.js +1 -0
  55. package/esm/PieChart/PieArc.js +1 -0
  56. package/esm/PieChart/PieArcLabel.js +1 -0
  57. package/esm/PieChart/PieArcLabelPlot.js +1 -1
  58. package/esm/PieChart/PieArcPlot.js +1 -1
  59. package/esm/PieChart/PieChart.js +11 -9
  60. package/esm/ScatterChart/Scatter.js +1 -1
  61. package/esm/ScatterChart/ScatterChart.js +11 -9
  62. package/esm/SparkLineChart/SparkLineChart.js +14 -5
  63. package/esm/context/CartesianContextProvider.js +8 -6
  64. package/index.js +1 -1
  65. package/internals/defaultizeColor.d.ts +15 -15
  66. package/internals/defaultizeValueFormatter.d.ts +4 -7
  67. package/internals/stackSeries.d.ts +4 -7
  68. package/legacy/BarChart/BarChart.js +11 -9
  69. package/legacy/BarChart/BarElement.js +1 -0
  70. package/legacy/BarChart/BarPlot.js +10 -10
  71. package/legacy/ChartsAxis/ChartsAxis.js +4 -4
  72. package/legacy/ChartsLegend/ChartsLegend.js +0 -101
  73. package/legacy/ChartsReferenceLine/ChartsReferenceLine.js +1 -1
  74. package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +4 -4
  75. package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +3 -3
  76. package/legacy/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -2
  77. package/legacy/ChartsTooltip/DefaultChartsItemTooltipContent.js +2 -2
  78. package/legacy/ChartsXAxis/ChartsXAxis.js +12 -8
  79. package/legacy/ChartsYAxis/ChartsYAxis.js +1 -1
  80. package/legacy/LineChart/AreaElement.js +1 -0
  81. package/legacy/LineChart/LineChart.js +11 -9
  82. package/legacy/LineChart/LineElement.js +1 -0
  83. package/legacy/LineChart/LineHighlightElement.js +2 -1
  84. package/legacy/LineChart/MarkElement.js +1 -0
  85. package/legacy/PieChart/PieArc.js +1 -0
  86. package/legacy/PieChart/PieArcLabel.js +1 -0
  87. package/legacy/PieChart/PieArcLabelPlot.js +1 -1
  88. package/legacy/PieChart/PieArcPlot.js +1 -1
  89. package/legacy/PieChart/PieChart.js +11 -9
  90. package/legacy/ScatterChart/Scatter.js +1 -1
  91. package/legacy/ScatterChart/ScatterChart.js +11 -9
  92. package/legacy/SparkLineChart/SparkLineChart.js +16 -6
  93. package/legacy/context/CartesianContextProvider.js +8 -6
  94. package/legacy/index.js +1 -1
  95. package/models/axis.d.ts +7 -2
  96. package/models/seriesType/common.d.ts +2 -1
  97. package/models/seriesType/config.d.ts +7 -12
  98. package/models/seriesType/line.d.ts +2 -2
  99. package/models/seriesType/pie.d.ts +7 -3
  100. package/models/seriesType/scatter.d.ts +5 -2
  101. package/modern/BarChart/BarChart.js +11 -9
  102. package/modern/BarChart/BarElement.js +1 -0
  103. package/modern/BarChart/BarPlot.js +8 -10
  104. package/modern/ChartsAxis/ChartsAxis.js +4 -4
  105. package/modern/ChartsLegend/ChartsLegend.js +0 -101
  106. package/modern/ChartsReferenceLine/ChartsReferenceLine.js +1 -1
  107. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +4 -4
  108. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +3 -3
  109. package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -2
  110. package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +2 -2
  111. package/modern/ChartsXAxis/ChartsXAxis.js +13 -9
  112. package/modern/ChartsYAxis/ChartsYAxis.js +1 -1
  113. package/modern/LineChart/AreaElement.js +1 -0
  114. package/modern/LineChart/LineChart.js +11 -9
  115. package/modern/LineChart/LineElement.js +1 -0
  116. package/modern/LineChart/LineHighlightElement.js +2 -1
  117. package/modern/LineChart/MarkElement.js +1 -0
  118. package/modern/PieChart/PieArc.js +1 -0
  119. package/modern/PieChart/PieArcLabel.js +1 -0
  120. package/modern/PieChart/PieArcLabelPlot.js +1 -1
  121. package/modern/PieChart/PieArcPlot.js +1 -1
  122. package/modern/PieChart/PieChart.js +11 -9
  123. package/modern/ScatterChart/Scatter.js +1 -1
  124. package/modern/ScatterChart/ScatterChart.js +11 -9
  125. package/modern/SparkLineChart/SparkLineChart.js +14 -5
  126. package/modern/context/CartesianContextProvider.js +8 -6
  127. package/modern/index.js +1 -1
  128. package/package.json +1 -1
@@ -36,7 +36,7 @@ export interface SparkLineChartProps extends Omit<ResponsiveChartContainerProps,
36
36
  * Formatter used by the tooltip.
37
37
  * @param {number} value The value to format.
38
38
  * @returns {string} the formatted value.
39
- * @default (v: number) => v.toString()
39
+ * @default (value: number | null) => (value === null ? '' : value.toString())
40
40
  */
41
41
  valueFormatter?: (value: number) => string;
42
42
  /**
@@ -73,6 +73,12 @@ export interface SparkLineChartProps extends Omit<ResponsiveChartContainerProps,
73
73
  * }
74
74
  */
75
75
  margin?: Partial<CardinalDirections<number>>;
76
+ /**
77
+ * If `true`, bar animations are skiped.
78
+ * @deprecated In v7 animations are skipped for sparkline.
79
+ * @default false
80
+ */
81
+ skipAnimation?: boolean;
76
82
  /**
77
83
  * Overridable component slots.
78
84
  * @default {}
@@ -50,9 +50,10 @@ const SparkLineChart = exports.SparkLineChart = /*#__PURE__*/React.forwardRef(fu
50
50
  slotProps,
51
51
  data,
52
52
  plotType = 'line',
53
- valueFormatter = v => v.toString(),
53
+ valueFormatter = value => value === null ? '' : value.toString(),
54
54
  area,
55
- curve = 'linear'
55
+ curve = 'linear',
56
+ skipAnimation = false
56
57
  } = props;
57
58
  const defaultXHighlight = showHighlight && plotType === 'bar' ? {
58
59
  x: 'band'
@@ -86,6 +87,7 @@ const SparkLineChart = exports.SparkLineChart = /*#__PURE__*/React.forwardRef(fu
86
87
  sx: sx,
87
88
  disableAxisListener: (!showTooltip || tooltip?.trigger !== 'axis') && axisHighlight?.x === 'none' && axisHighlight?.y === 'none',
88
89
  children: [plotType === 'bar' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_BarChart.BarPlot, {
90
+ skipAnimation: skipAnimation,
89
91
  slots: slots,
90
92
  slotProps: slotProps,
91
93
  sx: {
@@ -188,6 +190,12 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
188
190
  * @default false
189
191
  */
190
192
  showTooltip: _propTypes.default.bool,
193
+ /**
194
+ * If `true`, bar animations are skiped.
195
+ * @deprecated In v7 animations are skipped for sparkline.
196
+ * @default false
197
+ */
198
+ skipAnimation: _propTypes.default.bool,
191
199
  /**
192
200
  * The props used for each component slot.
193
201
  * @default {}
@@ -212,7 +220,7 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
212
220
  * Formatter used by the tooltip.
213
221
  * @param {number} value The value to format.
214
222
  * @returns {string} the formatted value.
215
- * @default (v: number) => v.toString()
223
+ * @default (value: number | null) => (value === null ? '' : value.toString())
216
224
  */
217
225
  valueFormatter: _propTypes.default.func,
218
226
  viewBox: _propTypes.default.shape({
@@ -231,7 +239,7 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
231
239
  * Notice it is a single configuration object, not an array of configuration.
232
240
  */
233
241
  xAxis: _propTypes.default.shape({
234
- axisId: _propTypes.default.string,
242
+ axisId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
235
243
  classes: _propTypes.default.object,
236
244
  data: _propTypes.default.array,
237
245
  dataKey: _propTypes.default.string,
@@ -239,13 +247,14 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
239
247
  disableTicks: _propTypes.default.bool,
240
248
  fill: _propTypes.default.string,
241
249
  hideTooltip: _propTypes.default.bool,
242
- id: _propTypes.default.string,
250
+ id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
243
251
  label: _propTypes.default.string,
244
252
  labelFontSize: _propTypes.default.number,
245
253
  labelStyle: _propTypes.default.object,
246
254
  max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
247
255
  min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
248
256
  position: _propTypes.default.oneOf(['bottom', 'left', 'right', 'top']),
257
+ reverse: _propTypes.default.bool,
249
258
  scaleType: _propTypes.default.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
250
259
  slotProps: _propTypes.default.object,
251
260
  slots: _propTypes.default.object,
@@ -117,7 +117,7 @@ function CartesianContextProvider(props) {
117
117
  allXAxis.forEach((axis, axisIndex) => {
118
118
  const isDefaultAxis = axisIndex === 0;
119
119
  const [minData, maxData] = getAxisExtremum(axis, xExtremumGetters, isDefaultAxis);
120
- 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];
121
121
  if ((0, _axis.isBandScaleConfig)(axis)) {
122
122
  const categoryGapRatio = axis.categoryGapRatio ?? DEFAULT_CATEGORY_GAP_RATIO;
123
123
  const barGapRatio = axis.barGapRatio ?? DEFAULT_BAR_GAP_RATIO;
@@ -166,7 +166,7 @@ function CartesianContextProvider(props) {
166
166
  allYAxis.forEach((axis, axisIndex) => {
167
167
  const isDefaultAxis = axisIndex === 0;
168
168
  const [minData, maxData] = getAxisExtremum(axis, yExtremumGetters, isDefaultAxis);
169
- 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];
170
170
  if ((0, _axis.isBandScaleConfig)(axis)) {
171
171
  const categoryGapRatio = axis.categoryGapRatio ?? DEFAULT_CATEGORY_GAP_RATIO;
172
172
  completedYAxis[axis.id] = (0, _extends2.default)({
@@ -235,7 +235,7 @@ process.env.NODE_ENV !== "production" ? CartesianContextProvider.propTypes = {
235
235
  * If not provided, a default axis config is used with id set to `DEFAULT_X_AXIS_KEY`.
236
236
  */
237
237
  xAxis: _propTypes.default.arrayOf(_propTypes.default.shape({
238
- axisId: _propTypes.default.string,
238
+ axisId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
239
239
  classes: _propTypes.default.object,
240
240
  data: _propTypes.default.array,
241
241
  dataKey: _propTypes.default.string,
@@ -243,13 +243,14 @@ process.env.NODE_ENV !== "production" ? CartesianContextProvider.propTypes = {
243
243
  disableTicks: _propTypes.default.bool,
244
244
  fill: _propTypes.default.string,
245
245
  hideTooltip: _propTypes.default.bool,
246
- id: _propTypes.default.string,
246
+ id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
247
247
  label: _propTypes.default.string,
248
248
  labelFontSize: _propTypes.default.number,
249
249
  labelStyle: _propTypes.default.object,
250
250
  max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
251
251
  min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
252
252
  position: _propTypes.default.oneOf(['bottom', 'left', 'right', 'top']),
253
+ reverse: _propTypes.default.bool,
253
254
  scaleType: _propTypes.default.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
254
255
  slotProps: _propTypes.default.object,
255
256
  slots: _propTypes.default.object,
@@ -269,7 +270,7 @@ process.env.NODE_ENV !== "production" ? CartesianContextProvider.propTypes = {
269
270
  * If not provided, a default axis config is used with id set to `DEFAULT_Y_AXIS_KEY`.
270
271
  */
271
272
  yAxis: _propTypes.default.arrayOf(_propTypes.default.shape({
272
- axisId: _propTypes.default.string,
273
+ axisId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
273
274
  classes: _propTypes.default.object,
274
275
  data: _propTypes.default.array,
275
276
  dataKey: _propTypes.default.string,
@@ -277,13 +278,14 @@ process.env.NODE_ENV !== "production" ? CartesianContextProvider.propTypes = {
277
278
  disableTicks: _propTypes.default.bool,
278
279
  fill: _propTypes.default.string,
279
280
  hideTooltip: _propTypes.default.bool,
280
- id: _propTypes.default.string,
281
+ id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
281
282
  label: _propTypes.default.string,
282
283
  labelFontSize: _propTypes.default.number,
283
284
  labelStyle: _propTypes.default.object,
284
285
  max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
285
286
  min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
286
287
  position: _propTypes.default.oneOf(['bottom', 'left', 'right', 'top']),
288
+ reverse: _propTypes.default.bool,
287
289
  scaleType: _propTypes.default.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
288
290
  slotProps: _propTypes.default.object,
289
291
  slots: _propTypes.default.object,
@@ -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
  };
@@ -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,
@@ -182,7 +182,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
182
182
  * @default yAxisIds[0] The id of the first provided axis
183
183
  */
184
184
  leftAxis: PropTypes.oneOfType([PropTypes.shape({
185
- axisId: PropTypes.string,
185
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
186
186
  classes: PropTypes.object,
187
187
  disableLine: PropTypes.bool,
188
188
  disableTicks: PropTypes.bool,
@@ -235,7 +235,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
235
235
  * @default null
236
236
  */
237
237
  rightAxis: PropTypes.oneOfType([PropTypes.shape({
238
- axisId: PropTypes.string,
238
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
239
239
  classes: PropTypes.object,
240
240
  disableLine: PropTypes.bool,
241
241
  disableTicks: PropTypes.bool,
@@ -264,7 +264,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
264
264
  faded: PropTypes.oneOf(['global', 'none', 'series']),
265
265
  highlighted: PropTypes.oneOf(['item', 'none', 'series'])
266
266
  }),
267
- id: PropTypes.string,
267
+ id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
268
268
  label: PropTypes.string,
269
269
  layout: PropTypes.oneOf(['horizontal', 'vertical']),
270
270
  stack: PropTypes.string,
@@ -306,7 +306,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
306
306
  * @default null
307
307
  */
308
308
  topAxis: PropTypes.oneOfType([PropTypes.shape({
309
- axisId: PropTypes.string,
309
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
310
310
  classes: PropTypes.object,
311
311
  disableLine: PropTypes.bool,
312
312
  disableTicks: PropTypes.bool,
@@ -343,7 +343,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
343
343
  * If not provided, a default axis config is used with id set to `DEFAULT_X_AXIS_KEY`.
344
344
  */
345
345
  xAxis: PropTypes.arrayOf(PropTypes.shape({
346
- axisId: PropTypes.string,
346
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
347
347
  classes: PropTypes.object,
348
348
  data: PropTypes.array,
349
349
  dataKey: PropTypes.string,
@@ -351,13 +351,14 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
351
351
  disableTicks: PropTypes.bool,
352
352
  fill: PropTypes.string,
353
353
  hideTooltip: PropTypes.bool,
354
- id: PropTypes.string,
354
+ id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
355
355
  label: PropTypes.string,
356
356
  labelFontSize: PropTypes.number,
357
357
  labelStyle: PropTypes.object,
358
358
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
359
359
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
360
360
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
361
+ reverse: PropTypes.bool,
361
362
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
362
363
  slotProps: PropTypes.object,
363
364
  slots: PropTypes.object,
@@ -377,7 +378,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
377
378
  * If not provided, a default axis config is used with id set to `DEFAULT_Y_AXIS_KEY`.
378
379
  */
379
380
  yAxis: PropTypes.arrayOf(PropTypes.shape({
380
- axisId: PropTypes.string,
381
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
381
382
  classes: PropTypes.object,
382
383
  data: PropTypes.array,
383
384
  dataKey: PropTypes.string,
@@ -385,13 +386,14 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
385
386
  disableTicks: PropTypes.bool,
386
387
  fill: PropTypes.string,
387
388
  hideTooltip: PropTypes.bool,
388
- id: PropTypes.string,
389
+ id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
389
390
  label: PropTypes.string,
390
391
  labelFontSize: PropTypes.number,
391
392
  labelStyle: PropTypes.object,
392
393
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
393
394
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
394
395
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
396
+ reverse: PropTypes.bool,
395
397
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
396
398
  slotProps: PropTypes.object,
397
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,
@@ -235,107 +235,6 @@ function DefaultChartsLegend(props) {
235
235
  })
236
236
  });
237
237
  }
238
- process.env.NODE_ENV !== "production" ? DefaultChartsLegend.propTypes = {
239
- // ----------------------------- Warning --------------------------------
240
- // | These PropTypes are generated from the TypeScript type definitions |
241
- // | To update them edit the TypeScript types and run "yarn proptypes" |
242
- // ----------------------------------------------------------------------
243
- /**
244
- * Override or extend the styles applied to the component.
245
- */
246
- classes: PropTypes.object.isRequired,
247
- /**
248
- * The direction of the legend layout.
249
- * The default depends on the chart.
250
- */
251
- direction: PropTypes.oneOf(['column', 'row']).isRequired,
252
- drawingArea: PropTypes.shape({
253
- bottom: PropTypes.number.isRequired,
254
- height: PropTypes.number.isRequired,
255
- left: PropTypes.number.isRequired,
256
- right: PropTypes.number.isRequired,
257
- top: PropTypes.number.isRequired,
258
- width: PropTypes.number.isRequired
259
- }).isRequired,
260
- /**
261
- * Set to true to hide the legend.
262
- * @default false
263
- */
264
- hidden: PropTypes.bool,
265
- /**
266
- * Space between two legend items (in px).
267
- * @default 10
268
- */
269
- itemGap: PropTypes.number,
270
- /**
271
- * Height of the item mark (in px).
272
- * @default 20
273
- */
274
- itemMarkHeight: PropTypes.number,
275
- /**
276
- * Width of the item mark (in px).
277
- * @default 20
278
- */
279
- itemMarkWidth: PropTypes.number,
280
- /**
281
- * Style applied to legend labels.
282
- * @default theme.typography.subtitle1
283
- */
284
- labelStyle: PropTypes.object,
285
- /**
286
- * Space between the mark and the label (in px).
287
- * @default 5
288
- */
289
- markGap: PropTypes.number,
290
- /**
291
- * Legend padding (in px).
292
- * Can either be a single number, or an object with top, left, bottom, right properties.
293
- * @default 0
294
- */
295
- padding: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
296
- bottom: PropTypes.number,
297
- left: PropTypes.number,
298
- right: PropTypes.number,
299
- top: PropTypes.number
300
- })]),
301
- position: PropTypes.shape({
302
- horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
303
- vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
304
- }).isRequired,
305
- series: PropTypes.shape({
306
- bar: PropTypes.shape({
307
- series: PropTypes.object.isRequired,
308
- seriesOrder: PropTypes.arrayOf(PropTypes.string).isRequired,
309
- stackingGroups: PropTypes.arrayOf(PropTypes.shape({
310
- ids: PropTypes.arrayOf(PropTypes.string).isRequired,
311
- stackingOffset: PropTypes.func.isRequired,
312
- stackingOrder: PropTypes.func.isRequired
313
- })).isRequired
314
- }),
315
- line: PropTypes.shape({
316
- series: PropTypes.object.isRequired,
317
- seriesOrder: PropTypes.arrayOf(PropTypes.string).isRequired,
318
- stackingGroups: PropTypes.arrayOf(PropTypes.shape({
319
- ids: PropTypes.arrayOf(PropTypes.string).isRequired,
320
- stackingOffset: PropTypes.func.isRequired,
321
- stackingOrder: PropTypes.func.isRequired
322
- })).isRequired
323
- }),
324
- pie: PropTypes.shape({
325
- series: PropTypes.object.isRequired,
326
- seriesOrder: PropTypes.arrayOf(PropTypes.string).isRequired
327
- }),
328
- scatter: PropTypes.shape({
329
- series: PropTypes.object.isRequired,
330
- seriesOrder: PropTypes.arrayOf(PropTypes.string).isRequired
331
- })
332
- }).isRequired,
333
- seriesToDisplay: PropTypes.arrayOf(PropTypes.shape({
334
- color: PropTypes.string.isRequired,
335
- id: PropTypes.string.isRequired,
336
- label: PropTypes.string.isRequired
337
- })).isRequired
338
- } : void 0;
339
238
  function ChartsLegend(inProps) {
340
239
  var _slots$legend;
341
240
  const props = useThemeProps({
@@ -29,7 +29,7 @@ process.env.NODE_ENV !== "production" ? ChartsReferenceLine.propTypes = {
29
29
  * The id of the axis used for the reference value.
30
30
  * @default The `id` of the first defined axis.
31
31
  */
32
- axisId: PropTypes.string,
32
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
33
33
  /**
34
34
  * Override or extend the styles applied to the component.
35
35
  */
@@ -66,11 +66,11 @@ process.env.NODE_ENV !== "production" ? ChartsAxisTooltipContent.propTypes = {
66
66
  axisData: PropTypes.shape({
67
67
  x: PropTypes.shape({
68
68
  index: PropTypes.number,
69
- value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired
69
+ value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired
70
70
  }),
71
71
  y: PropTypes.shape({
72
72
  index: PropTypes.number,
73
- value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired
73
+ value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired
74
74
  })
75
75
  }).isRequired,
76
76
  classes: PropTypes.object.isRequired,
@@ -80,11 +80,11 @@ process.env.NODE_ENV !== "production" ? ChartsAxisTooltipContent.propTypes = {
80
80
  axisData: PropTypes.shape({
81
81
  x: PropTypes.shape({
82
82
  index: PropTypes.number,
83
- value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired
83
+ value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired
84
84
  }),
85
85
  y: PropTypes.shape({
86
86
  index: PropTypes.number,
87
- value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired
87
+ value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired
88
88
  })
89
89
  }),
90
90
  axisValue: PropTypes.any,
@@ -39,7 +39,7 @@ process.env.NODE_ENV !== "production" ? ChartsItemTooltipContent.propTypes = {
39
39
  classes: PropTypes.object,
40
40
  itemData: PropTypes.shape({
41
41
  dataIndex: PropTypes.number,
42
- seriesId: PropTypes.string.isRequired,
42
+ seriesId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
43
43
  type: PropTypes.oneOf(['bar', 'line', 'pie', 'scatter']).isRequired
44
44
  }),
45
45
  series: PropTypes.shape({
@@ -63,7 +63,7 @@ process.env.NODE_ENV !== "production" ? ChartsItemTooltipContent.propTypes = {
63
63
  faded: PropTypes.oneOf(['global', 'none', 'series']),
64
64
  highlighted: PropTypes.oneOf(['item', 'none', 'series'])
65
65
  }),
66
- id: PropTypes.string.isRequired,
66
+ id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
67
67
  type: PropTypes.oneOf(['bar', 'line', 'pie', 'scatter']).isRequired,
68
68
  valueFormatter: PropTypes.func.isRequired
69
69
  }),
@@ -71,7 +71,7 @@ process.env.NODE_ENV !== "production" ? ChartsItemTooltipContent.propTypes = {
71
71
  }),
72
72
  itemData: PropTypes.shape({
73
73
  dataIndex: PropTypes.number,
74
- seriesId: PropTypes.string.isRequired,
74
+ seriesId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
75
75
  type: PropTypes.oneOf(['bar', 'line', 'pie', 'scatter']).isRequired
76
76
  }).isRequired,
77
77
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
@@ -88,11 +88,11 @@ process.env.NODE_ENV !== "production" ? DefaultChartsAxisTooltipContent.propType
88
88
  axisData: PropTypes.shape({
89
89
  x: PropTypes.shape({
90
90
  index: PropTypes.number,
91
- value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired
91
+ value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired
92
92
  }),
93
93
  y: PropTypes.shape({
94
94
  index: PropTypes.number,
95
- value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired
95
+ value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired
96
96
  })
97
97
  }).isRequired,
98
98
  /**
@@ -70,7 +70,7 @@ process.env.NODE_ENV !== "production" ? DefaultChartsItemTooltipContent.propType
70
70
  */
71
71
  itemData: PropTypes.shape({
72
72
  dataIndex: PropTypes.number,
73
- seriesId: PropTypes.string.isRequired,
73
+ seriesId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
74
74
  type: PropTypes.oneOf(['bar', 'line', 'pie', 'scatter']).isRequired
75
75
  }).isRequired,
76
76
  /**
@@ -97,7 +97,7 @@ process.env.NODE_ENV !== "production" ? DefaultChartsItemTooltipContent.propType
97
97
  faded: PropTypes.oneOf(['global', 'none', 'series']),
98
98
  highlighted: PropTypes.oneOf(['item', 'none', 'series'])
99
99
  }),
100
- id: PropTypes.string.isRequired,
100
+ id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
101
101
  type: PropTypes.oneOf(['bar', 'line', 'pie', 'scatter']).isRequired,
102
102
  valueFormatter: PropTypes.func.isRequired
103
103
  }).isRequired,
@@ -1,6 +1,6 @@
1
1
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
- const _excluded = ["scale", "tickNumber"];
3
+ const _excluded = ["scale", "tickNumber", "reverse"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import { useSlotProps } from '@mui/base/utils';
@@ -35,6 +35,7 @@ const useUtilityClasses = ownerState => {
35
35
  function addLabelDimension(xTicks, {
36
36
  tickLabelStyle: style,
37
37
  tickLabelInterval,
38
+ reverse,
38
39
  isMounted
39
40
  }) {
40
41
  const withDimension = xTicks.map(tick => {
@@ -61,8 +62,9 @@ function addLabelDimension(xTicks, {
61
62
  }
62
63
 
63
64
  // Filter label to avoid overlap
64
- let textStart = 0;
65
- let textEnd = 0;
65
+ let currentTextLimit = 0;
66
+ let previouseTextLimit = 0;
67
+ const direction = reverse ? -1 : 1;
66
68
  return withDimension.map((item, labelIndex) => {
67
69
  const {
68
70
  width,
@@ -74,15 +76,15 @@ function addLabelDimension(xTicks, {
74
76
  const textPosition = offset + labelOffset;
75
77
  const gapRatio = 1.2; // Ratio applied to the minimal distance to add some margin.
76
78
 
77
- textStart = textPosition - gapRatio * distance / 2;
78
- if (labelIndex > 0 && textStart < textEnd) {
79
+ currentTextLimit = textPosition - direction * (gapRatio * distance) / 2;
80
+ if (labelIndex > 0 && direction * currentTextLimit < direction * previouseTextLimit) {
79
81
  // Except for the first label, we skip all label that overlap with the last accepted.
80
- // Notice that the early return prevents `textEnd` from being updated.
82
+ // Notice that the early return prevents `previouseTextLimit` from being updated.
81
83
  return _extends({}, item, {
82
84
  skipLabel: true
83
85
  });
84
86
  }
85
- textEnd = textPosition + gapRatio * distance / 2;
87
+ previouseTextLimit = textPosition + direction * (gapRatio * distance) / 2;
86
88
  return item;
87
89
  });
88
90
  }
@@ -117,7 +119,8 @@ function ChartsXAxis(inProps) {
117
119
  xAxis: {
118
120
  [_ref]: {
119
121
  scale: xScale,
120
- tickNumber
122
+ tickNumber,
123
+ reverse
121
124
  }
122
125
  }
123
126
  } = _React$useContext,
@@ -179,6 +182,7 @@ function ChartsXAxis(inProps) {
179
182
  const xTicksWithDimension = addLabelDimension(xTicks, {
180
183
  tickLabelStyle: axisTickLabelProps.style,
181
184
  tickLabelInterval,
185
+ reverse,
182
186
  isMounted
183
187
  });
184
188
  const labelRefPoint = {
@@ -242,7 +246,7 @@ process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
242
246
  * The id of the axis to render.
243
247
  * If undefined, it will be the first defined axis.
244
248
  */
245
- axisId: PropTypes.string,
249
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
246
250
  /**
247
251
  * Override or extend the styles applied to the component.
248
252
  */
@@ -176,7 +176,7 @@ process.env.NODE_ENV !== "production" ? ChartsYAxis.propTypes = {
176
176
  * The id of the axis to render.
177
177
  * If undefined, it will be the first defined axis.
178
178
  */
179
- axisId: PropTypes.string,
179
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
180
180
  /**
181
181
  * Override or extend the styles applied to the component.
182
182
  */
@@ -120,6 +120,7 @@ process.env.NODE_ENV !== "production" ? AreaElement.propTypes = {
120
120
  faded: PropTypes.oneOf(['global', 'none', 'series']),
121
121
  highlighted: PropTypes.oneOf(['item', 'none', 'series'])
122
122
  }),
123
+ id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
123
124
  /**
124
125
  * The props used for each component slot.
125
126
  * @default {}