The Y axis labels are incorrect when all of the data values are But They're OK if one or more values are > 1

Share RGraph:   Share or Like RGraph on Facebook!

« Back to message list

Enter your email address to get email updates on this topic. You can stop receiving updates by clicking the link in the update email messages.

Posted by mark on 29th May 2014

In the example below, the y-axis is shown as
which is incorrect. Changing the data to ALL 2's or 5's works ok and if any of the values is change to > 1 then axis is also correct, just an issue if all values are 1.

<!DOCTYPE html>
<html lang="en" xmlns="\">
     <script src="RGraph3_2014-03-28-stable/RGraph/libraries/RGraph.common.core.js"></script>
     <script src="RGraph3_2014-03-28-stable/RGraph/libraries/RGraph.common.dynamic.js"></script>
     <script src="RGraph3_2014-03-28-stable/RGraph/libraries/RGraph.common.tooltips.js"></script>
     <script src="RGraph3_2014-03-28-stable/RGraph/libraries/"></script>
     <script src="RGraph3_2014-03-28-stable/RGraph/libraries/RGraph.line.js"></script>
     <script src="RGraph3_2014-03-28-stable/RGraph/libraries/RGraph.pie.js"></script>
     <script src="RGraph3_2014-03-28-stable/RGraph/libraries/RGraph.common.key.js"></script>

     <script src="jquery-1.11.0.js"></script>
     <script src="jquery-ui-1.10.4.custom/jquery-ui-1.10.4.custom/js/jquery-ui-1.10.4.custom.js"></script>

     <canvas id="reportCanvas" width="550" height="250">[No canvas support]</canvas>

       $(document).ready(function () {
         var bar = new RGraph.Bar(reportCanvas, [1,1,1]).draw();

Many thanks for your great libraries and any comment you are able to make regarding my problem.

Posted by Richard on 29th May 2014
Try setting the scale.decimals to 1:

obj.set('scale.decimals', 1);

Posted by mark on 29th May 2014
Hi Richard,

Thank you for such a fast reply.

That worked a treat!


Posted by mvsagar on 8th March 2016
When I tried the solution I got labels such as 0.2, 0.4, 0.6, 0.8 and 1.0 on Y axis. But I think the solution is not appropriate if Y-axis represents some count, say, number of apples. Showing fraction on Y axis does not seem to make any sense. Is there any alternative solution so that we get Y axis labels as 0 and 1 if Y axis values for every point on X axis is 0 or 1?
Posted by Richard on 8th March 2016

If I understand correctly (I probably don't), you could try something like this:

Posted by mvsagar on 8th March 2016
I have figured out a solution. This is to set property ylabels.count to 1 if all Y axis values are <= 1.

Add a reply

« Back to message list