How to get only whole numbers on the y-axis?
Asked Answered
H

5

41

I'm using highcharts. When I get small numbers in my series the y-axis starts using floating numbers. How can I force it to only use whole numbers regardless of my data?

Note: I do have a minimum set to "4", so even when there is one result to y-axis range will be 0-4.

Hydrography answered 7/6, 2013 at 4:6 Comment(2)
can you provide a working example on fiddler?Misunderstanding
possible duplicate of How To Show Only Integer Values On yAxis Of HighChartRutherfurd
O
68

Set allowDecimals: false, see API.

Overcasting answered 7/6, 2013 at 13:7 Comment(3)
I searched the API docs highstock yaxis whole numbers and it said string not found but Google gave me this answer instantly. Google + Stackoverflow > APIPostpaid
and how to restrict to whole numbers when you drag and drop points?Guienne
See this question on github.Fraase
B
5

You can try using the tickInterval.

Setting tickInterval to a whole number should do the trick you require.

   yAxis: {
            tickInterval: 5
        }

Working Demo

Bolten answered 7/6, 2013 at 7:21 Comment(0)
P
1

Please apply the yAxis property as min: 0 and tickInterval: 1. which is used to show only the positive area of Y axis.

  yAxis: {
        tickInterval: 1,
        min: 0
    }
Passional answered 5/1, 2018 at 10:21 Comment(0)
H
0

Can you please apply the yAxis property as min: 0. which is used to show only the positive area of Y axis.

Haiduk answered 7/6, 2013 at 10:4 Comment(0)
L
0

I am using version "echarts": "^5.3.2",

This solution worked for me by setting min interval to 1:

yAxis: {
    minInterval: 1,
 }

refer : https://echarts.apache.org/en/option.html#yAxis.minInterval

Larceny answered 5/10, 2023 at 6:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.