Toggle navigation
By
衰***命
2020-09-25 11:27:10
脚本
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
图表已生成
整理代码
刷新
代码
function contains(arr, dst) { var i = arr.length; while (i -= 1) { if (arr[i] == dst) { return i; } } return false; } var attackSourcesName = ['1栋609','6栋315','7栋215','4栋326','8栋714','6栋509','7栋617','8栋203','3栋209','8栋225']; var attackSourcesData =[157,125,98,88,76,62,55,43,36,22]; var attackSourcesColor=[{ x: 0, y: 0, x2: 1, y2: 0, colorStops: [{ offset: 0, color: '#FF7E7C' // 0% 处的颜色 }, { offset: 1, color: '#FF6061' // 100% 处的颜色 }], },{ x: 0, y: 0, x2: 1, y2: 0, colorStops: [{ offset: 0, color: '#F9C270' // 0% 处的颜色 }, { offset: 1, color: '#F9A146' // 100% 处的颜色 }], },{ x: 0, y: 0, x2: 1, y2: 2, colorStops: [{ offset: 0, color: '#F9C270' // 0% 处的颜色 }, { offset: 1, color: '#F9A146' // 100% 处的颜色 }], },{ x: 0, y: 0, x2: 1, y2: 0, colorStops: [{ offset: 0, color: '#5CC0FF' // 0% 处的颜色 }, { offset: 1, color: '#5998FF' // 100% 处的颜色 }], }] function attackSourcesDataFmt(sData) { var sss = []; sData.forEach(function(item, i) { itemStyle = { color: i > 3 ? attackSourcesColor[3] : attackSourcesColor[i] } sss.push({ value: item, itemStyle: itemStyle }); }); return sss; } option = { tooltip: { show: true, textStyle: { fontSize: 16 }, }, legend: { show: false }, grid: { top:10, bottom:15, left: 130, right:40 }, xAxis: { type: 'value', splitLine: { show: false }, axisLabel: { show: false }, axisTick: { show: false }, axisLine: { show: false } }, yAxis: { type: 'category', inverse: true, axisLine: { show: false }, axisTick: { show: false }, axisPointer: { label: { show: true, margin: 30 } }, data: attackSourcesName, axisLabel: { margin: 88, fontSize: 14, align: 'left', color: '#666', rich: { nt1: { color: '#fff', backgroundColor: '#FF7E7C', width: 20, height: 20, align: 'center', fontSize:14, borderRadius: 100 }, nt2: { color: '#fff', backgroundColor: '#F9C270', width: 20, height: 20, align: 'center', fontSize:14, borderRadius: 100 }, nt: { color: '#EAA53D', width: 20, height: 20, align: 'center', fontSize:14, borderRadius: 100 }, title: { color: '#666', width: 50, fontSize:14, align: 'left', padding: 0, } }, formatter: function(value, index) { index = contains(attackSourcesName, value) + 1 if (index - 1 ===0) { return [ '{nt1|' + index + '}' + ' {title|' + value + '}' ].join('\n') }if (index - 1 >0 && index - 1 <3) { return [ '{nt2|' + index + '}' + ' {title|' + value + '}' ].join('\n') } else { return [ '{nt|' + index + '}' + ' {title|' + value + '}' ].join('\n') } } } }, series: [{ type: 'bar', barWidth: '10px', data: attackSourcesDataFmt(attackSourcesData), itemStyle: { normal: { color: function(params) { return attackSourcesColor[params.dataIndex > 3 ? 3 : params.dataIndex] }, barBorderRadius: 5, } }, label: { show: true, position: 'right', color: '#666666', fontSize: 16, offset: [5, 0] } } ] };