Updating a Gauge with new data

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 Bernard Brault on 31st October 2013
Hi
I am new to RGraph and I have a few newby questions:

I am using Websockets to push new data to the page.
I want to update a gauge with the new data without using special effects.

Question #1:
Does this involves completely erasing the entire canvas and re-drawing the canvas, including the gauge that need updating?
or
Can RGraph selectively erase/re-draw (update)?
What is the recommended way to do this?

Question #2:
It relates to question #1 above.

In one example, I am using 2 gauges in one canvas: gauge1 and gauge2

                 gauge1.value = new_value_from_websocket;
                 RGraph.Clear(gauge1.canvas);
                 RGraph.RedrawCanvas(gauge1.canvas);

The above line of code re-draws both gauge1 and gauge2 so not exactly what I am looking for but it works!

Thank you for your help.
Posted by RGraph Support on 31st October 2013
Hi there,

1. Clearing the canvas and doing a redraw is the best way - though if you can then using the RGraph.Redraw() function is quicker to type!

2. Yes the RedrawCanvas function will redraw all charts that are registered for that canvas. You could use separate canvas tags for the two Gauges and then the RedrawCanvas function will just redraw the canvas tag that you specify.



Richard, RGraph Support
Please remember to link to the RGraph website

Help support RGraph - single site license only £99
    www.rgraph.net/license#single-site
Posted by RGraph Support on 31st October 2013
Hi there,

If you're limited for space here's something you could use - there's a similar example on the RGraph website already using one canvas - but this uses two:

www.rgraph.net/fiddle/view/an-example-of-two-gauge-charts-with-z-index-ordering



Richard, RGraph Support
Please remember to link to the RGraph website

Help support RGraph - single site license only £99
    www.rgraph.net/license#single-site

Add a reply




« Back to message list