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

后端 未结 8 1926
名媛妹妹
名媛妹妹 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 02:47

    Since Highcharts 5.0.1, you can also use softMax.

    softMax: Number
    A soft maximum for the axis. If the series data maximum is greater than this, the axis will stay at this maximum, but if the series data maximum is higher, the axis will flex to show all data.

    yAxis: {
        min: 0,
        softMax: 100,
        ...
    }
    

    Here is an example with a column chart : http://jsfiddle.net/84LLsepj/

    Note that currently, in Highcharts 5.0.7, it doesn't seem to be working for all types of charts. As you can see in this other jsfiddle, it doesn't work with line chart.

提交回复
热议问题