Echarts设置x轴文字垂直显示、倾斜显示或省略显示

垂直显示:

let option = {
	xAxis:{
		//文字样式
		axisLabel: {
             show: true,                               
             textStyle: {
                color: '#595C61'
             },
             formatter:function(value){
				return value.split("").join("\n");
			 }
        }
	}
}

在这里插入图片描述

倾斜显示:

let option = {
	xAxis:{
		//文字样式
		axisLabel: {
             show: true,                               
             textStyle: {
                color: '#595C61'
             },
             rotate:45
        }
	}
}

在这里插入图片描述

省略显示:

let option = {
	xAxis:{
		//文字样式
		axisLabel: {
             show: true,                               
             textStyle: {
                color: '#595C61'
             },
             formatter:function(value){
				 if(value.length > 6){
                        return `${value.slice(0,4)}...`;
                 }
                 return value;
			 }
        }
	}
}

在这里插入图片描述

发布了258 篇原创文章 · 获赞 21 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/wsln_123456/article/details/104471691
今日推荐