各位佬们,想问下echarts中如何让y轴的刻度标签单独一行显示?比如上面一行是XXX,下面就是对应的柱状图,如下图
翻了半天echarts文档,只找到个inside属性好像有点用又好像没多少用,没法让axisLabel刻度标签偏移到上方,活动范围只能在柱状图的高度里面。而且刻度标签还会被柱状图给遮挡住,下面是我尝试的代码:
import * as echarts from 'echarts';
var chartDom = document.getElementById('main');
var myChart = echarts.init(chartDom);
var option;
option = {
xAxis: {
type: 'value',
gridIndex: 0,
axisTick: {
show: false
},
axisLabel: {
show: false
},
axisLine: {
show: false
},
splitLine: {
show: false
}
},
yAxis: {
// type: 'value',
data: [
'Mon',
'Tue',
'Wed',
'Thu',
'Fri',
'Sat',
'Sun',
'Tue',
'Wed',
'Thu',
'Fri',
'Sat',
'Sun',
'Tue',
'Wed',
'Thu',
'Fri',
'Sat',
'Sun'
],
axisLabel: {
inside: true,
z: 100,
// margin:200,
// backgroundColor:"#f66",
color: '#f66',
fontSize: 24
// height:55
},
axisTick: {
show: false
},
axisLine: {
show: false
}
},
series: [
{
data: [
120, 200, 150, 80, 70, 110, 130, 200, 150, 80, 70, 110, 130, 200, 150,
80, 70
],
type: 'bar',
itemStyle: {
normal: {
color: {
type: 'linear',
x: 0,
y: 0,
x2: 1,
y2: 0,
colorStops: [
{
offset: 0.1,
color: '#0F89FF' // 10% 处的颜色
},
{
offset: 0.55,
color: '#31AEE9' // 55% 处的颜色
},
{
offset: 1,
color: '#00D5D9' // 100% 处的颜色
}
],
global: false // 缺省为 false
},
label: {
show: true,
position: 'right',
backgroundColor: 'transparent',
textStyle: {
color: '#86909C',
fontSize: 16,
textBorderWidth: 1,
textShadowOffsetY: 1,
textShadowColor: '#000000',
textShadowBlur: 2
}
},
barBorderRadius: 3
}
}
}
]
};
option && myChart.setOption(option);
该方案已解决我的问题https://blog.csdn.net/orangeverity/article/details/107160849