Skip to content

Commit 1caf34d

Browse files
committed
[charts] Fix grid with band scale
1 parent b5ed99d commit 1caf34d

3 files changed

Lines changed: 16 additions & 2 deletions

File tree

packages/x-charts/src/ChartsGrid/ChartsGrid.test.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,18 @@ describe('<ChartsGrid />', () => {
3131
</ChartContainer>,
3232
);
3333
});
34+
35+
it('should render grid on band scale without error', () => {
36+
render(
37+
<ChartContainer
38+
series={[]}
39+
width={500}
40+
height={500}
41+
xAxis={[{ scaleType: 'band', data: ['A', 'B', 'C'] }]}
42+
yAxis={[{ scaleType: 'band', data: ['A', 'B', 'C'] }]}
43+
>
44+
<ChartsGrid vertical horizontal />
45+
</ChartContainer>,
46+
);
47+
});
3448
});

packages/x-charts/src/ChartsGrid/ChartsHorizontalGrid.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export function ChartsGridHorizontal(props: ChartsGridHorizontalProps) {
2525
<React.Fragment>
2626
{yTicks.map(({ value, offset }) => (
2727
<GridLine
28-
key={`horizontal-${value.getTime?.() ?? value}`}
28+
key={`horizontal-${value?.getTime?.() ?? value}`}
2929
y1={offset}
3030
y2={offset}
3131
x1={start}

packages/x-charts/src/ChartsGrid/ChartsVerticalGrid.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export function ChartsGridVertical(props: ChartsGridVerticalProps) {
2525
<React.Fragment>
2626
{xTicks.map(({ value, offset }) => (
2727
<GridLine
28-
key={`vertical-${value.getTime?.() ?? value}`}
28+
key={`vertical-${value?.getTime?.() ?? value}`}
2929
y1={start}
3030
y2={end}
3131
x1={offset}

0 commit comments

Comments
 (0)