Highcharts - Keep Zero Centered on Y-Axis with Negative Values

前端 未结 5 825
灰色年华
灰色年华 2021-02-13 03:18

I have an area chart with negative values. Nothing insanely different from the example they give, but there\'s one twist: I\'d like to keep zero centered on the Y axis.

5条回答
  •  心在旅途
    2021-02-13 04:12

    I know this is an old post, but thought I would post my solution anyway (which is inspired from the one macserv suggested above in the accepted answer) as it may help others who are looking for a similar solution:

    tickPositioner: function (min, max) {
                var maxDeviation = Math.ceil(Math.max(Math.abs(this.dataMax), Math.abs(this.dataMin)));
                return this.getLinearTickPositions(this.tickInterval, -maxDeviation, maxDeviation);
            }
    

提交回复
热议问题