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([
['Fund', 'Projects', { role: 'style' }],
['CEC', 1000, '#8dc641'],
['NAI', 1170, '#6a747b'],
['Framework A', 660, '#f6f100'],
['Framework B', 660, '#6bbed1'],
['Framework C', 1030, '#eaeae9']
]);
options = {
title: 'Project Development & Pipeline by Fund',
legend: 'none',
'height': 300,
'width': 500,
'chartArea': {'width': '75%', 'height': '75%'},
colors: ['red', 'yellow', 'blue', 'red', 'yellow','yellow','yellow'],
};
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([
['Fund', 'Projects', { role: 'style' }],
['CEC', 200, '#8dc641'],
['NAI', 1170, '#6a747b'],
['Framework A', 660, '#f6f100'],
['Framework B', 660, '#6bbed1'],
['Framework C', 1030, '#eaeae9']
]);
options = {
title: 'Project Development & Pipeline by Fund',
legend: 'none',
'height': 300,
'width': 500,
'chartArea': {'width': '75%', 'height': '75%'},
colors: ['red', 'yellow', 'blue', 'red', 'yellow','yellow','yellow'],
};
chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
...