Single click kills all charts

Share RGraph:   Share or Like RGraph on Facebook!

« 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 ItinerantEngineer on 12th November 2013
I am using RGraph with partial razor views. I have a partial that is called many times, once for each set of Inventory

@model IEnumerable<Inventory>

@if(Model.Any())
{
     //dummy data to try and isolate problem
     string djs = "[1,2,3,4,5]";

     var graphname = "inv" + Model.FirstOrDefault().Id;
    
     <canvas id="@graphname" width="300" height="200">[No canvas support]</canvas>
     <script src="@Url.Content("~/Scripts/jquery-ui-1.10.2.min.js")" type="text/javascript"></script>
     <script src="@Url.Content("~/Scripts/rgraph/RGraph.common.core.js")" type="text/javascript"></script>
     <script src="@Url.Content("~/Scripts/rgraph/RGraph.bar.js")" type="text/javascript"></script>

     <script type="text/javascript">
         var dataArray = @djs;
         new RGraph.Bar('@graphname', dataArray).Draw();
    </script>
}

This works fine when the page loads, I see all my graphs. But the moment I click on anything on the page, graph or canvas, or nothing, all the graphs disappear. No errors are reported in the console and the source code for javascript looks fine. Any ideas why that would happen?
Posted by RGraph support on 12th November 2013
Hi there,

Sorry - never heard of "razor views". If you're including the RGraph dynamic library (RGraph.common.dynamic.js) then you could try taking it out - this is the file where event listeners are added to the canvas - including a click, mousedown, mouseup, and also a click event is added to the window. So if you take out this file (if you're including it) then event listeners won't be installed.

If you wanted you could also add a console.trace() call into the RGraph.Clear function - which will log a stack trace to the console - so you might be able to trace it back from that.




Richard
Posted by Marco on 3rd January 2014
Hello,

Richard, on interactive bars graph removing the dynamic library does give a warning (for not including them). For this I am using: www.rgraph.net/demos/bar-interactive-key.html graph.

Like ItinerantEngineer, I also have complications about graphics disappearing when I have multiple graphs on screen (gauge + bars interactive).
I find that my Gauge graph disappears once I click on anything (window) but my interactive bars graph behaves just fine.

What seems to be the problem with the gauge graph? It doesn't seem to be with the "adjustable" event (mousemove) of it. In fact I set it to false.

Thanks.
Posted by Marco on 3rd January 2014
Hello Richard,

It seems that the objectRegistry has 7 (I'd suppose only 2) "bars" graph objects after clearing both (gauge + bars graphs). This is why it does not draw the 1st (gauge) graph. Will continue to debug to understand why this is happening.

Tks.
Posted by RGraph support on 3rd January 2014
Hi there,


If you need to clear the ObjectRegistry you can call RGraph.ObjectRegistry.Clear(). This docs page may also be handy if you're playing with the OR:

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

Also, smething that I had recently was that the user was using RGraph.Reset() instead of RGraph.Clear(). The Reset method clears the canvas AND removes any objects related to that canvas from the OR. This may not be applicable to you - but you may need to use RGraph.Clear instead of RGraph.Reset.


Richard

Add a reply




« Back to message list