Which event signals that a graph is entirely rendered?

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 Jarle on 20th November 2012
Hi,

I want to export a PNG of a line graph as soon as it is rendered (and immediately close the canvas). I found that a line with a background image generates two 'ondraw' events, one after everything is rendered except the background image, and the second one after the rendering of the background image.

This results in the following two-stage code:
graph.ondraw = function(){ graph.ondraw = myGraph.exportImage; };

Is this normal behaviour?
Is there an event, which signals that everything is ready?

Thanks.
Posted by RGraph support on 20th November 2012
Hi,

It's normal behaviour yes because the background image has to load before the image can be used as the background. Thus it may take a few milliseconds to load then the chart is redrawn.

What I've now done is add a property that gets set when the images onload event is triggered (and thus the chart is redrawn). So in your ondraw code you can check this property and if it's true then it's (probably) the second time that the event has fired.


All being well this will be a part of the next beta.
Posted by Jarle on 20th November 2012
Thank you for your quick reply!

Add a reply




« Back to message list