Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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: ''
  }
},
question from:https://stackoverflow.com/questions/14238780/how-to-show-only-integer-values-on-yaxis-of-highchart

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
213 views
Welcome To Ask or Share your Answers For Others

1 Answer

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/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...