Line Chart from Public Google Spreadsheet

24 views
Skip to first unread message

Glenn Tremblett

unread,
Apr 17, 2018, 7:16:11 PM4/17/18
to Google Visualization API
Hi Folks,

I am new to Google Charts, and wondering if someone can help me get started with creating a chart using data from a public Google Spreadsheet. I have no problem creating a line chart using manually entered values (as described here: https://developers.google.com/chart/interactive/docs/gallery/linechart), but for some reason no data is showing when I try to use the data from my public spreadsheet. I am attempting to follow the instructions here: https://developers.google.com/chart/interactive/docs/spreadsheets

Can anyone point me in the direction of where I may be going wrong?


Thanks!

Glenn Tremblett

unread,
Apr 17, 2018, 7:27:08 PM4/17/18
to Google Visualization API
Forgot to mention, 

This is what I'm currently trying (unsuccessfully): 

    function drawSheetName() {
     
var queryString = encodeURIComponent('SELECT A, H, O, Q, R, U LIMIT 5 OFFSET 8');


     
var query = new google.visualization.Query(
         
'https://docs.google.com/spreadsheets/d/1c4axGPSXmJBGwbcwWmSSir_uYAa92lao1eg98hUjzv4=Sheet1&headers=1' + queryString);
      query
.send(handleSampleDataQueryResponse);
   
}


   
function handleSampleDataQueryResponse(response) {
     
if (response.isError()) {
        alert
('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
       
return;
     
}


     
var data = response.getDataTable();
     
var chart = new google.visualization.LineChart(document.getElementById('line_chart'));
      chart
.draw(data, { height: 400 });
   
}

Reply all
Reply to author
Forward
0 new messages