Remove a circle from a chart

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 Nico Verduin on 21st March 2013
Hi I am using the following code to create a new circle and remove the previous one. However the old circle stays shown on the graph. I am using it with appcelerator.

         // *************************************************************
          // Eventlistener : EVENT_PLACE_CIRCLE
          // *************************************************************
     Ti.App.addEventListener('EVENT_PLACE_CIRCLE', function(e){
      //
      // first remove old circle
      //
        if (typeof(circle) == 'object') {
      Ti.API.info('remove circle');
           RGraph.ObjectRegistry.Remove(circle);
         circle = null;
      }
      //
      // place a circle on the point that is currently
      // selected on the coverflowview with the video's'
      //
          circlePt = e.gamenumber;
           circle = new RGraph.Drawing.Circle('cvs',line.coords[circlePt][0],line.coords[circlePt][1],5);
           circle.Set('chart.strokestyle', 'black');
           circle.Set('chart.fillstyle', 'rgba(255,0,0,0.7)');
           circle.Set('chart.shadow', true);
           circle.Draw();
         });

         // *************************************************************
          // Eventlistener : EVENT_REMOVE_LAST_MATCH_POINT
          // *************************************************************
 
Posted by RGraph support on 21st March 2013
Hi there,

The canvas is not automatically redrawn - so try calling:

RGraph.Redraw();

After you remove the circle.



Richard, RGraph Support

1 Year Priority Support now reduced to £299:
   www.rgraph.net/support
Posted by Enter your name... on 21st March 2013
I do not know what goes wrong, but It is asif it never gets back from the Redraw:
see the following code used:

         // *************************************************************
          // Eventlistener : EVENT_PLACE_CIRCLE
          // *************************************************************
     Ti.App.addEventListener('EVENT_PLACE_CIRCLE', function(e){
      //
      // first remove old circle
      //
        if (typeof(circle) == 'object') {
        
  Ti.API.info('circle exists');
  
           RGraph.ObjectRegistry.Remove(circle);
         circle = null;
         RGraph.Redraw(); // redraw the graph
      }
     
   Ti.API.info('circle Draw');

      //
      // place a circle on the point that is currently
      // selected on the coverflowview with the video's'
      //
          circlePt = e.gamenumber;
         
     Ti.API.info(circlePt);
  
           circle = new RGraph.Drawing.Circle('cvs',line.coords[circlePt][0],line.coords[circlePt][1],5);
           circle.Set('chart.strokestyle', 'black');
           circle.Set('chart.fillstyle', 'rgba(255,0,0,0.7)');
           circle.Set('chart.shadow', true);
           circle.Draw();
         });

I never see the next Ti.API.info line:
her are some log results

Mar 21 13:34:23 iPad-van-Nico Tennis Coach[2134] <Warning>: [DEBUG] Firing app event: EVENT_PLACE_CIRCLE
Posted by RGraph support on 21st March 2013
Hi there,

Try RGraph.RedrawCanvas() instead then:

var ca = circle.canvas;

RGraph.ObjectRegistry.Remove(circle);
circle = null;
RGraph.RedrawCanvas(ca)



Richard, RGraph Support

1 Year Priority Support now reduced to £299:
   www.rgraph.net/support
Posted by Enter your name... on 21st March 2013
Hi Richard

Seems it is not the Redraw causing it (so far) In the following code, it stops after the RGraph.ObjectRegistry.Remove(circle); statement.


         // *************************************************************
          // Eventlistener : EVENT_PLACE_CIRCLE
          // *************************************************************
     Ti.App.addEventListener('EVENT_PLACE_CIRCLE', function(e){
      //
      // first remove old circle
      //
        if (typeof(circle) == 'object') {
          
           RGraph.ObjectRegistry.Remove(circle);
          
      Ti.API.info('circle should be removed');

// circle = null;
         RGraph.Redraw(); // redraw the graph
      }
     
   Ti.API.info('circle Draw');

      //
      // place a circle on the point that is currently
      // selected on the coverflowview with the video's'
      //
          circlePt = e.gamenumber;
         
     Ti.API.info(circlePt);
  
           circle = new RGraph.Drawing.Circle('cvs',line.coords[circlePt][0],line.coords[circlePt][1],5);
           circle.Set('chart.strokestyle', 'black');
           circle.Set('chart.fillstyle', 'rgba(255,0,0,0.7)');
           circle.Set('chart.shadow', true);
           circle.Draw();
         });

The only code touching circle is below. If I remove the statement it works?
Posted by RGraph support on 21st March 2013
Hi there,

Try clearing the ObjectRegistry entirely and see what that does:

RGraph.ObjectRegistry.Clear();

Oh and try ensuring that it works on a browser - if not you'll be able to use the browser debug tools.

Richard, RGraph Support

1 Year Priority Support now reduced to £299:
   www.rgraph.net/support
Posted by Enter your name... on 21st March 2013
This is interesting. RGraph.ObjectRegistry.Clear() works, but of course clears the whole graph. Then draws my circle. Am I giving the wrong parameter to the Remove function? Or is it a bug?


         // *************************************************************
          // Eventlistener : EVENT_PLACE_CIRCLE
          // *************************************************************
     Ti.App.addEventListener('EVENT_PLACE_CIRCLE', function(e){
      //
      // first remove old circle
      //
        if (typeof(circle) == 'object') {
      RGraph.ObjectRegistry.Clear();
// RGraph.ObjectRegistry.Remove(circle);
          
      Ti.API.info('circle should be removed');

// circle = null;
         RGraph.Redraw(); // redraw the graph
      }
     
   Ti.API.info('circle Draw');

      //
      // place a circle on the point that is currently
      // selected on the coverflowview with the video's'
      //
          circlePt = e.gamenumber;
         
     Ti.API.info(circlePt);
  
           circle = new RGraph.Drawing.Circle('cvs',line.coords[circlePt][0],line.coords[circlePt][1],5);
           circle.Set('chart.strokestyle', 'black');
           circle.Set('chart.fillstyle', 'rgba(255,0,0,0.7)');
           circle.Set('chart.shadow', true);
           circle.Draw();
         });
Posted by RGraph support on 21st March 2013
Hi there,

No - in this approach you can clear everything and then recreate and redraw everything.



Richard, RGraph Support

1 Year Priority Support now reduced to £299:
   www.rgraph.net/support
Posted by Enter your name... on 21st March 2013
I just rewrote everyting to take this approach. See if it works

Thanks
Posted by Enter your name... on 21st March 2013
Hi Richard
Rewrote it all so it clears the whole registry and redraw everything. Works like a charm now.

Add a reply




« Back to message list