RGraph reloads the previous chart when I reload the page and I click on the body of the page

i use this to clear charts:

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

when I reload the previous page and a new chart is placed above the last, and a new label is placed above the last.

I use charts for donuts and circles

thankss !!!

+6
source share
2 answers

You need to clear the ObjectRegistry that tracks the objects. You can do it with:

 RGraph.ObjectRegistry.Clear(); 

Or you can clear the objects associated with a particular canvas tag with:

 RGraph.ObjectRegistry.Clear(myCanvas); 

Or you can delete a specific object with:

 RGraph.ObjectRegistry.Remove(myObject); 

You can read more about ObjectRegistry in the API documentation page:

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

+9
source

You can also use RGraph.Clear (document.getElementById ("Your item id"));

+2
source

Source: https://habr.com/ru/post/917203/


All Articles