I am using Google Apps Script with Spreadsheets. I am trying to find out a way to return a Google Chart(static or dynamic, doesn't matter). The data set that I will be using will be in a spreadsheet, and I want the Google Chart to be returned in the form of a web app(URL should start with: script.google.com/macros/idforscript). I have tried to use the official Google Apps Script tutorials, but even they don't work, leaving me, when I open the page, with a [400] error in a red rectangle. Here is the code that I am using:
function doGet() {
/*
var data = Charts.newDataTable()
.addColumn(Charts.ColumnType.STRING, 'Month')
.addColumn(Charts.ColumnType.NUMBER, 'In Store')
.addColumn(Charts.ColumnType.NUMBER, 'Online')
.addRow(['January', 10, 1])
.addRow(['February', 12, 1])
.addRow(['March', 20, 2])
.addRow(['April', 25, 3])
.addRow(['May', 30, 4])
.build();
*/
var data = SpreadsheetApp.openByUrl("https://docs.google.com/spreadsheets/d/1PPlSIiQ7fZ5AzcyB61iVmIBQQepm6vubd4S2Eo9fWOg/edit#gid=0").getSheets()[0];
var chart = data.newChart().setChartType(Charts.ChartType.BAR).addRange(data.getRange('A1:B3')).build();
var uiApp = UiApp.createApplication().setTitle('My Chart');
uiApp.add(chart);
return uiApp;
}
Do you know the solution to this problem? Any help is greatly appreciated.