@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.
- package/BarChart/BarChart.js +10 -8
- package/BarChart/BarElement.d.ts +20 -13
- package/BarChart/BarElement.js +1 -0
- package/BarChart/BarPlot.d.ts +3 -5
- package/BarChart/BarPlot.js +9 -10
- package/CHANGELOG.md +159 -1
- package/ChartContainer/ChartContainer.js +6 -4
- package/ChartsAxis/ChartsAxis.js +4 -4
- package/ChartsLegend/ChartsLegend.d.ts +5 -54
- package/ChartsLegend/ChartsLegend.js +2 -307
- package/ChartsLegend/DefaultChartsLegend.d.ts +60 -0
- package/ChartsLegend/DefaultChartsLegend.js +294 -0
- package/ChartsLegend/index.d.ts +1 -0
- package/ChartsLegend/index.js +11 -0
- package/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
- package/ChartsReferenceLine/common.d.ts +2 -1
- package/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
- package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +1 -1
- package/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
- package/ChartsTooltip/utils.d.ts +1 -0
- package/ChartsTooltip/utils.js +7 -0
- package/ChartsXAxis/ChartsXAxis.js +13 -9
- package/ChartsYAxis/ChartsYAxis.js +1 -1
- package/LineChart/AnimatedArea.js +1 -1
- package/LineChart/AnimatedLine.js +1 -1
- package/LineChart/AreaElement.d.ts +2 -1
- package/LineChart/AreaElement.js +1 -1
- package/LineChart/LineChart.js +10 -8
- package/LineChart/LineElement.d.ts +2 -1
- package/LineChart/LineElement.js +1 -1
- package/LineChart/LineHighlightElement.d.ts +3 -2
- package/LineChart/LineHighlightElement.js +2 -1
- package/LineChart/MarkElement.d.ts +3 -2
- package/LineChart/MarkElement.js +1 -0
- package/PieChart/PieArc.d.ts +3 -2
- package/PieChart/PieArc.js +1 -0
- package/PieChart/PieArcLabel.d.ts +3 -2
- package/PieChart/PieArcLabel.js +1 -0
- package/PieChart/PieArcLabelPlot.js +1 -1
- package/PieChart/PieArcPlot.js +1 -1
- package/PieChart/PieChart.js +10 -8
- package/ResponsiveChartContainer/ResponsiveChartContainer.js +6 -4
- package/ScatterChart/ScatterChart.js +10 -8
- package/SparkLineChart/SparkLineChart.d.ts +1 -1
- package/SparkLineChart/SparkLineChart.js +5 -4
- package/context/CartesianContextProvider.js +8 -6
- package/esm/BarChart/BarChart.js +10 -8
- package/esm/BarChart/BarElement.js +1 -0
- package/esm/BarChart/BarPlot.js +8 -10
- package/esm/ChartContainer/ChartContainer.js +6 -4
- package/esm/ChartsAxis/ChartsAxis.js +4 -4
- package/esm/ChartsLegend/ChartsLegend.js +2 -307
- package/esm/ChartsLegend/DefaultChartsLegend.js +286 -0
- package/esm/ChartsLegend/index.js +1 -0
- package/esm/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
- package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -2
- package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
- package/esm/ChartsTooltip/utils.js +6 -0
- package/esm/ChartsXAxis/ChartsXAxis.js +13 -9
- package/esm/ChartsYAxis/ChartsYAxis.js +1 -1
- package/esm/LineChart/AnimatedArea.js +1 -1
- package/esm/LineChart/AnimatedLine.js +1 -1
- package/esm/LineChart/AreaElement.js +1 -1
- package/esm/LineChart/LineChart.js +10 -8
- package/esm/LineChart/LineElement.js +1 -1
- package/esm/LineChart/LineHighlightElement.js +2 -1
- package/esm/LineChart/MarkElement.js +1 -0
- package/esm/PieChart/PieArc.js +1 -0
- package/esm/PieChart/PieArcLabel.js +1 -0
- package/esm/PieChart/PieArcLabelPlot.js +1 -1
- package/esm/PieChart/PieArcPlot.js +1 -1
- package/esm/PieChart/PieChart.js +10 -8
- package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +6 -4
- package/esm/ScatterChart/ScatterChart.js +10 -8
- package/esm/SparkLineChart/SparkLineChart.js +5 -4
- package/esm/context/CartesianContextProvider.js +8 -6
- package/index.js +1 -1
- package/internals/defaultizeColor.d.ts +16 -16
- package/internals/defaultizeValueFormatter.d.ts +4 -7
- package/internals/stackSeries.d.ts +4 -7
- package/legacy/BarChart/BarChart.js +10 -8
- package/legacy/BarChart/BarElement.js +1 -0
- package/legacy/BarChart/BarPlot.js +10 -10
- package/legacy/ChartContainer/ChartContainer.js +6 -4
- package/legacy/ChartsAxis/ChartsAxis.js +4 -4
- package/legacy/ChartsLegend/ChartsLegend.js +2 -323
- package/legacy/ChartsLegend/DefaultChartsLegend.js +302 -0
- package/legacy/ChartsLegend/index.js +1 -0
- package/legacy/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
- package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
- package/legacy/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -2
- package/legacy/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
- package/legacy/ChartsTooltip/utils.js +6 -0
- package/legacy/ChartsXAxis/ChartsXAxis.js +12 -8
- package/legacy/ChartsYAxis/ChartsYAxis.js +1 -1
- package/legacy/LineChart/AnimatedArea.js +1 -1
- package/legacy/LineChart/AnimatedLine.js +1 -1
- package/legacy/LineChart/AreaElement.js +1 -1
- package/legacy/LineChart/LineChart.js +10 -8
- package/legacy/LineChart/LineElement.js +1 -1
- package/legacy/LineChart/LineHighlightElement.js +2 -1
- package/legacy/LineChart/MarkElement.js +1 -0
- package/legacy/PieChart/PieArc.js +1 -0
- package/legacy/PieChart/PieArcLabel.js +1 -0
- package/legacy/PieChart/PieArcLabelPlot.js +1 -1
- package/legacy/PieChart/PieArcPlot.js +1 -1
- package/legacy/PieChart/PieChart.js +10 -8
- package/legacy/ResponsiveChartContainer/ResponsiveChartContainer.js +6 -4
- package/legacy/ScatterChart/ScatterChart.js +10 -8
- package/legacy/SparkLineChart/SparkLineChart.js +6 -5
- package/legacy/context/CartesianContextProvider.js +8 -6
- package/legacy/index.js +1 -1
- package/models/axis.d.ts +7 -2
- package/models/seriesType/common.d.ts +2 -1
- package/models/seriesType/config.d.ts +7 -12
- package/models/seriesType/line.d.ts +2 -2
- package/models/seriesType/pie.d.ts +7 -3
- package/models/seriesType/scatter.d.ts +5 -2
- package/modern/BarChart/BarChart.js +10 -8
- package/modern/BarChart/BarElement.js +1 -0
- package/modern/BarChart/BarPlot.js +8 -10
- package/modern/ChartContainer/ChartContainer.js +6 -4
- package/modern/ChartsAxis/ChartsAxis.js +4 -4
- package/modern/ChartsLegend/ChartsLegend.js +2 -307
- package/modern/ChartsLegend/DefaultChartsLegend.js +286 -0
- package/modern/ChartsLegend/index.js +1 -0
- package/modern/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
- package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -2
- package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
- package/modern/ChartsTooltip/utils.js +6 -0
- package/modern/ChartsXAxis/ChartsXAxis.js +13 -9
- package/modern/ChartsYAxis/ChartsYAxis.js +1 -1
- package/modern/LineChart/AnimatedArea.js +1 -1
- package/modern/LineChart/AnimatedLine.js +1 -1
- package/modern/LineChart/AreaElement.js +1 -1
- package/modern/LineChart/LineChart.js +10 -8
- package/modern/LineChart/LineElement.js +1 -1
- package/modern/LineChart/LineHighlightElement.js +2 -1
- package/modern/LineChart/MarkElement.js +1 -0
- package/modern/PieChart/PieArc.js +1 -0
- package/modern/PieChart/PieArcLabel.js +1 -0
- package/modern/PieChart/PieArcLabelPlot.js +1 -1
- package/modern/PieChart/PieArcPlot.js +1 -1
- package/modern/PieChart/PieChart.js +10 -8
- package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +6 -4
- package/modern/ScatterChart/ScatterChart.js +10 -8
- package/modern/SparkLineChart/SparkLineChart.js +5 -4
- package/modern/context/CartesianContextProvider.js +8 -6
- package/modern/index.js +1 -1
- 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?:
|
|
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:
|
|
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?:
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
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:
|
|
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
|
-
|
|
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:
|
|
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:
|
|
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
|
|
105
|
-
const
|
|
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 :
|
|
113
|
-
y: verticalLayout ?
|
|
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 ?
|
|
117
|
-
width: verticalLayout ? barWidth :
|
|
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,
|