Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RGraph reload the previous graph when i reload the page and i click the body of the page

Tags:

rgraph

i use that for clear the graphs:

for (var i=0; i< document.getElementsByTagName('canvas').length; i++) {
RGraph.Clear(document.getElementsByTagName('canvas')[i]);
}

when i reload the page the previous appear and the new graph is placed over the last one, and the new label is placed above the last one

i use donut and pie charts

thankss!!!

like image 670
Santiago Elvira Ramirez Avatar asked Jun 01 '12 16:06

Santiago Elvira Ramirez


2 Answers

You need to clear the ObjectRegistry, which keeps track of objects. You can do that with:

RGraph.ObjectRegistry.Clear();

Or you can clear objects related to a specific canvas tag with:

RGraph.ObjectRegistry.Clear(myCanvas);

Or you can remove a specific object with:

RGraph.ObjectRegistry.Remove(myObject);

You can read more about the ObjectRegistry on the API docs page:

https://www.rgraph.net/canvas/api.html#objectregistry

like image 87
Richard Avatar answered Nov 19 '22 02:11

Richard


You can also use RGraph.Clear(document.getElementById("The Id of your element"));

like image 35
Happy Avatar answered Nov 19 '22 04:11

Happy