2. x轴折行显示
leezozz 1/16/2023 echarts
//核心代码:
xAxis: {
type: 'category',
data: props.data.xData,
axisLabel: {
interval: 0, // 设置成 0 强制显示所有标签。如果设置为 1,表示『隔一个标签显示签』,如果值为 2,表示隔两个标签显示一个标签,以此类推
rotate: -45, // 倾斜角度
// 设置x轴折行
formatter:function(value: any) {
// 字符个数 / 2的位置折行
var targetLen = Math.floor(value.length / 2)
var newVal = value.slice(0, targetLen)
var newValue = value.slice(targetLen)
return newVal + '\n' + newValue
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17