解决原理:找到两组数据分别对应的最大值,最小值,差,统一分割段数,分别求对应分割段数的分割距离
splitNumber:分割段数
interval:设置分割间距
max:大于等于各组数据中的最大值,计算招数数据中最大值之后取整
实现源码:
yAxis: [{
type: ‘value’,
name: ‘’,
axisTick: {
show: false,
},
axisLine: {
show: false,
},
splitNumber: 5,
interval:Math.ceil(Math.max.apply(null, this.barData) / 5),
max:Math.ceil(Math.max.apply(null, this.barData) / 5) * 5,
min:0,
axisLabel: {
},
splitLine: {
show:true,
lineStyle: {
color: ‘#ccc’
}
},
nameTextStyle: {
align: ‘left’,
padding: [0, 0, 0, -40]
}
},
{
type: ‘value’,
name: ‘’,
axisTick: {
show: false,
},
splitNumber: 5,
interval:Math.ceil(Math.max.apply(null, this.lineData) / 5),
max:Math.ceil(Math.max.apply(null, this.lineData) / 5) * 5,
min:0,
axisLine: {
show: false,
},
axisLabel: {
formatter: ‘{value}%’
},
}
],