Skip to content

Commit eb10f43

Browse files
authored
fix: bar-x with the similar data should be displayed the same for different types of axes (#295)
1 parent 4e33906 commit eb10f43

14 files changed

+67
-84
lines changed
-175 Bytes
Loading
7.07 KB
Loading
7.81 KB
Loading
5.31 KB
Loading
122 Bytes
Loading
289 Bytes
Loading
209 Bytes
Loading

src/__tests__/bar-x-series.visual.test.tsx

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,63 @@ test.describe('Bar-x series', () => {
2727
await expect(component.locator('svg')).toHaveScreenshot();
2828
});
2929

30+
test('Same data with different x-axis type', async ({mount}) => {
31+
const points = [
32+
{x: 0, y: 1},
33+
{x: 1, y: 3},
34+
{x: 2, y: 2},
35+
];
36+
// linear x-axis
37+
const component = await mount(
38+
<ChartTestStory
39+
data={{
40+
title: {text: 'linear x-axis'},
41+
series: {
42+
data: [{type: 'bar-x', name: '', data: points}],
43+
},
44+
xAxis: {type: 'linear'},
45+
}}
46+
/>,
47+
);
48+
await expect(component.locator('svg')).toHaveScreenshot();
49+
50+
// datetime x-axis
51+
const startDate = new Date('2000-10-10T00:00:00Z').getTime();
52+
const day = 1000 * 60 * 60 * 24;
53+
await component.update(
54+
<ChartTestStory
55+
data={{
56+
title: {text: 'datetime x-axis'},
57+
series: {
58+
data: [
59+
{
60+
type: 'bar-x',
61+
name: '',
62+
data: points.map((d) => ({x: d.x * day + startDate, y: d.y})),
63+
},
64+
],
65+
},
66+
xAxis: {type: 'datetime'},
67+
}}
68+
/>,
69+
);
70+
await expect(component.locator('svg')).toHaveScreenshot();
71+
72+
// categorical x-axis
73+
await component.update(
74+
<ChartTestStory
75+
data={{
76+
title: {text: 'categorical x-axis'},
77+
series: {
78+
data: [{type: 'bar-x', name: '', data: points}],
79+
},
80+
xAxis: {type: 'category', categories: ['0', '1', '2']},
81+
}}
82+
/>,
83+
);
84+
await expect(component.locator('svg')).toHaveScreenshot();
85+
});
86+
3087
test.describe('Stacking percent', () => {
3188
test('Linear X-axis ', async ({mount}) => {
3289
const chartData: ChartData = {

src/components/ChartInner/useChartInnerProps.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ export function useChartInnerProps(props: Props) {
132132
boundsHeight,
133133
rangeSliderState,
134134
series: preparedSeries,
135-
seriesOptions: preparedSeriesOptions,
136135
split: preparedSplit,
137136
xAxis,
138137
yAxis,

src/hooks/useAxis/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ export function useAxis(props: UseAxesProps) {
5353
xAxis,
5454
width,
5555
seriesData,
56-
seriesOptions: preparedSeriesOptions,
5756
});
5857

5958
let estimatedBoundsHeight = boundsHeight ?? height;

0 commit comments

Comments
 (0)