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 Query

More Query from same tag