score:1

Accepted answer

By default, Highcharts enforces to have ticks on round values. If you set the yAxis.min or yAxis.max to some value, that is not divisible by round tickInterval (e.g. 2, 5, 10, 20, 25, 50, 100), this value will be rounded to such.

There are some ways of setting ticks in the other way. The most enforcing ones are to set the tickPositions Array that strictly says, what the ticks should be on the given axis, or with tickFormatter function, which returns the tickPositions Array.

Example code:

let data = [1500, 1400, 1550, 1630, 1600],
  min = Math.min(...data),
  mid = (Math.max(...data) - Math.min(...data)) / 2 + Math.min(...data),
  max = Math.max(...data);
    
Highcharts.chart('container', {

  yAxis: [{
    tickPositions: [min, mid, max]
  }],

  series: [{
    data: data
  }]

});

Demo:

https://jsfiddle.net/BlackLabel/07kzt12x/

API References:

https://api.highcharts.com/highcharts/yAxis.tickPositions https://api.highcharts.com/highcharts/yAxis.tickPositioner


Related Articles