How can I force multiple y-axis in Highcharts to have a common zero

后端 未结 7 1411
萌比男神i
萌比男神i 2021-01-02 00:32

See this JSFiddle. How do I get the y-axis zero to align?

7条回答
  •  甜味超标
    2021-01-02 00:53

    you can do it easily by following the below code-

    you just need to find which point of opposite y -axis meets zero of first y-axis and set the min of opp y-axis to (that point * -1)

    In my case yaxis[1] forms the main y-axis and yaxis[0] forms the opposite y-axis

     }, function(chart) { // on complete
            var factor = chart.yAxis[1].min  / chart.yAxis[1].tickInterval
            var tick = chart.yAxis[0].tickInterval;
            var _min = chart.yAxis[0].tickInterval * factor 
            chart.yAxis[0].update({ min: _min });
            chart.yAxis[0].update({ tickInterval: tick });
    
    
    
        });
    

提交回复
热议问题