Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show only integer values on yAxis of HighChart?

We have a set of a data that contains counts of instances of events. These can only be integers. When we display data that has a high enough yValue the yAxis labels are integers. However, when we zoom in to ranges of data that have under y = 5 we see the tick markers show things like 0.5, 0.75, 1.5, etc. How can we force the yAxis labels to only show integer values?

Here is an example bit of code with some data. As you zoom in to the lower value region of the chart you can see what I mean. This is the current yAxis setup:

yAxis: {   labels: {     style: {       fontSize: '9px',       width: '175px'     }   },   title: {     text: ''   } }, 
like image 672
wergeld Avatar asked Jan 09 '13 15:01

wergeld


1 Answers

Set the allowDecimals option in the y axis to false in order to prevent non integer tick marks from being displayed:

yAxis: {     allowDecimals: false,     labels: {         style: {             fontSize: '9px',             width: '175px'         }     },     title: {         text: ''     } } 

Here is a demonstration: http://jsfiddle.net/sBC9K/

like image 156
Asad Saeeduddin Avatar answered Sep 21 '22 06:09

Asad Saeeduddin