@mui/x-charts 7.0.0-beta.1 → 7.0.0-beta.2

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 (152) hide show
  1. package/BarChart/BarChart.js +10 -8
  2. package/BarChart/BarElement.d.ts +20 -13
  3. package/BarChart/BarElement.js +1 -0
  4. package/BarChart/BarPlot.d.ts +3 -5
  5. package/BarChart/BarPlot.js +9 -10
  6. package/CHANGELOG.md +159 -1
  7. package/ChartContainer/ChartContainer.js +6 -4
  8. package/ChartsAxis/ChartsAxis.js +4 -4
  9. package/ChartsLegend/ChartsLegend.d.ts +5 -54
  10. package/ChartsLegend/ChartsLegend.js +2 -307
  11. package/ChartsLegend/DefaultChartsLegend.d.ts +60 -0
  12. package/ChartsLegend/DefaultChartsLegend.js +294 -0
  13. package/ChartsLegend/index.d.ts +1 -0
  14. package/ChartsLegend/index.js +11 -0
  15. package/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  16. package/ChartsReferenceLine/common.d.ts +2 -1
  17. package/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
  18. package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +1 -1
  19. package/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
  20. package/ChartsTooltip/utils.d.ts +1 -0
  21. package/ChartsTooltip/utils.js +7 -0
  22. package/ChartsXAxis/ChartsXAxis.js +13 -9
  23. package/ChartsYAxis/ChartsYAxis.js +1 -1
  24. package/LineChart/AnimatedArea.js +1 -1
  25. package/LineChart/AnimatedLine.js +1 -1
  26. package/LineChart/AreaElement.d.ts +2 -1
  27. package/LineChart/AreaElement.js +1 -1
  28. package/LineChart/LineChart.js +10 -8
  29. package/LineChart/LineElement.d.ts +2 -1
  30. package/LineChart/LineElement.js +1 -1
  31. package/LineChart/LineHighlightElement.d.ts +3 -2
  32. package/LineChart/LineHighlightElement.js +2 -1
  33. package/LineChart/MarkElement.d.ts +3 -2
  34. package/LineChart/MarkElement.js +1 -0
  35. package/PieChart/PieArc.d.ts +3 -2
  36. package/PieChart/PieArc.js +1 -0
  37. package/PieChart/PieArcLabel.d.ts +3 -2
  38. package/PieChart/PieArcLabel.js +1 -0
  39. package/PieChart/PieArcLabelPlot.js +1 -1
  40. package/PieChart/PieArcPlot.js +1 -1
  41. package/PieChart/PieChart.js +10 -8
  42. package/ResponsiveChartContainer/ResponsiveChartContainer.js +6 -4
  43. package/ScatterChart/ScatterChart.js +10 -8
  44. package/SparkLineChart/SparkLineChart.d.ts +1 -1
  45. package/SparkLineChart/SparkLineChart.js +5 -4
  46. package/context/CartesianContextProvider.js +8 -6
  47. package/esm/BarChart/BarChart.js +10 -8
  48. package/esm/BarChart/BarElement.js +1 -0
  49. package/esm/BarChart/BarPlot.js +8 -10
  50. package/esm/ChartContainer/ChartContainer.js +6 -4
  51. package/esm/ChartsAxis/ChartsAxis.js +4 -4
  52. package/esm/ChartsLegend/ChartsLegend.js +2 -307
  53. package/esm/ChartsLegend/DefaultChartsLegend.js +286 -0
  54. package/esm/ChartsLegend/index.js +1 -0
  55. package/esm/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  56. package/esm/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
  57. package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -2
  58. package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
  59. package/esm/ChartsTooltip/utils.js +6 -0
  60. package/esm/ChartsXAxis/ChartsXAxis.js +13 -9
  61. package/esm/ChartsYAxis/ChartsYAxis.js +1 -1
  62. package/esm/LineChart/AnimatedArea.js +1 -1
  63. package/esm/LineChart/AnimatedLine.js +1 -1
  64. package/esm/LineChart/AreaElement.js +1 -1
  65. package/esm/LineChart/LineChart.js +10 -8
  66. package/esm/LineChart/LineElement.js +1 -1
  67. package/esm/LineChart/LineHighlightElement.js +2 -1
  68. package/esm/LineChart/MarkElement.js +1 -0
  69. package/esm/PieChart/PieArc.js +1 -0
  70. package/esm/PieChart/PieArcLabel.js +1 -0
  71. package/esm/PieChart/PieArcLabelPlot.js +1 -1
  72. package/esm/PieChart/PieArcPlot.js +1 -1
  73. package/esm/PieChart/PieChart.js +10 -8
  74. package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +6 -4
  75. package/esm/ScatterChart/ScatterChart.js +10 -8
  76. package/esm/SparkLineChart/SparkLineChart.js +5 -4
  77. package/esm/context/CartesianContextProvider.js +8 -6
  78. package/index.js +1 -1
  79. package/internals/defaultizeColor.d.ts +16 -16
  80. package/internals/defaultizeValueFormatter.d.ts +4 -7
  81. package/internals/stackSeries.d.ts +4 -7
  82. package/legacy/BarChart/BarChart.js +10 -8
  83. package/legacy/BarChart/BarElement.js +1 -0
  84. package/legacy/BarChart/BarPlot.js +10 -10
  85. package/legacy/ChartContainer/ChartContainer.js +6 -4
  86. package/legacy/ChartsAxis/ChartsAxis.js +4 -4
  87. package/legacy/ChartsLegend/ChartsLegend.js +2 -323
  88. package/legacy/ChartsLegend/DefaultChartsLegend.js +302 -0
  89. package/legacy/ChartsLegend/index.js +1 -0
  90. package/legacy/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  91. package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
  92. package/legacy/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -2
  93. package/legacy/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
  94. package/legacy/ChartsTooltip/utils.js +6 -0
  95. package/legacy/ChartsXAxis/ChartsXAxis.js +12 -8
  96. package/legacy/ChartsYAxis/ChartsYAxis.js +1 -1
  97. package/legacy/LineChart/AnimatedArea.js +1 -1
  98. package/legacy/LineChart/AnimatedLine.js +1 -1
  99. package/legacy/LineChart/AreaElement.js +1 -1
  100. package/legacy/LineChart/LineChart.js +10 -8
  101. package/legacy/LineChart/LineElement.js +1 -1
  102. package/legacy/LineChart/LineHighlightElement.js +2 -1
  103. package/legacy/LineChart/MarkElement.js +1 -0
  104. package/legacy/PieChart/PieArc.js +1 -0
  105. package/legacy/PieChart/PieArcLabel.js +1 -0
  106. package/legacy/PieChart/PieArcLabelPlot.js +1 -1
  107. package/legacy/PieChart/PieArcPlot.js +1 -1
  108. package/legacy/PieChart/PieChart.js +10 -8
  109. package/legacy/ResponsiveChartContainer/ResponsiveChartContainer.js +6 -4
  110. package/legacy/ScatterChart/ScatterChart.js +10 -8
  111. package/legacy/SparkLineChart/SparkLineChart.js +6 -5
  112. package/legacy/context/CartesianContextProvider.js +8 -6
  113. package/legacy/index.js +1 -1
  114. package/models/axis.d.ts +7 -2
  115. package/models/seriesType/common.d.ts +2 -1
  116. package/models/seriesType/config.d.ts +7 -12
  117. package/models/seriesType/line.d.ts +2 -2
  118. package/models/seriesType/pie.d.ts +7 -3
  119. package/models/seriesType/scatter.d.ts +5 -2
  120. package/modern/BarChart/BarChart.js +10 -8
  121. package/modern/BarChart/BarElement.js +1 -0
  122. package/modern/BarChart/BarPlot.js +8 -10
  123. package/modern/ChartContainer/ChartContainer.js +6 -4
  124. package/modern/ChartsAxis/ChartsAxis.js +4 -4
  125. package/modern/ChartsLegend/ChartsLegend.js +2 -307
  126. package/modern/ChartsLegend/DefaultChartsLegend.js +286 -0
  127. package/modern/ChartsLegend/index.js +1 -0
  128. package/modern/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  129. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
  130. package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -2
  131. package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
  132. package/modern/ChartsTooltip/utils.js +6 -0
  133. package/modern/ChartsXAxis/ChartsXAxis.js +13 -9
  134. package/modern/ChartsYAxis/ChartsYAxis.js +1 -1
  135. package/modern/LineChart/AnimatedArea.js +1 -1
  136. package/modern/LineChart/AnimatedLine.js +1 -1
  137. package/modern/LineChart/AreaElement.js +1 -1
  138. package/modern/LineChart/LineChart.js +10 -8
  139. package/modern/LineChart/LineElement.js +1 -1
  140. package/modern/LineChart/LineHighlightElement.js +2 -1
  141. package/modern/LineChart/MarkElement.js +1 -0
  142. package/modern/PieChart/PieArc.js +1 -0
  143. package/modern/PieChart/PieArcLabel.js +1 -0
  144. package/modern/PieChart/PieArcLabelPlot.js +1 -1
  145. package/modern/PieChart/PieArcPlot.js +1 -1
  146. package/modern/PieChart/PieChart.js +10 -8
  147. package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +6 -4
  148. package/modern/ScatterChart/ScatterChart.js +10 -8
  149. package/modern/SparkLineChart/SparkLineChart.js +5 -4
  150. package/modern/context/CartesianContextProvider.js +8 -6
  151. package/modern/index.js +1 -1
  152. package/package.json +1 -1
