How to redraw after each AJAX request

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 Kyle on 10th October 2012
Hi,

Id like to know how to redraw a line chart after making an ajax request with changed parameters.

Right now it updates fine, but it draws infinitely ontop of each other.
Ive tried using Rgraph.Clear() but to no avail.

Can anybody help?

Thanks
Posted by RGraph Support on 10th October 2012
Hi,

Are you creating a new object each time? If so then because the old objects are being "remembered" you'll need to remove them from the ObjectRegistry like this:

RGraph.ObjectRegistry.Clear();

or this:

RGraph.ObjectRegistry.Remove(obj);

Alternatively you can just update the data properties of of the first object and redraw the chart. With the line chart it's called "original_data". So it would go like this:

obj.original_data = myNewData;
RGraph.Clear(canvas);
obj.Draw();
Posted by Kyle on 10th October 2012
Thanks alot, works like a charm now :)

Also without reading your reply to my other question...I finally figured out on my own, the problem with the JSON.
Returning a string "[2,2,1]" instead of a real array.
rrrrgh, thanks anyways
  :)

Add a reply




« Back to message list