简体   繁体   中英

How to set the x-axis to start at the bottom of the chart in highchart

When I have a chart and all the data are zero,the x-axis is centered. (jsfiddle)

but What I need is to start at bottom of the chart, like this:

How can I do this with HighChart.

Set yAxis max and min .

yAxis: {
    max: 0.06,
    min: 0
}

Demo

For dinamically modified.

function preventZeroLabel() {
    var axis = this.yAxis[0];
    if( -axis.min == axis.max ) {
        axis.setExtremes(0, 1, true);
    }
}

chart: {
    events: {
        load: preventZeroLabel,
        redraw: preventZeroLabel
    }
}

Demo

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM