Chart does not disappear


« 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 Kai on 13th February 2013
Hello everybody,
I`m quite impressed about RGraph, but I have the following problem:

I combine a bar-graph and a line-graph in one canvas, this works great :-)

But somehow in my application a graph, that I never created appears and I can`t delete ist. I deleted all the cache, I restarted browser and computer (it appears in all browsers I tested).

I know that page:
www.rgraph.net/docs/misc.html/#clear.canvas

...so I put in my application

*****
RGraph.Reset(cvs);
RGraph.ObjectRegistry.Clear();
RGraph.ObjectRegistry.Clear(cvs);
RGraph.ObjectRegistry.Remove(cvs);
<canvas id='cvs' width='600' height='250'>[No canvas support]</canvas>
  <script>
bar = new RGraph.Bar('cvs', [$jan_bar,$feb_bar,$maerz_bar,$april_bar,$mai_bar,$juni_bar,$juli_bar,$aug_bar,$sep_bar,$okt_bar,$nov_bar,$dez_bar]);
.....
......
***********************
...to create the graph I want. That one is well created but there is that weird graph as well!????

Firebug shows me the code of the "undeletable" chart:
*****************
<canvas id="cvs" height="250" width="600" style="visibility: visible; cursor: default;">[No canvas support]</canvas>
<script>
bar = new RGraph.Bar('cvs', [,,,,,,,,,,,]); bar.Set('ymax', -353.16); bar.Set('ylabels.count', 5); bar.Set('lab..........
*******************
.....I have no idea where it comes from and how I can delete it....
Can anybody give me a hint please?

Thank you very much, Kai
Posted by RGraph support on 13th February 2013
Hi,

These:

RGraph.Reset(cvs);
RGraph.ObjectRegistry.Clear();
RGraph.ObjectRegistry.Clear(cvs);
RGraph.ObjectRegistry.Remove(cvs);

Should be after your canvas tag (unless you're using the window.onload event etc). Plus you should pass the canvas DOM object to the Reset function:

canvas = document.getElementById('cvs');
RGraph.Reset(canvas);

So put the Reset call after the canvas and use the canvas object instead of a string.


Richard, RGraph Support

1 Year Premium Support now reduced to £299:
   www.rgraph.net/support
Posted by Kai on 13th February 2013
Hi Richard,

thank you very much; I found out it works also with that function:

        function chartUnload() {
      var el = new Array();
      var elemsCanvas = document.getElementsByTagName("canvas");
      for (var i=0; i<elemsCanvas.length; i++) {
          if (typeof(elemsCanvas[i]) != 'undefined' && elemsCanvas[i].id.indexOf("__rgraph") == 0) {
              el.push(elemsCanvas[i].id);
          }
      }
      var elemsDiv = document.getElementsByTagName("div");
      for (var i=0; i<elemsDiv.length; i++) {
          if (typeof(elemsDiv[i]) != 'undefined' && elemsDiv[i].id.indexOf("__rgraph") == 0) {
              el.push(elemsDiv[i].id);
          }
      }

      for (var i = 0; i < el.length; i++) {
          var elNode = document.getElementById(el[i]);
          if (elNode.parentNode) {
              elNode.parentNode.removeChild(elNode);
          }
          else {
              document.body.removeChild(elNode);
          }
      }

  
      var firstDiv = document.getElementsByTagName("div")[0];
      if (firstDiv.innerHTML == 'M') {
          firstDiv.parentNode.removeChild(firstDiv);
      }

      scatterChart = null;
      data = [];
      labels = [];

      RGraph.ObjectRegistry.Clear();
}

Add a reply

 




« Back to message list
RGraph on social media