-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathechart graph.html
160 lines (152 loc) · 4.13 KB
/
echart graph.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<!DOCTYPE html>
<html style="height: 100%">
<head>
<meta charset="utf-8">
</head>
<body style="height: 100%; margin: 0">
<div id="container" style="height: 100%"></div>
<script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/echarts.min.js"></script>
<script type="text/javascript">
var dom = document.getElementById("container");
var myChart = echarts.init(dom);
var app = {};
option = null;
var graph = [];
var categories = [];
for (var i = 0; i < 9; i++) {
categories[i] = {
name: '类目' + i
};
}
console.log(graph);
graph = {
nodes: [
{
attributes: {
modularity_class: 1
},
category: 0,
id: "0",
itemStyle: null,
label: {
normal: {
show: false
}
},
name: "Myriel",
symbolSize: 19.12381,
value: 28.685715,
},
{
attributes: {
modularity_class: 1
},
category: 0,//图例
id: "1",
itemStyle: null,
label: {
normal: {
show: false
}
},
name: "Myriel",
symbolSize: 19.12381,
value: 28.685715,
// x: -266.82776,
// y: 399.6904 //位置一定要动
},
{
attributes: {
modularity_class: 1
},
category: 0,//图例
id: "2",
itemStyle: null,
label: {
normal: {
show: false
}
},
name: "Myriel",
symbolSize: 19.12381,
value: 28.685715,
// x: -266.82776,
// y: 399.6904 //位置一定要动
}
],
links: [
{
id: "0",
lineStyle: {normal: {}},
name: null,
source: "1",
target: "0",
},
{
id: "1",
lineStyle: {normal: {}},
name: null,
source: "1",
target: "2",
}
]
};
option = {
title: {
text: 'Les Miserables',
subtext: 'Default layout',
top: 'bottom',
left: 'right'
},
tooltip: {},
legend: [{
// selectedMode: 'single',
data: categories.map(function (a) {
return a.name;
})
}],
animationDuration: 1500,
animationEasingUpdate: 'quinticInOut',
series: [
{
name: '',
type: 'graph',
layout: 'force', //力图生效
data: graph.nodes,
links: graph.links,
categories: categories,
roam: true,
focusNodeAdjacency: true,
itemStyle: {
normal: {
borderColor: '#fff',
borderWidth: 1,
shadowBlur: 10,
shadowColor: 'rgba(0, 0, 0, 0.3)'
}
},
label: {
position: 'right',
formatter: '{b}'
},
lineStyle: {
color: 'source',
curveness: 0.3
},
emphasis: {
lineStyle: {
width: 10
}
},
force: {
repulsion: 2500,
edgeLength: [10, 50]
},
draggable: true,
}
]
};
myChart.setOption(option);
</script>
</body>
</html>