Google Charts BAR
Updating Google Chart
by gdicerbo
HTML
<html>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {
packages: ["corechart"]
});
google.setOnLoadCallback(drawChart);
var chart;
var data;
var options;
function drawChart() {
dataTable = google.visualization.arrayToDataTable([
['State', 'FullDev', 'PreDev','Hold', 'Placeholder', 'Closed', {type:'string', role:'annotation'}],
['MA', 11, 0, 12,12, 2, 37],
['NY', 8, 3,1,17, 1, 30],
['ME', 0, 10,2,10, 0, 22]
]);
options = {
legend: 'bottom',
series: {
0:{color:'#8dc641'},
1:{color:'#6a747b'},
2:{color:'#f6f100'},
3:{color:'#6bbed1'},
4:{color:'#eaeae9'}
},
annotations: {
textStyle: {
color: 'black',
}
},
isStacked: true,
'height': 375,
'width': 650,
'chartArea': {
'width': '75%',
'height': '75%'
},
vAxis: {
title: 'Projects (#)',
titleTextStyle: {
italic: false
}
},
};
chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
chart.draw(dataTable, options);
}
// function to update the chart with new data.
var chart;
var data;
var options;
function updateChart() {
dataTable = google.visualization.arrayToDataTable([
['State', 'FullDev', 'PreDev','Hold', 'Placeholder', 'Closed', {type:'string', role:'annotation'}],
['MA', 38.1, 0, 35.8, 40.5, 6.4, 120.9],
['NY', 29.8, 20.3, 6.8, 114.8, 2.8, 174.3],
['ME', 0, 55.4, 13.5, 97.5, 0, 136.4]
]);
options = {
legend: 'bottom',
series: {
0:{color:'#8dc641'},
1:{color:'#6a747b'},
...