title: Copying charts in a Google Sheets using Google Apps Script
body: <p>I built a chart in a Google Sheets. Now I need to duplicate the chart.</p>
  <p>There is UI copy interface for the charts. I tried to replicate it in Google Apps Script with no luck:</p>
  <pre><code>function copyChart() {
    var sheet = SpreadsheetApp.getActiveSheet();
    var chart = sheet.getCharts()[0];
    var chartCopy = sheet.newChart();
    chartCopy = chart;
    sheet.insertChart(chartCopy);
  }
  </code></pre>
  <p>How do I make a working script that duplicates the first chart in the current spreadsheet?</p>