title: TypeError: sheet.newChart(...).setChartType(...).setDataViewDefinition is not a function
body: <p>I'm trying to draw a chart with Google Apps Script in Google Sheets. I have a spreadsheet and a file called Code.gs.</p>
  <pre><code>function newChart() {
    // Generate a chart representing the data in the range of A1:B15.
    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var sheet = ss.getSheets()[0];
  
    // build the data view definition
    var COLUMN_SPEC = [
      0,
      1,
      {sourceColumn: 2, role: 'tooltip'}
    ];
    var viewSpec = Charts.newDataViewDefinition()
       .setColumns(COLUMN_SPEC)
       .build();
  
    var chart = sheet.newChart()
       .setChartType(Charts.ChartType.COMBO)
       .setDataViewDefinition(viewSpec)
       .addRange(sheet.getRange('A2:B20'))
       .addRange(sheet.getRange('C2:C20'))
  
       .setPosition(5, 5, 0, 0)
       .build();
  
    sheet.insertChart(chart);
  }
  </code></pre>
  <p>I get the following error when running the function newChart():</p>
  <pre><code>TypeError: sheet.newChart(...).setChartType(...).setDataViewDefinition is not a function (line 18, file &quot;Code&quot;)
  </code></pre>
  <p>Can someone tell me what's wrong?</p>
  <p><strong>References:</strong></p>
  <p><a href="https://stackoverflow.com/questions/53605363/need-tooltips-change-google-sheet-existing-data-into-datatable">Need Tooltips: Change google sheet existing data into DataTable</a></p>