Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting Highcharts maximum Y value to an exact amount without rounding

Every time I set my min and max values in Highcharts, I never get graphs with the exact min and max that I sent, but always something somewhat close. It seems as though Highcharts is picking a interval range for the axes and if my maximum doesn't conform to the right interval, it gets ignored or rounded off.

For example, if I set a min of 0 and a max of 3125 for a Y axis, I get a Y axis starting with 0 then going up in increments of 500 to a maximum of 3500, which is not at all what I want.

Can I get the chart to use an exact maximum or will it always round up in some wierd way?

like image 381
NoPantsJim Avatar asked Dec 15 '22 10:12

NoPantsJim


2 Answers

There are a couple of things that you can do.

1) set your tickInterval to a number that divides evenly into your max

2) set 'endOnTick' to false for your y axis, and set your maxPadding to 0. This will set the chart max to your specification, regardless of where the last tick falls.

http://api.highcharts.com/highcharts#yAxis.tickInterval

http://api.highcharts.com/highcharts#yAxis.maxPadding

http://api.highcharts.com/highcharts#yAxis.endOnTick

like image 51
jlbriggs Avatar answered May 25 '23 10:05

jlbriggs


Set the endOnTick property to false.

like image 41
Jérôme Avatar answered May 25 '23 09:05

Jérôme