Skip to content

Commit a451b63

Browse files
author
duxinyue.dxy
committed
Merge branch 'main' into dev/add-zero
2 parents 1af59bf + 7feca8e commit a451b63

26 files changed

+999
-0
lines changed

.changeset/full-turkeys-sniff.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@antv/gpt-vis': patch
3+
---
4+
5+
add waterfall
19.1 KB
Loading
27.2 KB
Loading
15.6 KB
Loading
19.3 KB
Loading
23.6 KB
Loading

__tests__/snapshots/waterfall.png

22.7 KB
Loading

__tests__/waterfall.spec.ts

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
import { test } from '@playwright/test';
2+
import { renderChartAndSnapshot } from './utils/renderChartAndSnapshot';
3+
4+
test.use({ viewport: { width: 1200, height: 600 } });
5+
6+
test.describe('Waterfall component tests', () => {
7+
test('waterfall', async ({ page }) => {
8+
const spec = {
9+
type: 'waterfall',
10+
data: [
11+
{ category: '第一季度', value: 6200000 },
12+
{ category: '第二季度', value: -2600000 },
13+
{ category: '第三季度', value: 4100000 },
14+
{ category: '第四季度', value: 3700000 },
15+
{ category: '总计', isTotal: true },
16+
],
17+
axisXTitle: '季度',
18+
axisYTitle: '金额',
19+
title: 'Waterfall Chart',
20+
};
21+
await renderChartAndSnapshot(page, spec, 'waterfall.png');
22+
});
23+
24+
test('waterfall-required', async ({ page }) => {
25+
const spec = {
26+
type: 'waterfall',
27+
data: [
28+
{ category: 'Q1', value: 5000000 },
29+
{ category: 'Q2', value: -1000000 },
30+
{ category: 'Q3', value: 3000000 },
31+
{ category: 'Q4', value: 2000000 },
32+
{ category: 'Total', isTotal: true },
33+
],
34+
};
35+
await renderChartAndSnapshot(page, spec, 'waterfall-required.png');
36+
});
37+
38+
test('waterfall-theme-dark', async ({ page }) => {
39+
const spec = {
40+
type: 'waterfall',
41+
data: [
42+
{ category: 'Q1', value: 6200000 },
43+
{ category: 'Q2', value: -2600000 },
44+
{ category: 'Q3', value: 4100000 },
45+
{ category: 'Q4', value: 3700000 },
46+
{ category: 'Total', isTotal: true },
47+
],
48+
axisXTitle: 'Quarter',
49+
axisYTitle: 'Amount',
50+
theme: 'dark',
51+
};
52+
await renderChartAndSnapshot(page, spec, 'waterfall-theme-dark.png');
53+
});
54+
55+
test('waterfall-custom-color', async ({ page }) => {
56+
const spec = {
57+
type: 'waterfall',
58+
data: [
59+
{ category: 'Q1', value: 6200000 },
60+
{ category: 'Q2', value: -2600000 },
61+
{ category: 'Q3', value: 4100000 },
62+
{ category: 'Q4', value: 3700000 },
63+
{ category: 'Total', isTotal: true },
64+
],
65+
axisXTitle: 'Quarter',
66+
axisYTitle: 'Amount',
67+
positiveColor: '#00FF00',
68+
negativeColor: '#FF0000',
69+
totalColor: '#666',
70+
};
71+
await renderChartAndSnapshot(page, spec, 'waterfall-custom-color.png');
72+
});
73+
74+
test('waterfall-total', async ({ page }) => {
75+
const spec = {
76+
type: 'waterfall',
77+
data: [
78+
{ category: '第一季度', value: 6200000 },
79+
{ category: '第二季度', value: 2600000 },
80+
{ category: '统计', value: 8800000, isTotal: true },
81+
{ category: '第三季度', value: 4100000 },
82+
{ category: '第四季度', value: -3700000 },
83+
{ category: '总计', isTotal: true },
84+
],
85+
axisXTitle: 'Quarter',
86+
axisYTitle: 'Amount',
87+
};
88+
await renderChartAndSnapshot(page, spec, 'waterfall-total.png');
89+
});
90+
91+
test('waterfall-intermediate-total', async ({ page }) => {
92+
const spec = {
93+
type: 'waterfall',
94+
data: [
95+
{ category: '第一季度', value: 120000000 },
96+
{ category: '第二季度', value: 569000000 },
97+
{ category: '第三季度', value: 231000000 },
98+
{ category: '前三季度总计', isIntermediateTotal: true },
99+
{ category: '第四季度', value: -342000000 },
100+
{ category: '第五季度', value: -232000000 },
101+
{ category: '四五季度总计', isIntermediateTotal: true },
102+
{ category: '总计', isTotal: true },
103+
],
104+
axisXTitle: 'Quarter',
105+
axisYTitle: 'Amount',
106+
};
107+
await renderChartAndSnapshot(page, spec, 'waterfall-intermediate-total.png');
108+
});
109+
});
61.5 KB
Loading
108 KB
Loading

0 commit comments

Comments
 (0)