Y axis labels are incorrect when all data values are 1.xxx ok if one or more values are > 1


« 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
Hi,

In the example below, the y-axis is shown as
  1
  1
  1
  0
  0
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="www.w3.org/1999/xhtml\">
   <head>
     <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/RGraph.bar.js"></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>

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

     <script>
       $(document).ready(function () {
         var bar = new RGraph.Bar(reportCanvas, [1,1,1]).draw();
       });
     </script>
   </body>
</html>

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

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

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





Richard
Posted by mark on 29th May 2014
Hi Richard,

Thank you for such a fast reply.

That worked a treat!

Cheers,

mark
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
Hi,

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

www.rgraph.net/fiddle/view.html/a-bar-chart-with-a-reduced-scale




Richard
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
RGraph on social media