Rescale Scatter chart X scale

Share RGraph:   To help my Google visibility (it can't get much worse!), if you like and use RGraph I'd appreciate it if you could link to me

« 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)
.
.set('xmax',secs)
.
.
.Draw();

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;
     RGraph.Clear(canvas);
     RGraph.Reset(canvas);
     RGraph.ObjectRegistry.Clear();
     draw(secs);
     }

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);



www.rgraph.net/fiddle/view/a-scatter-chart-showing-rescaling






Richard, RGraph Support
www.rgraph.net
If RGraph has helped you - please share the website - thanks!
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