mohammad
mohammad

Reputation: 61

Highchart always show max value for y Axis

I set the max value for yAxis but in some situation, I see a value more than max value that I set for Highchart.

I need in any situation max value will be shown in yAxis.

Upvotes: 1

Views: 1129

Answers (2)

Kamil Kulig
Kamil Kulig

Reputation: 5826

By default Highcharts computes values for ticks and may round up the maximum extreme so that it has the same value as the last tick.

You can modify ticks in tickPositioner callback to make sure that the max value will always be shown as a tick:

  yAxis: {
    max: 110,
    min: -20,
    tickPositioner: function() {
      var tickPositions = this.tickPositions,
        lastTick = tickPositions[tickPositions.length - 1],
        max = this.options.max;

      if (lastTick > max) {
        tickPositions.pop(); // remove last tick
        tickPositions.push(max);
      }
    }
  },

Live demo: http://jsfiddle.net/kkulig/8k4skeh9/

API reference: https://api.highcharts.com/highcharts/xAxis.tickPositioner

Upvotes: 1

Core972
Core972

Reputation: 4114

With tickInterval (API) it's works

Fiddle

Edit : For dynamic data you can use SetExtreme method API or update to update the tickInterval API

Upvotes: 0

Related Questions