Toggle navigation
流程可视化跟踪
By
mark_ycj
2019-03-13 14:07:29
脚本
16
21
作品使用的第三方脚本
/dep/echarts/map/js/china.js
数据管理
上传数据
支持小于 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 nodes = [{ name: '节点信息看看看看1', code: 'node1000000001', x: 0 + 64, y: -60 - 20, width: 138, height: 40, status: 2, ext: { finishTime: '2019-01-01' } }, { name: '节点信息看看看看2', code: 'node1000000002', x: 228 + 64, y: -108 - 20, width: 138, height: 40, status: 0, ext: {} }, { name: '节点信息看看看看3', code: 'node1000000003', x: 228 + 64, y: 0 - 20, width: 138, height: 40, status: 1, ext: {} }, { name: '节点信息看看看看4', code: 'node1000000004', x: 492 + 64, y: -48 - 20, width: 138, height: 40, status: 0, ext: {} } ]; // 连接信息 var links = [{ source: 'node1000000001', target: 'node1000000002', status: 0 }, { source: 'node1000000001', target: 'node1000000003', status: 1 }, { source: 'node1000000003', target: 'node1000000004', status: 0 } ]; function getScatterData() { var scatterData = []; for (var i = 0; i < nodes.length; i++) { scatterData.push({ name: nodes[i].name, value: [nodes[i].x, nodes[i].y], type: 'title', w: 30, h: 30, ext: nodes[i].ext, node_status: nodes[i].status, label: { normal: { textStyle: { color: '#000', fontSize: 14 } } } }); } return scatterData; } function getLinesData() { var linesData = []; var map = {}; for (var i = 0; i < nodes.length; i++) { map[nodes[i].code] = nodes[i]; } for (var i = 0; i < links.length; i++) { var source = map[links[i].source]; var target = map[links[i].target]; // 计算信息框的四个边中点的位置 source.top = { x: source.x, y: (source.y + (1 / 2 * 30)) }; source.right = { x: (source.x + (1 / 2 * 30)), y: source.y }; source.bottom = { x: source.x, y: (source.y - (1 / 2 * 30)) }; source.left = { x: (source.x - (1 / 2 * 30)), y: source.y }; target.top = { x: target.x, y: (target.y + (1 / 2 * 30)) }; target.right = { x: (target.x + (1 / 2 * 30)), y: target.y }; target.bottom = { x: target.x, y: (target.y - (1 / 2 * 30)) }; target.left = { x: (target.x - (1 / 2 * 30)), y: target.y }; //s->t:s左:t右 if (source.right.x < target.left.x) { linesData.push(getLine([ [source.right.x, source.right.y], [target.left.x, target.left.y] ], links[i].status)); } //t<-s:s右:t左 else if (source.left.x > target.right.x) { linesData.push(getLine([ [source.left.x, source.left.y], [target.right.x, target.right.y] ], links[i].status)); } //s //| //t else if (source.bottom.y > target.top.y) { linesData.push(getLine([ [source.bottom.x, source.bottom.y], [target.top.x, target.top.y] ], links[i].status)); } //t //| //s else if (source.top.y < target.bottom.y) { linesData.push(getLine([ [source.top.x, source.top.y], [target.bottom.x, target.bottom.y] ], links[i].status)); } } return linesData; } function getLine(coords, status) { var lineColor = '#e1e1e1'; var lineSymbol = 'none'; if (status == 2) { lineColor = '#41a51e'; } else if (status == 1) { lineSymbol = 'arrow'; lineColor = '#ff9f1d'; } return { name: '', type: 'lines', coordinateSystem: 'cartesian2d', symbol: ['none', 'arrow'], symbolSize: 10, zlevel: 4, lineStyle: { normal: { type: 'solid', color: lineColor, width: 2, curveness: 0 } }, data: [{ coords: coords }] }; } function getSeries() { var series = []; series.push({ type: 'scatter', symbol: 'circle', zlevel: 333, silent: true, symbolSize: function(value, params) { return [30, 30]; }, itemStyle: { normal: { shadowBlur: 10, shadowColor: 'rgba(120, 36, 50, 0.5)', shadowOffsetY: 5, color: function(params) { if (params.data.type == 'title') { if (params.data.node_status == 2) { return '#41a51e'; } else if (params.data.node_status == 1) { return '#ff9f1d'; } else { return '#e1e1e1'; } } } } }, label: { normal: { show: true, position: 'bottom', formatter: function(params) { var ext = params.data.ext; var finishTime = ""; if ("undefined" != typeof ext && "undefined" != typeof ext.finishTime) { finishTime = ext.finishTime; } if (params.data.type == 'title') { return params.data.name + "\n\n" + finishTime; } }, textStyle: { color: '#000' } } }, data: getScatterData(), }); return series; //.concat(getLinesData()); } // 指定图表的配置项和数据 var option = { backgroundColor: '#fff', title: [{ // text: "流程跟踪图", x: '5%', y: 0, textStyle: { color: '#fff', fontStyle: 'normal', fontWeight: 'normal', fontFamily: 'sans-serif', fontSize: 14 } }], tooltip: { }, grid: { left: 0, right: 0, top: 0, bottom: 0 }, xAxis: { type: 'value', show: false, splitLine: { show: false, }, axisLabel: { show: false }, max: 900, min: 0 }, yAxis: { type: 'value', show: false, splitLine: { show: false, }, axisLabel: { show: false }, max: 0, min: -900 }, series: getSeries() }; // 使用刚指定的配置项和数据显示图表。 myChart.setOption(option); myChart.on("click", function(param){ console.log(param); alert(); });