How do I rescale my Scatter chart X scale?

« 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 Patrick on 3rd March 2014
I am tying to provide a slider for user input to rescale the xscale on a scatter chart. The xscale is originally set with
var line1 = new RGraph.Scatter('cvs', accel)

where secs is the variable holding the x axis max value.
I use the following to change the value of secs and call draw(secs) which is the function used to create the RGraph originally.

function xz()
     secs = document.getElementById("xhigh").value;

Whenever I draw with the changed xmax I get garbled negative values for the x scale.
By the way xmin is set to 0 and is not changed yet.
Posted by Richard on 3rd March 2014
Hi there,

It looks like you're setting the xmin value to a string. You should convert it to a number with the JavaScript Number() or parseInt() functions first then give it to RGraph, eg:

secs = Number(document.getElementById("xhigh").value);

Posted by Patrick on 3rd March 2014
Thanks for catching my error.
I did not find the example at fiddle, but I have to RGraph.ObjectRegistry.Clear(); because I have multiple graphs on the same canvas (multiple y scales). I have been using RGraph for about a week now.

Great software by the way!

Add a reply

« Back to message list