Re: how to do not show decimals in vAxis?

1,104 views
Skip to first unread message

asgallant

unread,
Sep 24, 2012, 1:40:18 PM9/24/12
to google-visua...@googlegroups.com
What you do here depends on what the actual cause of the decimals appearing is.  The first is caused by gridlines falling on non-integer values (ie, if your axis goes from 0-10, you get values of 0, 2.5, 5, 7.5, and 10 on the axis); the second is having an unwanted significant digit on the axis values (ie, 0, 10.0, 20.0, 30.0, 40.0).

To fix the first, use some combination of the three vAxis suboptions: minValue, maxValue, and gridlines.count.  If minValue and maxValue are integers, and (maxValue - MinValue) / (gridlines.count - 1) is an integer, then there will be no decimals.  By default, the API sets minValue and maxValue automatically, and gridlines.count is 5.

To fix the second, set vAxis.format to "#" (or any other ICU decimal pattern with no decimal digits).

The second solution can be applied in the first case, but your axis values won't be accurate (ie, a line drawn at 7.5 will be labeled as 8).

On Monday, September 24, 2012 10:21:16 AM UTC-4, Patrike wrote:
My LineChart are showing some decimals... but I have only integers to show...do I have an option to do not show decimals, instead of show only integers?

Thanks.

Patrike

unread,
Sep 26, 2012, 8:45:05 AM9/26/12
to google-visua...@googlegroups.com
Thanks for the reply... my case is the first one... the v and h axes are automatic calculated (see attach)... and i have no idea on how to 'fix' it, even with your orientation...
Thanks again...
chart.JPG

asgallant

unread,
Sep 26, 2012, 1:41:31 PM9/26/12
to google-visua...@googlegroups.com
If your values will always be relatively small (between 0 and 4), the easiest way to fix it would be to set vAxis.minValue to 0 and vAxis.maxValue to 4.  If your values can be larger than 4 or smaller than 0, then you need a bit more dynamic solution that takes the min and max values of your data into account.  See both in action here: http://jsfiddle.net/asgallant/wgq86/
Reply all
Reply to author
Forward
Message has been deleted
0 new messages