Echarts(五)双y轴0刻度线不对齐解决思路demo

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u014744118/article/details/81543012
option = {
    xAxis: {
        type: 'category',
        data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
    },
    yAxis: [{
        type: 'value',
        max: function(value) {
            if(Math.abs(value.max) > Math.abs(value.min)){
                return (Math.abs(value.max)*1.2).toFixed(2);
            }else{
                return (Math.abs(value.min)*1.2).toFixed(2);
            }
        },
        min: function(value) {
            if(Math.abs(value.max) > Math.abs(value.min)){
                return (-Math.abs(value.max) * 1.2).toFixed(2);
            }else{
                return (-Math.abs(value.min) * 1.2).toFixed(2);
            }
        }
    },
    {
        type: 'value',
        max: function(value) {
            if(Math.abs(value.max) > Math.abs(value.min)){
                return (Math.abs(value.max)*1.2).toFixed(2);
            }else{
                return (Math.abs(value.min)*1.2).toFixed(2);
            }
        },
        min: function(value) {
            if(Math.abs(value.max) > Math.abs(value.min)){
                return (-Math.abs(value.max) * 1.2).toFixed(2);
            }else{
                return (-Math.abs(value.min) * 1.2).toFixed(2);
            }
        }
    }],
    series: [{
        data: [120, 200, -150, 80, 70, -110, 130],
        type: 'bar',
        yAxisIndex: 1
    },
    {
        data: [120, 200, 150, 80, -70, 110, -130],
        type: 'bar'
    }]
};

猜你喜欢

转载自blog.csdn.net/u014744118/article/details/81543012