Reputation: 2716
I'm working with Google Charts Api.
As a data surce, I'm using a Google spreeadsheat. I using this spreadsheat:
https://docs.google.com/spreadsheet/pub?key=0Amf7cOIp81pxdGdxUmFMZVVFVjBwTENTcUpVVldVRnc&output=html
The problem is that as the table has multiple columns, how can I select which column I wnat to show in the chart?
I get the table via: var data = response.getDataTable();
But I don't know hot to get some column from data
.
In draw()
method I don't know too if I can pass as parameter some specific column
Here my complete code:
google.load('visualization', '1.0', {'packages':['corechart']});
google.load('visualization', '1.0', {'packages':['controls']});
google.setOnLoadCallback(drawChart);
function drawChart() {
var query = new google.visualization.Query(
'https://docs.google.com/spreadsheet/pub?key=0Amf7cOIp81pxdGdxUmFMZVVFVjBwTENTcUpVVldVRnc&output=html');
query.send(handleQueryResponse);
}
function handleQueryResponse(response) {
if (response.isError()) {
alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
return;
}
var data = response.getDataTable();
// Testing
console.log(data.getColumnId(1));
var chart = new google.visualization.PieChart(document.getElementById('columnchart'));
var options = {'title':'World Cup Statistics',
'width':800,
'height':800};
chart.draw(data, options);
Upvotes: 0
Views: 2361