Highcharts: Ensure y-Axis 0 value is at chart bottom

后端 未结 8 1806
名媛妹妹
名媛妹妹 2021-02-05 02:18

I\'m outputting a series of highcharts on a page. In some instances, all data for the specified time period may come back with 0 values.

In such a case, the chart looks

8条回答
  •  孤独总比滥情好
    2021-02-05 03:03

    I had also posted this to the HighCharts forum, where I got a response that seems to work. Unfortunately, it will involve me doing some pre-processing of the data prior to rendering the charts in order to check for all "0" data values... but it'll work. Just wish there was something more "built-in" to HighCharts.

    So after summing up the "y" values, if I get 0, the y-axis properties should look like this:

    yAxis: {
        minPadding: 0, 
        maxPadding: 0,         
        min: 0, 
        max:1,
        showLastLabel:false,
        tickInterval:1,
        title: {
                text: ""
        }
    }
    

    See: http://jsfiddle.net/KM2Jx/2/

    The keys seem to be the "max" and "showLastLabel" properties.

提交回复
热议问题