Using the ymax option on a Line chart causes a displacement bug

« 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 Kacper on 28th December 2013
Setting ymax value on line graph displaces plot position or its scale is incorrect:

Without setting 'ymax':
With 'ymax' value set :

Please note misplaced integer values on second screenshot.


<!DOCTYPE html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="scripts/RGraph.common.core.js" ></script>
<script type="text/javascript" src="scripts/RGraph.line.js" ></script>
<body onload="init()">
<canvas id="cvs" width="600" height="400">[No canvas support]</canvas>
  window.onload = function ()
   var line = new RGraph.Line('cvs', [0,2,1,5,2]);
   line.Set('ymax', 6)
Posted by RGraph support on 28th December 2013
Hi there,

It looks like it's due to rounding - try setting scale.decimals to 1 or 2.

Posted by Kacper on 29th December 2013
Ok, thats it, but how to acheive proper integer scale? I want my grid lines without decimal places. I want to plot a curve with some additional space from the top, so it won't be drawn on the plot border. To do this I set ymax to max curve value + 1. Is there a different proper way to do it?
Posted by Kacper on 29th December 2013
Ok, I've done it with
line.Set('numyticks', 5)
.Set('background.grid.autofit.numhlines',5).Set('ymax', 15)
.Set('chart.ylabels.specific', [15,12,9,6,3,0]);

but I think proper grid lines and labels should be automatically set by default

Posted by RGraph support on 29th December 2013
Hi there,

There's no vertical margin - it would affect the scale adversely. There's only the hmargin property for a horizontal margin.


Add a reply

« Back to message list