Skip to content

Commit 6e0107d

Browse files
Fix same issue for position property
1 parent 8303fb8 commit 6e0107d

File tree

1 file changed

+8
-6
lines changed
  • packages/x-charts/src/internals/plugins/featurePlugins/useChartCartesianAxis

1 file changed

+8
-6
lines changed

packages/x-charts/src/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,17 @@ export function defaultizeXAxis(
2828
const parsedAxes = inputAxes.map((axisConfig, index) => {
2929
const dataKey = axisConfig.dataKey;
3030

31-
const position = axisConfig.position ?? 'none';
31+
// The first x-axis is defaultized to the bottom
32+
const defaultPosition = index === 0 ? 'bottom' : 'none';
33+
const position = axisConfig.position ?? defaultPosition;
3234
const defaultHeight =
3335
DEFAULT_AXIS_SIZE_HEIGHT + (axisConfig.label ? AXIS_LABEL_DEFAULT_HEIGHT : 0);
3436

3537
const sharedConfig = {
3638
id: `defaultized-x-axis-${index}`,
37-
// The fist axis is defaultized to the bottom/left
38-
...(index === 0 ? ({ position: 'bottom' } as const) : {}),
3939
offset: offsets[position],
4040
...axisConfig,
41+
position,
4142
height: axisConfig.height ?? defaultHeight,
4243
};
4344

@@ -79,16 +80,17 @@ export function defaultizeYAxis(
7980
const parsedAxes = inputAxes.map((axisConfig, index) => {
8081
const dataKey = axisConfig.dataKey;
8182

82-
const position = axisConfig.position ?? 'none';
83+
// The first y-axis is defaultized to the left
84+
const defaultPosition = index === 0 ? 'left' : 'none';
85+
const position = axisConfig.position ?? defaultPosition;
8386
const defaultWidth =
8487
DEFAULT_AXIS_SIZE_WIDTH + (axisConfig.label ? AXIS_LABEL_DEFAULT_HEIGHT : 0);
8588

8689
const sharedConfig = {
8790
id: `defaultized-y-axis-${index}`,
88-
// The first axis is defaultized to the left
89-
...(index === 0 ? ({ position: 'left' } as const) : {}),
9091
offset: offsets[position],
9192
...axisConfig,
93+
position,
9294
width: axisConfig.width ?? defaultWidth,
9395
};
9496

0 commit comments

Comments
 (0)