i'm trying to make buttons in GoogleCharts that can modify the "view" property of a chart.
Here's my head :
<script type="text/javascript">
google.charts.load('current', {'packages':['corechart', 'table', 'gauge', 'controls']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
//New chart, with a specific 'view'
var chart = new google.visualization.ChartWrapper({
'chartType': 'ColumnChart',
'containerId': 'chart_div',
'options': {
'width': 640,
'height': 480
},
'view': {'columns': [0, 1]}
});
//Data used to fill the chart, i don't think there's an issue here
...
//There's 3 columns of data
//Assign data to the chart and draw it
chart.setDataTable(data);
chart.draw();
}
</script>
In the body i use the following function linked to a button :
<script type="text/javascript">
function changeVisualisation() {
chart.setView({'columns': [0, 2]});
chart.draw();
}
</script>
However i get the following error :
"categoryfilter.html:54 Uncaught ReferenceError: chart is not defined"
What am i forgeting ?