I'm not 100% on how you would do it in pure JS but using this API in
GWT you do the following:
Create your gauge object initially with your data and options passed
in then on a timer retrieve your new data and call gauge.draw with the
updated data.
t = new Timer() {
public void run() {
retrieveGaugeData();
if(gauge != null) {
gauge.draw(createGaugeData(), createGaugeOptions());
}
retriveJVMData();
}
};
t.scheduleRepeating(5000);
On Dec 4, 10:31 am, gman <[email protected]> wrote:
> If you take a simple gauge example like:
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml">
> <head>
> <meta http-equiv="content-type" content="text/html; charset=utf-8"/
>
> <title>
> Google Visualization API Sample
> </title>
> <script type="text/javascript" src="http://www.google.com/jsapi"></
> script>
> <script type="text/javascript">
> google.load('visualization', '1', {packages: ['gauge']});
> </script>
> <script type="text/javascript">
> function drawVisualization() {
> // Create and populate the data table.
> var data = new google.visualization.DataTable();
> var x=Math.floor(Math.random()*100);
> data.addColumn('string', 'Label');
> data.addColumn('number', 'Value');
> data.addRows(1);
> data.setValue(0, 0, 'Memory');
> data.setValue(0, 1, x);
>
> // Create and draw the visualization.
> new google.visualization.Gauge(document.getElementById
> ('visualization')).
> draw(data, null);
> }
>
> google.setOnLoadCallback(drawVisualization);
> </script>
> </head>
> <body style="font-family: Arial;border: 0 none;">
> <div id="visualization" style="width: 300px; height: 300px;"></
> div>
> </body>
> </html>
>
> How would I modify this code to update every 30 seconds and display a
> new value without refreshing the whole page?
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-visualization-api?hl=en.