Toggle navigation
流程图
By
儒雅的dts
2018-10-29 05:20:46
脚本
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
图表已生成
整理代码
刷新
代码
//浏览器resize重画 function resizeChart() { var w = $('body').width(); var h = $('body').height(); myChart.resize({ width: w, height: h }); option.series = getSeries(); myChart.setOption(option, true); } var data = [{ name: 'asdd_fact', code: 'node1', value: { interfaceNum: 'date ', kpiNum: 'order', alarmNum: 'cnt ' }, x: 0.35, y: 0.65 }, { name: 'asdd_t1', code: 'node5', value: { interfaceNum: 'date ', kpiNum: 'order', alarmNum: 'client' }, x: 0.1, y: 0.65 },{ name: 'date_cnt', code: 'node2', value: { interfaceNum: 'date', kpiNum: 'cnt ', alarmNum: 'xxx ' }, x: 0.55, y: 0.8 }, { name: 'order_cnt', code: 'node3', value: { interfaceNum: 'client', kpiNum: 'cnt ', alarmNum: 'xxx ' }, x: 0.55, y: 0.5 }, { name: 'client_cnt', code: 'node4', value: { interfaceNum: 'client', kpiNum: 'cnt ', alarmNum: 'xxx ' }, x: 0.8, y: 0.5 }]; var links = [{ source: 'node1', target: 'node2', }, { source: 'node5', target: 'node1', },{ source: 'node1', target: 'node3', }, { source: 'node3', target: 'node4', }]; var line = 3; //行:把画布上画几行信息框 var column = 4; //列:把画布上画几列信息框 function getScatterData() { var scatterData = []; //画布宽高 var c_w = myChart.getWidth(); var c_h = myChart.getHeight(); //计算信息框的宽高 var w = c_w / (column * 2); var h = c_h / (line * 2); for (var i = 0; i < data.length; i++) { //把消息框分为两部分:标题和内容,内容高度为标题高度的3倍,echart是以中心画图,所以要分别计算标题和内容框的中心点位置 scatterData.push({ name: data[i].name, value: [data[i].x, (data[i].y * c_h + (3 / 8 * h)) / c_h], type: 'title', w: w, h: h / 4, label: { normal: { textStyle: { color: '#fff', fontWeight: 'bold', fontSize: 15 } } } }, { code: data[i].code, value: [data[i].x, (data[i].y * c_h + (1 / 4 * h) - (3 / 4 * h) / 2) / c_h], type: 'body', w: w, h: 3 / 4 * h, info: data[i].value, label: { normal: { textStyle: { color: '#000' } } } }); } return scatterData; } function getLinesData() { var linesData = []; var map = {}; for (var i = 0; i < data.length; i++) { map[data[i].code] = data[i]; } for (var i = 0; i < links.length; i++) { var source = map[links[i].source]; var target = map[links[i].target]; //画布宽高 var c_w = myChart.getWidth(); var c_h = myChart.getHeight(); //计算信息框的宽高 var w = c_w / (column * 2); var h = c_h / (line * 2); //计算信息框的四个边中点的位置 source.top = { x: source.x, y: (source.y * c_h + (1 / 2 * h)) / c_h }; source.right = { x: (source.x * c_w + (1 / 2 * w)) / c_w, y: source.y }; source.bottom = { x: source.x, y: (source.y * c_h - (1 / 2 * h)) / c_h }; source.left = { x: (source.x * c_w - (1 / 2 * w)) / c_w, y: source.y }; target.top = { x: target.x, y: (target.y * c_h + (1 / 2 * h)) / c_h }; target.right = { x: (target.x * c_w + (1 / 2 * w)) / c_w, y: target.y }; target.bottom = { x: target.x, y: (target.y * c_h - (1 / 2 * h)) / c_h }; target.left = { x: (target.x * c_w - (1 / 2 * w)) / c_w, 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] ])); } //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] ])); } //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] ])); } //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] ])); } } return linesData; } function getLine(coords) { return { name: '', type: 'lines', coordinateSystem: 'cartesian2d', symbol: ['none', 'arrow'], symbolSize: 10, zlevel: 4, effect: { show: true, period: 4, trailLength: 0.5, color: '#7480BC', symbolSize: 3 }, lineStyle: { normal: { color: '#B0C4DE', width: 1, curveness: 0 } }, data: [{ coords: coords }] }; } function getSeries() { var series = []; series.push({ type: 'scatter', symbol: 'rect', zlevel: 2, silent: true, symbolSize: function(value, params) { return [params.data.w, params.data.h]; }, itemStyle: { normal: { shadowBlur: 10, shadowColor: 'rgba(120, 36, 50, 0.5)', shadowOffsetY: 5, color: function(params) { if (params.data.type == 'title') { return '#88359A'; } else { return '#D8BFD8'; } } } }, label: { normal: { show: true, position: 'inside', formatter: function(params) { if (params.data.type == 'title') { return params.data.name; } else { return 'col1' + params.data.info.interfaceNum + '\ncol2' + params.data.info.kpiNum + '\ncol3' + params.data.info.alarmNum; } }, textStyle: { color: '#000' } } }, data: getScatterData(), }); return series.concat(getLinesData()); } option = null; option = { backgroundColor: '#F3F3F3', title: [{ text: "流程图", x: '5%', y: 0, textStyle: { color: '#333', fontStyle: 'normal', fontWeight: 'normal', fontFamily: 'sans-serif', fontSize: 14, } }], tooltip: { /*trigger: 'axis', axisPointer: { show: true, type: 'cross' }*/ }, grid: { left: 0, right: 0, top: 0, bottom: 0 }, xAxis: { type: 'value', splitLine: { show: false, }, axisLabel: { show: false }, max: 1, min: 0 }, yAxis: { type: 'value', splitLine: { show: false, }, axisLabel: { show: false }, max: 1, min: 0 }, series: getSeries() };