Toggle navigation
数据完整率统计-- 合理处理Y轴显示文字很长的问题
By
金***灬
2018-12-07 02:01:57
脚本
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
图表已生成
整理代码
刷新
代码
//如果Y轴的描述文字很长,我们可以将文字显示在bar中,将数据显示在右侧。 //这样排版更加美观 //需要注意的是,要将bar的颜色的透明度调低。否则颜色会掩盖文字 var titlename = ['姓名', '身份证号', '年龄', '家庭住址', '籍贯']; var valdata = [98, 90, 86, 30, 10] var rateData = [100, 100, 100, 100, 100] option = { backgroundColor: 'white', //设置背景色 title: { text: '数据完整率统计', subtext: '人员登记信息完整率统计', show: true, }, grid: { left: '2%', right: '2%', containLabel: true //是否显示刻度 }, xAxis: { show: false, }, yAxis: [{ type: 'category', data: titlename, boundaryGap: true, axisLabel: { interval: 0, inside: true, textStyle: { color: '#222222', fontSize: 14 } }, axisTick: { show: false, }, axisLine: { show: false, }, splitLine: { show: false, } }, { show: true, data: valdata, axisLabel: { formatter: '{value}%', textStyle: { fontSize: 12, color: '#000', }, }, axisLine: { show: false }, splitLine: { show: false }, axisTick: { show: false }, }], series: [{ name: '条', type: 'bar', yAxisIndex: 0, data: valdata, label: { normal: { show: false, position: 'inside', color: '#222222', fontSize: 14, formatter: '{c}%' } }, itemStyle: { normal: { barBorderRadius: [10, 10, 10, 10], color: new echarts.graphic.LinearGradient(1, 0, 0, 0, [{ offset: 1, color: 'rgba(3,235,255, 0.3)' //将透明度设置成0.3,这样Y轴左侧的label能够显示出来来 }, { offset: 0, color: 'rgba(0,165,255, 0.5)' }]), }, }, }, { name: '框', type: 'bar', yAxisIndex: 1, barGap: '-100%', data: rateData, // barWidth: 30, itemStyle: { normal: { color: 'none', borderColor: '#00c1de', borderWidth: 2, barBorderRadius: [10, 10, 10, 10], } } }, ] };