That's what I suspected >;o)

The DataTable for gauges needs two columns: 1 string and 1 number.  The 
first column contains the label for the gauge and the second contains the 
value (see 
http://code.google.com/apis/ajax/playground/?type=visualization#gauge).  Try 
this instead:

var gaugeData;
var chart;
var options;

function getMyForm() {
    gaugeData = new google.visualization.DataTable();
    gaugeData.addColumn('string', 'day');
    gaugeData.addColumn('number', 'value');
    gaugeData.addRows(1);
    gaugeData.setCell(0, 0, 'Today');
    gaugeData.setCell(0, 1, 0);

    options = {
        min:0,
        max:150,
        width: 175,
        height: 175,
        redFrom: 0, 
        redTo: 60, 
        yellowFrom:60,
        yellowTo: 90,
        greenFrom:90,
        greenTo:100,
        minorTicks: 5,
        backgroundColor: '#999999'
    };

    chart = new google.visualization.Gauge(document.getElementById(
'menuMyFormChartDiv'));
    chart.draw(gaugeData, options);
}

function updateChart() {
    gaugeData.setValue(0, 0, 'Tomorrow');
    gaugeData.setValue(0, 1, gaugeData.getValue(0, 1) + 25);
    chart.draw(gaugeData, options);
}


There seems to be a bug (or undocumented feature?) where the label isn't 
updated when the gauge is redrawn.  I suspect this is because calling draw() 
on a gauge after it has been drawn once invokes an animation rather than a 
straight up redraw.  Maybe this would work better:

var gaugeData = new google.visualization.DataTable();    
gaugeData.addColumn('string', 'day');
gaugeData.addColumn('number', 'value');
gaugeData.addRows(1);

function getMyForm(label, value) {
    gaugeData.setCell(0, 0, label);
    gaugeData.setCell(0, 1, value);

    var options = {
        min:0,
        max:150,
        width: 175,
        height: 175,
        redFrom: 0, 
        redTo: 60, 
        yellowFrom:60,
        yellowTo: 90,
        greenFrom:90,
        greenTo:100,
        minorTicks: 5,
        backgroundColor: '#999999'
    };

    var chart = new google.visualization.Gauge(document.getElementById(
'menuMyFormChartDiv'));
    chart.draw(gaugeData, options);
}

function updateChart() {
    getMyForm('Tomorrow', gaugeData.getValue(0,1) + 25);
}


You'll need to pass the 'label' and 'value' parameters to it the first time 
you call the function. The downside is that you lose the animation with this 
method.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-visualization-api/-/unznFuT36fIJ.
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.

Reply via email to