Skip to content

Commit dba197a

Browse files
committed
feat: introduce new charts
* SankeyChart * TreemapChart * ChordChart
1 parent 4e8e311 commit dba197a

File tree

12 files changed

+17040
-25
lines changed

12 files changed

+17040
-25
lines changed

__tests__/plots/chord.spec.tsx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { mount } from '@vue/test-utils'
2+
import ChordChart from '../../src/plots/chord'
3+
4+
const DATA = [
5+
{ source: '北京', target: '天津', value: 30 },
6+
{ source: '北京', target: '上海', value: 80 },
7+
{ source: '北京', target: '河北', value: 46 },
8+
{ source: '北京', target: '辽宁', value: 49 },
9+
{ source: '北京', target: '黑龙江', value: 69 },
10+
{ source: '北京', target: '吉林', value: 19 },
11+
{ source: '天津', target: '河北', value: 62 },
12+
{ source: '天津', target: '辽宁', value: 82 },
13+
{ source: '天津', target: '上海', value: 16 },
14+
{ source: '上海', target: '黑龙江', value: 16 },
15+
{ source: '河北', target: '黑龙江', value: 76 },
16+
{ source: '河北', target: '内蒙古', value: 24 },
17+
{ source: '内蒙古', target: '北京', value: 32 },
18+
]
19+
20+
const config = {
21+
data: DATA,
22+
sourceField: 'source',
23+
targetField: 'target',
24+
weightField: 'value',
25+
}
26+
27+
describe('ChordChart', () => {
28+
test('should render without crashed', () => {
29+
mount(() => <ChordChart {...config} />)
30+
})
31+
})

__tests__/plots/sankey.spec.tsx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { mount } from '@vue/test-utils'
2+
import SankeyChart from '../../src/plots/sankey'
3+
const DATA = [
4+
{ source: '首次打开', target: '首页 UV', value: 160 },
5+
{ source: '结果页', target: '首页 UV', value: 40 },
6+
{ source: '验证页', target: '首页 UV', value: 10 },
7+
{ source: '我的', target: '首页 UV', value: 10 },
8+
{ source: '朋友', target: '首页 UV', value: 8 },
9+
{ source: '其他来源', target: '首页 UV', value: 27 },
10+
{ source: '首页 UV', target: '理财', value: 30 },
11+
{ source: '首页 UV', target: '扫一扫', value: 40 },
12+
{ source: '首页 UV', target: '服务', value: 35 },
13+
{ source: '首页 UV', target: '蚂蚁森林', value: 25 },
14+
{ source: '首页 UV', target: '跳失', value: 10 },
15+
{ source: '首页 UV', target: '借呗', value: 30 },
16+
{ source: '首页 UV', target: '花呗', value: 40 },
17+
{ source: '首页 UV', target: '其他流向', value: 45 },
18+
]
19+
20+
const config = {
21+
data: DATA,
22+
sourceField: 'source',
23+
targetField: 'target',
24+
weightField: 'value',
25+
nodeWidthRatio: 0.008,
26+
nodePaddingRatio: 0.03,
27+
}
28+
29+
describe('SankeyChart', () => {
30+
test('should render without crashed', () => {
31+
mount(() => <SankeyChart {...config} />)
32+
})
33+
})

__tests__/plots/treemap.spec.tsx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { mount } from '@vue/test-utils'
2+
import TreemapChart from '../../src/plots/treemap'
3+
4+
const data = {
5+
name: 'root',
6+
children: [
7+
{ name: '分类 1', value: 560 },
8+
{ name: '分类 2', value: 500 },
9+
{ name: '分类 3', value: 150 },
10+
{ name: '分类 4', value: 140 },
11+
{ name: '分类 5', value: 115 },
12+
{ name: '分类 6', value: 95 },
13+
{ name: '分类 7', value: 90 },
14+
{ name: '分类 8', value: 75 },
15+
{ name: '分类 9', value: 98 },
16+
{ name: '分类 10', value: 60 },
17+
{ name: '分类 11', value: 45 },
18+
{ name: '分类 12', value: 40 },
19+
{ name: '分类 13', value: 40 },
20+
{ name: '分类 14', value: 35 },
21+
{ name: '分类 15', value: 40 },
22+
{ name: '分类 16', value: 40 },
23+
{ name: '分类 17', value: 40 },
24+
{ name: '分类 18', value: 30 },
25+
{ name: '分类 19', value: 28 },
26+
{ name: '分类 20', value: 16 },
27+
],
28+
}
29+
30+
const config = {
31+
data,
32+
colorField: 'name',
33+
}
34+
35+
describe('TreemapChart', () => {
36+
test('should render without crashed', () => {
37+
mount(() => <TreemapChart {...config} />)
38+
})
39+
})

0 commit comments

Comments
 (0)