-
Notifications
You must be signed in to change notification settings - Fork 85
/
g6.html
71 lines (71 loc) · 1.58 KB
/
g6.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://gw.alipayobjects.com/os/antv/pkg/_antv.g6-3.4.7/dist/g6.min.js"></script>
</head>
<body>
<div id="g6-chart"></div>
<script>
const data = {
nodes: [{
id: 'node1',
x: 100,
y: 200,
label: '起始点',
size: 60,
labelCfg: {
position: 'center',
style: {
fontSize: 12,
fill: '#fff'
}
},
style: {
fill: '#ff0000',
stroke: '#888',
lineWidth: 1
}
}, {
id: 'node2',
x: 300,
y: 200,
label: '目标点1',
size: 80
}, {
id: 'node4',
x: 300,
y: 400,
label: '目标点4',
size: 80
}, {
id: 'node3',
x: 500,
y: 200,
label: '目标点2',
size: 100
}], // 点集
edges: [{
source: 'node1',
target: 'node2',
label: '连接线1'
}, {
source: 'node1',
target: 'node4',
label: '连接线3'
}, {
source: 'node2',
target: 'node3',
label: '连接线2'
}] // 边集
};
const graph = new G6.Graph({
container: 'g6-chart',
width: 800,
height: 500
}); // 完成 G6 图的初始化
graph.data(data); // 绑定数据源
graph.render(); // 绘制矢量图
</script>
</body>
</html>