package/models/axis.d.ts CHANGED
@@ -3,6 +3,7 @@ import type { ScaleBand, ScaleLogarithmic, ScalePower, ScaleTime, ScaleLinear, S
3
3
  import { ChartsAxisClasses } from '../ChartsAxis/axisClasses';
4
4
  import type { TickParams } from '../hooks/useTicks';
5
5
  import { ChartsTextProps } from '../ChartsText';
6
+ export type AxisId = string | number;
6
7
  export type D3Scale<Domain extends {
7
8
  toString(): string;
8
9
  } = number | Date | string, Range = number, Output = number> = ScaleBand<Domain> | ScaleLogarithmic<Range, Output> | ScalePoint<Domain> | ScalePower<Range, Output> | ScaleTime<Range, Output> | ScaleLinear<Range, Output>;
@@ -24,7 +25,7 @@ export interface ChartsAxisProps extends TickParams {
24
25
  * The id of the axis to render.
25
26
  * If undefined, it will be the first defined axis.
26
27
  */
27
- axisId?: string;
28
+ axisId?: AxisId;
28
29
  /**
29
30
  * If true, the axis line is disabled.
30
31
  * @default false
@@ -160,7 +161,7 @@ export type AxisConfig<S extends ScaleName = ScaleName, V = any> = {
160
161
  /**
161
162
  * Id used to identify the axis.
162
163
  */
163
- id: string;
164
+ id: AxisId;
164
165
  /**
165
166
  * The minimal value of the domain.
166
167
  * If not provided, it gets computed to display the entire chart data.
@@ -184,6 +185,10 @@ export type AxisConfig<S extends ScaleName = ScaleName, V = any> = {
184
185
  * If `true`, hide this value in the tooltip
185
186
  */
186
187
  hideTooltip?: boolean;
188
+ /**
189
+ * If `true`, Reverse the axis scaleBand.
190
+ */
191
+ reverse?: boolean;
187
192
  } & Partial<ChartsXAxisProps | ChartsYAxisProps> & Partial<Omit<AxisScaleConfig[S], 'scale'>> & TickParams;
188
193
  export type AxisDefaultized<S extends ScaleName = ScaleName, V = any> = Omit<AxisConfig<S, V>, 'scaleType'> & AxisScaleConfig[S] & {
189
194
  /**
@@ -1,7 +1,8 @@
1
1
  import type { HighlightScope } from '../../context/HighlightProvider';
2
2
  import type { StackOffsetType, StackOrderType } from '../stacking';
3
+ export type SeriesId = number | string;
3
4
  export type CommonSeriesType<TValue> = {
4
- id?: string;
5
+ id?: SeriesId;
5
6
  color?: string;
6
7
  /**
7
8
  * Formatter used to render values in tooltip or other data display.
@@ -5,6 +5,7 @@ import { PieSeriesType, DefaultizedPieSeriesType, PieItemIdentifier, PieValueTyp
5
5
  import { AxisConfig } from '../axis';
6
6
  import { DefaultizedProps, MakeOptional } from '../helpers';
7
7
  import { StackingGroupsType } from '../../internals/stackSeries';
8
+ import { SeriesId } from './common';
8
9
  interface ChartsSeriesConfig {
9
10
  bar: {
10
11
  seriesInput: DefaultizedProps<BarSeriesType, 'id'> & {
@@ -53,25 +54,19 @@ export type ChartSeriesDefaultized<T extends ChartSeriesType> = ChartsSeriesConf
53
54
  } : ChartsSeriesConfig[T]['series'];
54
55
  export type ChartItemIdentifier<T extends ChartSeriesType> = ChartsSeriesConfig[T]['itemIdentifier'];
55
56
  type ExtremumGetterParams<T extends ChartSeriesType> = {
56
- series: {
57
- [id: string]: ChartSeries<T>;
58
- };
57
+ series: Record<SeriesId, ChartSeries<T>>;
59
58
  axis: AxisConfig;
60
59
  isDefaultAxis: boolean;
61
60
  };
62
61
  export type ExtremumGetterResult = [number, number] | [null, null];
63
62
  export type ExtremumGetter<T extends ChartSeriesType> = (params: ExtremumGetterParams<T>) => ExtremumGetterResult;
64
63
  export type FormatterParams<T extends ChartSeriesType> = {
65
- series: {
66
- [id: string]: ChartsSeriesConfig[T]['seriesInput'];
67
- };
68
- seriesOrder: string[];
64
+ series: Record<SeriesId, ChartsSeriesConfig[T]['seriesInput']>;
65
+ seriesOrder: SeriesId[];
69
66
  };
70
67
  export type FormatterResult<T extends ChartSeriesType> = {
71
- series: {
72
- [id: string]: ChartSeriesDefaultized<T>;
73
- };
74
- seriesOrder: string[];
68
+ series: Record<SeriesId, ChartSeriesDefaultized<T>>;
69
+ seriesOrder: SeriesId[];
75
70
  } & (ChartsSeriesConfig[T] extends {
76
71
  canBeStacked: true;
77
72
  } ? {
@@ -95,7 +90,7 @@ export type LegendParams = {
95
90
  * The identifier of the legend element.
96
91
  * Used for internal purpose such as `key` props
97
92
  */
98
- id: string;
93
+ id: SeriesId;
99
94
  };
100
95
  export type LegendGetter<T extends ChartSeriesType> = (series: FormatterResult<T>) => LegendParams[];
101
96
  export {};
@@ -1,6 +1,6 @@
1
1
  import { DefaultizedProps } from '../helpers';
2
2
  import type { StackOffsetType } from '../stacking';
3
- import { CartesianSeriesType, CommonDefaultizedProps, CommonSeriesType, StackableSeriesType } from './common';
3
+ import { CartesianSeriesType, CommonDefaultizedProps, CommonSeriesType, SeriesId, StackableSeriesType } from './common';
4
4
  export type CurveType = 'catmullRom' | 'linear' | 'monotoneX' | 'monotoneY' | 'natural' | 'step' | 'stepBefore' | 'stepAfter';
5
5
  export interface ShowMarkParams<AxisValue = number | Date> {
6
6
  /**
@@ -66,7 +66,7 @@ export interface LineSeriesType extends CommonSeriesType<number | null>, Cartesi
66
66
  */
67
67
  export type LineItemIdentifier = {
68
68
  type: 'line';
69
- seriesId: DefaultizedLineSeriesType['id'];
69
+ seriesId: SeriesId;
70
70
  /**
71
71
  * `dataIndex` can be `undefined` if the mouse is over the area and not a specific item.
72
72
  */
@@ -1,8 +1,12 @@
1
1
  import { PieArcDatum as D3PieArcDatum } from 'd3-shape';
2
2
  import { DefaultizedProps } from '../helpers';
3
- import { CommonDefaultizedProps, CommonSeriesType } from './common';
3
+ import { CommonDefaultizedProps, CommonSeriesType, SeriesId } from './common';
4
+ export type PieItemId = string | number;
4
5
  export type PieValueType = {
5
- id: string | number;
6
+ /**
7
+ * A unique identifier of the pie slice.
8
+ */
9
+ id: PieItemId;
6
10
  value: number;
7
11
  label?: string;
8
12
  color?: string;
@@ -119,7 +123,7 @@ export interface PieSeriesType<Tdata = PieValueType> extends CommonSeriesType<Td
119
123
  */
120
124
  export type PieItemIdentifier = {
121
125
  type: 'pie';
122
- seriesId: DefaultizedPieSeriesType['id'];
126
+ seriesId: SeriesId;
123
127
  dataIndex: number;
124
128
  };
125
129
  export interface DefaultizedPieSeriesType extends DefaultizedProps<PieSeriesType, CommonDefaultizedProps> {
@@ -1,8 +1,11 @@
1
1
  import { DefaultizedProps } from '../helpers';
2
- import { CartesianSeriesType, CommonDefaultizedProps, CommonSeriesType } from './common';
2
+ import { CartesianSeriesType, CommonDefaultizedProps, CommonSeriesType, SeriesId } from './common';
3
3
  export type ScatterValueType = {
4
4
  x: number;
5
5
  y: number;
6
+ /**
7
+ * A unique identifier for the scatter point
8
+ */
6
9
  id: string | number;
7
10
  };
8
11
  export interface ScatterSeriesType extends CommonSeriesType<ScatterValueType>, CartesianSeriesType {
@@ -22,7 +25,7 @@ export interface ScatterSeriesType extends CommonSeriesType<ScatterValueType>, C
22
25
  */
23
26
  export type ScatterItemIdentifier = {
24
27
  type: 'scatter';
25
- seriesId: DefaultizedScatterSeriesType['id'];
28
+ seriesId: SeriesId;
26
29
  dataIndex: number;
27
30
  };
28
31
  export interface DefaultizedScatterSeriesType extends DefaultizedProps<ScatterSeriesType, CommonDefaultizedProps | 'color'> {
@@ -134,7 +134,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
134
134
  * @default xAxisIds[0] The id of the first provided axis
135
135
  */
136
136
  bottomAxis: PropTypes.oneOfType([PropTypes.shape({
137
- axisId: PropTypes.string,
137
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
138
138
  classes: PropTypes.object,
139
139
  disableLine: PropTypes.bool,
140
140
  disableTicks: PropTypes.bool,
@@ -185,7 +185,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
185
185
  * @default yAxisIds[0] The id of the first provided axis
186
186
  */
187
187
  leftAxis: PropTypes.oneOfType([PropTypes.shape({
188
- axisId: PropTypes.string,
188
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
189
189
  classes: PropTypes.object,
190
190
  disableLine: PropTypes.bool,
191
191
  disableTicks: PropTypes.bool,
@@ -251,7 +251,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
251
251
  * @default null
252
252
  */
253
253
  rightAxis: PropTypes.oneOfType([PropTypes.shape({
254
- axisId: PropTypes.string,
254
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
255
255
  classes: PropTypes.object,
256
256
  disableLine: PropTypes.bool,
257
257
  disableTicks: PropTypes.bool,
@@ -304,7 +304,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
304
304
  * @default null
305
305
  */
306
306
  topAxis: PropTypes.oneOfType([PropTypes.shape({
307
- axisId: PropTypes.string,
307
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
308
308
  classes: PropTypes.object,
309
309
  disableLine: PropTypes.bool,
310
310
  disableTicks: PropTypes.bool,
@@ -341,7 +341,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
341
341
  * If not provided, a default axis config is used with id set to `DEFAULT_X_AXIS_KEY`.
342
342
  */
343
343
  xAxis: PropTypes.arrayOf(PropTypes.shape({
344
- axisId: PropTypes.string,
344
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
345
345
  classes: PropTypes.object,
346
346
  data: PropTypes.array,
347
347
  dataKey: PropTypes.string,
@@ -349,13 +349,14 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
349
349
  disableTicks: PropTypes.bool,
350
350
  fill: PropTypes.string,
351
351
  hideTooltip: PropTypes.bool,
352
- id: PropTypes.string,
352
+ id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
353
353
  label: PropTypes.string,
354
354
  labelFontSize: PropTypes.number,
355
355
  labelStyle: PropTypes.object,
356
356
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
357
357
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
358
358
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
359
+ reverse: PropTypes.bool,
359
360
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
360
361
  slotProps: PropTypes.object,
361
362
  slots: PropTypes.object,
@@ -375,7 +376,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
375
376
  * If not provided, a default axis config is used with id set to `DEFAULT_Y_AXIS_KEY`.
376
377
  */
377
378
  yAxis: PropTypes.arrayOf(PropTypes.shape({
378
- axisId: PropTypes.string,
379
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
379
380
  classes: PropTypes.object,
380
381
  data: PropTypes.array,
381
382
  dataKey: PropTypes.string,
@@ -383,13 +384,14 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
383
384
  disableTicks: PropTypes.bool,
384
385
  fill: PropTypes.string,
385
386
  hideTooltip: PropTypes.bool,
386
- id: PropTypes.string,
387
+ id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
387
388
  label: PropTypes.string,
388
389
  labelFontSize: PropTypes.number,
389
390
  labelStyle: PropTypes.object,
390
391
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
391
392
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
392
393
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
394
+ reverse: PropTypes.bool,
393
395
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
394
396
  slotProps: PropTypes.object,
395
397
  slots: PropTypes.object,
@@ -105,6 +105,7 @@ process.env.NODE_ENV !== "production" ? BarElement.propTypes = {
105
105
  faded: PropTypes.oneOf(['global', 'none', 'series']),
106
106
  highlighted: PropTypes.oneOf(['item', 'none', 'series'])
107
107
  }),
108
+ id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
108
109
  /**
109
110
  * The props used for each component slot.
110
111
  * @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,
@@ -101,20 +100,19 @@ const useAggregatedData = () => {
101
100
  color
102
101
  } = series[seriesId];
103
102
  return stackedData.map((values, dataIndex) => {
104
- const bottom = Math.min(...values);
105
- const top = Math.max(...values);
103
+ const valueCoordinates = values.map(v => verticalLayout ? yScale(v) : xScale(v));
104
+ const minValueCoord = Math.min(...valueCoordinates);
105
+ const maxValueCoord = Math.max(...valueCoordinates);
106
106
  return {
107
- bottom,
108
- top,
109
107
  seriesId,
110
108
  dataIndex,
111
109
  layout: series[seriesId].layout,
112
- x: verticalLayout ? xScale(xAxis[xAxisKey].data?.[dataIndex]) + barOffset : xScale(bottom),
113
- y: verticalLayout ? yScale(top) : yScale(yAxis[yAxisKey].data?.[dataIndex]) + barOffset,
110
+ x: verticalLayout ? xScale(xAxis[xAxisKey].data?.[dataIndex]) + barOffset : minValueCoord,
111
+ y: verticalLayout ? minValueCoord : yScale(yAxis[yAxisKey].data?.[dataIndex]) + barOffset,
114
112
  xOrigin: xScale(0),
115
113
  yOrigin: yScale(0),
116
- height: verticalLayout ? Math.abs(yScale(bottom) - yScale(top)) : barWidth,
117
- width: verticalLayout ? barWidth : Math.abs(xScale(bottom) - xScale(top)),
114
+ height: verticalLayout ? maxValueCoord - minValueCoord : barWidth,
115
+ width: verticalLayout ? barWidth : maxValueCoord - minValueCoord,
118
116
  color,
119
117
  highlightScope: series[seriesId].highlightScope
120
118
  };
@@ -122,7 +122,7 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
122
122
  * If not provided, a default axis config is used with id set to `DEFAULT_X_AXIS_KEY`.
123
123
  */
124
124
  xAxis: PropTypes.arrayOf(PropTypes.shape({
125
- axisId: PropTypes.string,
125
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
126
126
  classes: PropTypes.object,
127
127
  data: PropTypes.array,
128
128
  dataKey: PropTypes.string,
@@ -130,13 +130,14 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
130
130
  disableTicks: PropTypes.bool,
131
131
  fill: PropTypes.string,
132
132
  hideTooltip: PropTypes.bool,
133
- id: PropTypes.string,
133
+ id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
134
134
  label: PropTypes.string,
135
135
  labelFontSize: PropTypes.number,
136
136
  labelStyle: PropTypes.object,
137
137
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
138
138
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
139
139
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
140
+ reverse: PropTypes.bool,
140
141
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
141
142
  slotProps: PropTypes.object,
142
143
  slots: PropTypes.object,
@@ -156,7 +157,7 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
156
157
  * If not provided, a default axis config is used with id set to `DEFAULT_Y_AXIS_KEY`.
157
158
  */
158
159
  yAxis: PropTypes.arrayOf(PropTypes.shape({
159
- axisId: PropTypes.string,
160
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
160
161
  classes: PropTypes.object,
161
162
  data: PropTypes.array,
162
163
  dataKey: PropTypes.string,
@@ -164,13 +165,14 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
164
165
  disableTicks: PropTypes.bool,
165
166
  fill: PropTypes.string,
166
167
  hideTooltip: PropTypes.bool,
167
- id: PropTypes.string,
168
+ id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
168
169
  label: PropTypes.string,
169
170
  labelFontSize: PropTypes.number,
170
171
  labelStyle: PropTypes.object,
171
172
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
172
173
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
173
174
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
175
+ reverse: PropTypes.bool,
174
176
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
175
177
  slotProps: PropTypes.object,
176
178
  slots: PropTypes.object,
@@ -100,7 +100,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
100
100
  * @default xAxisIds[0] The id of the first provided axis
101
101
  */
102
102
  bottomAxis: PropTypes.oneOfType([PropTypes.shape({
103
- axisId: PropTypes.string,
103
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
104
104
  classes: PropTypes.object,
105
105
  disableLine: PropTypes.bool,
106
106
  disableTicks: PropTypes.bool,
@@ -127,7 +127,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
127
127
  * @default yAxisIds[0] The id of the first provided axis
128
128
  */
129
129
  leftAxis: PropTypes.oneOfType([PropTypes.shape({
130
- axisId: PropTypes.string,
130
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
131
131
  classes: PropTypes.object,
132
132
  disableLine: PropTypes.bool,
133
133
  disableTicks: PropTypes.bool,
@@ -154,7 +154,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
154
154
  * @default null
155
155
  */
156
156
  rightAxis: PropTypes.oneOfType([PropTypes.shape({
157
- axisId: PropTypes.string,
157
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
158
158
  classes: PropTypes.object,
159
159
  disableLine: PropTypes.bool,
160
160
  disableTicks: PropTypes.bool,
@@ -191,7 +191,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
191
191
  * @default null
192
192
  */
193
193
  topAxis: PropTypes.oneOfType([PropTypes.shape({
194
- axisId: PropTypes.string,
194
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
195
195
  classes: PropTypes.object,
196
196
  disableLine: PropTypes.bool,
197
197
  disableTicks: PropTypes.bool,