echarts双y轴对齐

import * as echarts from 'echarts';

var chartDom = document.getElementById('main');
var myChart = echarts.init(chartDom);
var option;

option = {
    tooltip: {
        trigger: 'axis',
        axisPointer: {            // 坐标轴指示器,坐标轴触发有效
            type: 'shadow'        // 默认为直线,可选为:'line' | 'shadow'
        }
    },
    grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
    },
    xAxis: [
    {
        type: 'category',
      
        data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']
    }
],
yAxis: [
    {
        type: 'value',
        name: '蒸发量',
        max: Math.ceil(5.2/10)*10,
        min:  Math.ceil(-10/10)*10,
       interval: Math.ceil(15.2/10),
     
    },
    {
        type: 'value',
        name: '温度',
       max: Math.ceil(150.7/10)*10,
         min:  Math.ceil(-50/10)*10,
       interval: Math.ceil(200.7/10),
    }
],
series: [
    {
        name: '蒸发量',
        type: 'bar',
        data: [-10, 5.2]
    },
    {
        name: '降水量',
        type: 'bar',
        yAxisIndex:1,
        data: [-50, 2, 150.7]
    },
    
]
};

option && myChart.setOption(option);

你可能感兴趣的:(javaScript)