title: How To Get Chart From Sheet in Google Apps Script
body: <p>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 <em>[400]</em> error in a red rectangle. Here is the code that I am using:</p>
  
  <pre><code>  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;
  
  }
  </code></pre>
  
  <p>Do you know the solution to this problem? Any help is greatly appreciated.</p>