效果图:
隐藏了柱状图的X轴和Y轴和其余属性并且Y轴反向坐标轴 使其出现这样的效果
代码:
var AXIS_OPTION = {
tooltip: { //提示框
trigger: 'axis',
axisPointer: {
type: 'shadow',
},
},
grid: { //距离控制
width: '75%',
left: '30px',
right: '30px',
bottom: '4%',
top: '15%',
containLabel: true,
},
xAxis: { // x轴属性控制
type: 'value',
axisLine: {
show: false,
},
axisTick: {
show: false,
},
show: false,
},
yAxis: {
type: 'category',
data: [1,2,3,4,5],
splitLine: { show: false },
axisLine: {
show: false,
},
axisTick: {
show: false,
},
nameTextStyle: {
fontSize: 18,
},
inverse: true, //反向坐标轴
},
series: {
name: '协同参与度',
type: 'bar',
data: [],
barWidth: 12, // 柱体宽度
barGap: 10, //柱体距离
smooth: true,
label: {
normal: {
show: true,
position: 'right',
offset: [5, -2],
textStyle: {
fontSize: 14,
},
formatter: ['{c}', '{b|%}'].join(' '), //自定义显示模板
rich: {
b: {},
},
},
},
itemStyle: {
emphasis: {
barBorderRadius: 5,
},
normal: {
barBorderRadius: 4,
color: function (params) { //改变颜色关键代码
const colorList = [
'#457ef2',
'#ff5a5e',
'#24b29c',
'#a055ed',
'#e8aa07',
]
return colorList[params.dataIndex]
},
},
},
},
}