That's what I suspected >;o)
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.