add visualization charts into spreadsheet

28 views
Skip to first unread message

Jon Martin

unread,
Nov 23, 2016, 8:47:25 PM11/23/16
to Google Visualization API
I am trying to make charts based on data I put in. So far the timeline chart is what i think i will need but it isn't part of SpreadsheetApp it is only part of google.visualization. I imported the google library. SO it is compiling and running all the scrips but at this point can not get Chart to appear in the spreadsheet.

here is my function. It has been changed a lot trying to get this to work. Main issue is just how do i get the chart to actually show up in the spreadsheet. 

function handleQueryResponse(response) {
var range = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Bravo+ USO Task").getRange(10, 2,1,2).getValues();
var range2 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Bravo+ USO Task").getRange(9,2,1,2);
var sheet = SpreadsheetApp.getActiveSheet();
// var data = google.visualization.getDataTable();//
  //response.getDataTable(
  
  var chartBuilder = SpreadsheetApp.getActiveSheet().newChart();
  
  //SpreadsheetApp.getActiveSheet().newChart();
  var chart = new google.visualization.ColumnChart( SpreadsheetApp.getActiveSheet().insertChart(chartBuilder.setPosition(7, 5, 5, 5)) );
  chart.draw(range, null)
  
 sheet.insertChart(chart);
}

another issue is this... 

    var container = document.getElementById('example2.2');
    var chart = new google.visualization.Timeline(container);
The container always uses example of document. I am using spreadsheet not document. So I am probably handling this wrong.
Any help would be appreciated, Thanks
Reply all
Reply to author
Forward
0 new messages