Bar chart: Dynamic re-load of data after click is drawn out of sync


« 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 Leon Friesema on 25th April 2013
I'm using a combined bar/line graph to show data. The bar graph is the data for the calculated line-graph, the server is using some bussinesslogic to calculate the new value.

When I use the bar-graph on a page using JSON/AJAX data and I want to repost a value to receive new data (let the server do some calculations) the redraw of the bar-graph is too late and/or out of sync.

Since the server is reposting data (in this case the server is localhost) the fiddle for this example will not work, but it's an example for the code I'm using; see: jsfiddle.net/MTXFt/1/

It's concerning line 21 (or actually 22..23)
Now when I post an alert on line 21 e.g. alert('drawing here'); and wait for about 1 or 2 seconds before pressing ok the redraw will work - although lower values than the original values will be drawn really strange (background lines running through the updated bar etc.).

For now the bar-graph is the most important one. Can anyone please help me out here?

regards,
Leon.
Posted by RGraph support on 25th April 2013
Hi there,

> (background lines running through the updated bar etc.)

This would suggest that you might have prior charts being drawn repeatedly. You can circumvent this by resetting your canvas before you draw the updated chart:

RGraph.Reset(canvas);

You can use the Reset() function instead of the clear function.

Also, this may or may not help:

dev.rgraph.net/fiddle/view/bdd58450becd3ef119908a3dd674e996

This doesn't create a new chart object - it updates the data on one object whenever the canvas is clicked and redraws the chart.




Richard, RGraph Support

5 developer license with Priority support for £299:
   www.rgraph.net/license#five-developer
Posted by Leon Friesema on 1st May 2013
Indeed the bars were drawn multiple times. We've rearranged the order of the events and all is working well - thanks for the information!

Regards,
Leon.

Add a reply

 




« Back to message list
RGraph on social media