title: Insert a chart built with google apps script into a google spreadsheet
body: <p>This may sound a dumb question, but I have searched the web a lot and I didn't find what I wanted...</p>
  
  <p>I 've managed to build the chart I want to display, from the data on different spreadsheets, and I would like to insert the chart into a spreadsheet without having to paste the data on the sheet. Is this possible ? </p>
  
  <p>I can also use UIApp to display it, but then I would like to have it displayed on the spreadsheet without having to call it from a menu or a button.</p>
  
  <p>Thanks for your help,</p>
  
  <p>edelans</p>
  
  <p>--
  Here is my code so far, it's working as I can see on the debugger tool</p>
  
  <pre><code>  function BuildMTChart(){
    var ss = SpreadsheetApp.getActiveSpreadsheet() 
    var DataChart = MTLastMonth()  // MTLastMonth() returns an array with the data I need
    var dSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Dashboard");
  
        var dataTable = Charts.newDataTable();
            dataTable.addColumn(Charts.ColumnType['DATE'], 'Date');
            dataTable.addColumn(Charts.ColumnType['NUMBER'], 'Maintenance');
            dataTable.addColumn(Charts.ColumnType['NUMBER'], 'Troubleshooting');
            for ( var i = 0; i &lt; DataChart.length; i++) {
              dataTable.addRow([DataChart[i][0], DataChart[i][1], DataChart[i][2]]);
            }
            dataTable.build();        
  
      var chart = Charts.newAreaChart()
          .setDataTable(dataTable)         
          .setDimensions(800, 400)         
          .setYAxisTitle("Hours")
          .setXAxisTitle("Date")
          .build();
  </code></pre>