Toggle navigation
调用关系图
By
wolf赵帅帅
2017-02-13 09:46:32
脚本
16
21
作品使用的第三方脚本
数据管理
上传数据
支持小于 5M 任意格式(csv, xlsx, json, xml, ...)的数据文件
上传后可以通过生成的文件链接异步获取托管的数据。
历史数据
0 条
无历史数据
代码修改记录
信息提示
保存作品
对当前截图不满意?你还可以
上传本地截图
重新截图
作品名称
作品描述
标签
geo
grid
legend
markLine
markPoint
bar
effectScatter
line
lines
map
timeline
title
toolbox
tooltip
visualMap
作品默认版本
最新
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
20:11:45
图表已生成
整理代码
刷新
代码
var data = [ { "root": "service1", "clients": [ "service11", "service12" ] }, { "root": "service2", "clients": [ "service21", "service22" ], "servers": [ "service12" ] } ]; function get_nodes(data) { var nodes = []; var tmp_nodes = []; for (var root_i in data) { tmp_nodes.push(data[root_i].root); nodes.push( { 'name':data[root_i].root, 'x':100, 'y':(parseInt(root_i)+1)*100, 'label': { 'normal': { 'show': true, textStyle: { 'color': 'red', 'fontSize': 8 } } } } ); var clients = data[root_i].clients; var servers = data[root_i].servers; var coord_i = parseInt(root_i)+1; for (var client_i in clients) { if (tmp_nodes.indexOf(clients[client_i]) >= 0) { continue; }else{ tmp_nodes.push(clients[client_i]) } nodes.push( { 'name':clients[client_i], 'x':(parseInt(root_i)+1)*200, 'y':(parseInt(coord_i)+parseInt(client_i))*100, 'label': { 'normal': { 'show': true, textStyle: { 'color': 'red', 'fontSize': 8 } } } } ); coord_i += 1; } for (var server_i in servers) { if (tmp_nodes.indexOf(servers[server_i]) >= 0) { continue; }else{ tmp_nodes.push(servers[server_i]) } nodes.push( { 'name':servers[server_i], 'x':(parseInt(root_i)+1)*200, 'y': (parseInt(coord_i)+parseInt(server_i))*100, 'label': { 'normal': { 'show': true, textStyle: { 'color': 'red', 'fontSize': 8 } } } } ); coord_i += 1; } } return nodes; } function get_links(data) { var links = []; for (var root_i in data) { var clients = data[root_i].clients; var servers = data[root_i].servers; for (var client_i in clients) { links.push({'source': clients[client_i], 'target': data[root_i].root}) } for (var server_i in servers) { links.push({'source': data[root_i].root, 'target': servers[server_i]}) } } return links; } var option = { title: { text: '调用关系构建' }, tooltip: {}, series: [{ type: 'graph', legendHoverLink: true, layout: 'none', focusNodeAdjacency: true, symbolSize: 50, roam: true, label: { normal: { show: true } }, edgeSymbol: ['circle', 'arrow'], edgeSymbolSize: [4, 10], edgeLabel: { normal: { textStyle: { fontSize: 8 } } }, itemStyle: { normal: { color: '#ccc', borderColor: '#1af' } }, data: get_nodes(data), links: get_links(data), lineStyle: { normal: { color: '#1af', opacity: 0.9, width: 2, curveness: 0.2 } } }] }; myChart.setOption(option);