需求:折线图实现双y轴,并实现不同的参数使用不同的y轴
方法:
1、yAxis中添加双轴
[{
type: 'value',
name: '温度',
axisLabel: {
formatter: '{value}℃'
}
},{
type: 'value',
name: '百分比',
min: 0,
max: 100,
axisLabel: {
formatter: '{value}%'
}
}]
其中
position:y轴的位置,
默认 grid 中的第一个 y 轴在 grid 的左侧('left'),第二个 y 轴视第一个 y 轴的位置放在另一侧。
2、series中添加参数yAxisIndex
[{
name: '送风温度(℃)',
type: 'line',
yAxisIndex: 1,
data: ary0
},{
name: '风机速度反馈(%)',
type: 'line',
yAxisIndex: 1,
data: ary8
}]
yAxisIndex默认是0,即使用第一个y轴设置0,地位个y轴设置1
效果图: