echarts 如何使柱状图左右展示_# 请教一下*echarts 中横向柱状图怎样实现类目名称显示在图表上方*的问题...

本文介绍了如何在Echarts 4.7.0版本中,将横向柱状图的类目名称显示在图表上方,以达到设计图的预期效果。通过调整Y轴配置,尝试将类目名定位到顶部,但遇到无法更改Y轴类目名位置的问题。示例代码中展示了包括tooltip、legend、grid、xAxis、yAxis和series等配置项的详细设置。
摘要由CSDN通过智能技术生成

echarts 版本

V4.7.0

预期效果

想还原设计图里的,横向柱状图将类目名称显示在图表上方的效果(如图)

实际效果

按官方示例 Demo 改了一个,但总是没法更改 Y 轴类目名位置的问题

配置代码

option = {

backgroundColor: '#071021',

tooltip: {

trigger: 'axis',

axisPointer: { // 坐标轴指示器,坐标轴触发有效

type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'

}

},

legend: {

data: ['违法数', '事故数', '死亡数'],

// right: '35%',

bottom: 'bottom',

itemGap: 10,

padding: [16,0],

itemWidth: 20,

itemHeight: 10,

textStyle: {

fontSize: 12,

fontWeight: 600,

color: '#C4D3F5'

}

},

grid: {

left: '3%',

right: '4%',

bottom: '3%',

containLabel: true

},

xAxis: {

type: 'value',

show: false,

},

yAxis: {

type: 'category',

show: true,

// itemStyle: {

// color: '#fff'

// },

data: ['西安纵横交通设施工程有限公司', '西安市双生吉福搬家服务部', '陕西明通交通设施工程有限公司', '扬力集团股份有限公司', '陕西西安路路通交通设施有限公司', '西安智达交通有限责任公司', '西安天畅交通设施有限责任公司','陕西中旺能源交通开发有限责任公司','蓝天巴士集团','西安菱力物流设备有限公司']

},

series: [

{

name: '违法数',

type: 'bar',

stack: '总量',

barGap: '-10%',

barWidth: '50%',

showBackground: true,

backgroundStyle: {

color: 'rgba(255,255,255,0.1)'

},

label: {

show: true,

position: 'inside',

// position: 'right',

color: '#ffffff',

fontSize: 15

},

data: [320, 302, 301, 334, 390, 330, 320,301, 334, 390],

itemStyle: {

color: '#0E9BD8',

// normal: {

// // show: true,

// // position: "top",

// }

},

},

{

name: '事故数',

type: 'bar',

stack: '总量',

label: {

show: true,

position: 'inside'

},

data: [120, 132, 101, 134, 90, 230, 210,120, 132, 101],

itemStyle: {

color: '#FEA900'

},

},

{

name: '死亡数',

type: 'bar',

stack: '总量',

label: {

show: true,

position: 'insideRight'

},

data: [220, 182, 191, 234, 290, 330, 310,220, 182, 191],

itemStyle: {

color: '#FF3D3D'

},

},

]

};

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值