echart x轴标签文字过多显示被重叠的解决办法
解决办法
1、不显示全部标签,
xAxis: {
type: 'category',
data: xAxisData,
axisLabel: {
color: 'rgba(255,255,255,0.65)',
fontSize: 10,
interval: 'auto',
rotate: 15,
},
},
2、倾斜标签
xAxis: {
type: 'category',
data: xAxisData,
axisLabel: {
color: 'rgba(255,255,255,0.65)',
fontSize: 10,
rotate: 15,
},
},
3、 标签行换
xAxis: {
type: 'category',
data: xAxisData,
axisLabel: {
color: 'rgba(255,255,255,0.65)',
fontSize: 10,
formatter(value) {
// 每8字符换行
const str = value.replace(/(.{8})/g, '$1\n');
return `{a|${str}}`;
},
// 文本样式控制行间距
rich: {
a: { // 定义名为 'a' 的样式块
lineHeight: 16 // 行高设为20像素
}
}
},
},