Limit y-axis to only integers in bar chart

6,009 views
Skip to first unread message

alfatek

unread,
Apr 6, 2011, 11:42:06 AM4/6/11
to jqplot-users
Hi,

I have a bar chart (http://www.jqplot.com/tests/barRendererTests.php)
and my data values are something like:
A -> 2
B -> 10
C -> 3
D -> 8

Now I want to limit the y-axis to only show integer values instead of
values like 2.2, 4.5, etc which doesn't make sense with my dataset.
Is it possible to use the auto option for the y-axis and still get
this? Any configuration or plugin for this?

gaurav korla

unread,
May 18, 2011, 8:06:46 AM5/18/11
to jqplot-users
axesDefaults:
{
useSeriesColor: true,
min: 1,
max: 3.1,
tickInterval: 1,
tickOptions: {
formatString: '%d'
}
},

The tickOptions will restrict the labels to display axis in integers
only and will igore the decimal values.

Chris Leonello

unread,
May 21, 2011, 8:30:32 AM5/21/11
to jqplot-users
Are you using the latest 1.0.0b1 build (available from bitbucket
downloads: https://bitbucket.org/cleonello/jqplot/downloads)? You
should get much better, "round number" ticks with that build. To get
the "rounder" ticks, you must NOT specify an axis min, max,
numberTicks or tickInterval. Let the plot figure everything out.

The format string, will just format the display of the tick value on
the plot. So, a tick value of 2.2 with %d format will show up as 2,
but the actual value will still be 2.2.

While this is what a format string is supposed to do, the desired
behavior by many users is for the format string to affect the actual
value of the tick. This causes confusion.

Felipe Moura Carvalho

unread,
Nov 8, 2016, 8:23:44 AM11/8/16
to jqplot-users
Thanks Guy this solution resolved my problem 

:)
Reply all
Reply to author
Forward
0 new messages