echarts是一款很常用的插件,小编今天get到一个新技能!
1.有时我们会用到双Y轴,但右边的Y轴刻度不显示,这时,只要我们加上yAxisIndex: 1就OK啦!
series:[
{
name: '金额',
type: 'bar',
barWidth: '50%',
label: {
normal: {
show: true,
position: 'top'
}
},
data: []
},{
name: '数量',
type: 'line',
yAxisIndex: 1,
label: {
normal: {
show: true,
position: 'bottom'
}
},
data: []
}
]
2.当我们数据很大时,Y轴刻度会超出范围,显示不全,就像这样:

image.png
这时,只要我们,看下面
yAxis:[{
type: "value",
axisLabel: {
margin: 6,
formatter: function (value, index) {
if (value >= 10000 && value < 10000000) {
value = value / 10000 + "万";
} else if (value >= 10000000) {
value = value / 10000000 + "千万";
}
return value;
}
}
}],

image.png
喜欢就赞一个哦!