Toggle navigation
柱状图双标签
By
CrazyStroy
2018-12-23 13:50:54
脚本
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
图表已生成
整理代码
刷新
代码
//思路 将两条柱状图重合显示 一个label显示在中间一个显示在右边 let data1 = ['50', '100', '150']; let data2 = ['100', '120', '78']; option = { backgroundColor: '#fff', grid: { left: '5%', top: '1%', right: '2%', bottom: '1%', containLabel: true }, xAxis: [{ show: false, }], yAxis: [{ offset: '27', axisLabel: { textStyle: { color: '#192948', fontSize: '16', } }, data: ['寿命', '它故障', '画面不正常'] }, { axisTick: 'none', axisLine: 'none', show: false, axisLabel: { textStyle: { color: '#192948', fontSize: '16', } }, data: ['寿命', '它故障', '画面不正常'] }], series: [{ name: '红条', type: 'bar', yAxisIndex: 0, barGap: '0', data: data1, label: { normal: { show: true, position: 'inside', formatter: function(param) { return param.value; }, textStyle: { color: '#fff', fontSize: '16', } } }, barWidth: 50, z: 2 }, { name: '红条', type: 'bar', yAxisIndex: 1, barGap: '0', data: data1, label: { normal: { show: true, position: 'right', formatter: function(param) { var sum = data1.reduce((total, num) => { return Number(total) + Number(num); }); let rate = parseInt((param.value / sum) * 100).toFixed(); return rate + "%"; }, textStyle: { color: '#000', fontSize: '16', } } }, barWidth: 50, z: 1 }, { name: '黑条', type: 'bar', yAxisIndex: 0, barGap: '0', data: data2, label: { normal: { show: true, position: 'inside', formatter: function(param) { return param.value; }, textStyle: { color: '#fff', fontSize: '16', } } }, barWidth: 50, z: 2 }, { name: '黑条', type: 'bar', yAxisIndex: 1, barGap: '0', data: data2, barWidth: 50, z: 1 } ] };