Toggle navigation
等比拉升柱状图(升级版,可自由设置比例)
By
G***魂
2019-03-31 09:16:59
脚本
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 datas = [1500, 1, 12, 30, 4, 85, 6, 2, 11, 545]; var ax = 5; //真实y轴数据间隔 var ay = 10; //虚拟y轴数据比例 function setValue(datas) { var list = []; datas.forEach(function(data) { var x = 1, y = 1 / ay, newv = 0, z = 0; while (data > ax * x) { newv += ax; x *= ay; y *= ay; z += 1; } if (z > 0) { if (y > 1) { data -= (x / ay * ax); } else { data -= ax; } data = data / (x - y); } newv += data; list.push(newv); }); return list; } function getValue(data) { var x = 1, y = 1 / ay, newv = 0, z = 0; while (data >= ax * (z + 1)) { newv += ((x - y) > 1 ? (x - y) : 1) * ax; y *= ay; x *= ay; z += 1; } if (z > 0) { if (y > 1) { data -= z * ax; } else { data -= ax; } data = data * (x - y); } newv += data; return Math.round(newv); //return data; } function getYaxis(value) { var x = ay, y = 1, newval = 0, z = 0; while (value >= ax) { if (z > 0) { newval += (x - y) * ax; x *= ay; y *= ay; } else { newval += ax; } value = value - ax; z += 1; } return newval; } option = { backgroundColor: '#000', color: ['#2ea5c3', '#e08f68'], tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' }, formatter: function(params) { var tiplabel = params[0].name + '
' + '
' + params[0].seriesName + ':' + getValue(params[0].value) + '
' + '
' + params[1].seriesName + ':' + getValue(params[1].value); return tiplabel; } }, legend: { data: ['呼入量', '呼出量'], left: 'center', textStyle: { color: '#fff' } }, grid: { //top:80, left: 10, bottom: 50, right: 50, containLabel: true, }, xAxis: { type: 'category', data: [ 'a1', 'a2', 'a3', 'a4', 'a5', 'a6', 'a7', 'a8', 'a9', 'a10' ], axisLabel: { tooltip: { show: true, }, inside: false, textStyle: { fontSize: 16 }, interval: 0, color: '#00ffea' }, }, yAxis: [{ type: 'value', splitLine: { show: false }, axisLine: { lineStyle: { color: 'rgba(36,101,199,.5)', } }, axisLabel: { textStyle: { fontSize: 12 }, formatter: function(value) { return getYaxis(value); }, color: '#00ffea' }, minInterval: ax, maxInterval: ax }], series: [{ name: '呼入量', yAxisIndex: 0, //barMinHeight:5, barCategoryGap: '30%', itemStyle: { normal: { label: { show: true, position: 'top', color: '#fff', fontSize: 14, formatter: function(params) { return getValue(params.value); }, }, color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ offset: 0, color: '#1a9afe' }, { offset: 1, color: '#71b5e8' }]), opacity: 1, barBorderRadius: 20, shadowBlur: 20, shadowColor: 'rgba(0, 0, 0, 0.5)' } }, type: 'bar', data: setValue(datas) }, { name: '呼出量', yAxisIndex: 0, //barMinHeight:5, itemStyle: { normal: { label: { show: true, position: 'top', color: '#fff', fontSize: 14 }, color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ offset: 0, color: '#e12945' }, { offset: 1, color: '#f7734e' }]), opacity: 1, barBorderRadius: 20, shadowBlur: 10, shadowColor: 'rgba(0, 0, 0, 0.5)' } }, type: 'bar', data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } ] }