title: Adding error bars to a scatter chart in a Google spreadsheet
body: <p>I'm a physics teacher trying to use Google Sheets to do collaborative work in the lab. I already managed to add trend lines to a scatter chart through a google apps script. What I'd like to do now is add some custom error bars, specifying a different value for each data point. According to <a href="https://developers.google.com/chart/interactive/docs/gallery/intervals" rel="nofollow">this</a>, it seems to be possible. However, I'm at a loss when it comes to defining column roles programmatically and integrating them in the chart.</p>
  
  <p>Here is how I create a basic chart:</p>
  
  <pre class="lang-js prettyprint-override"><code>function scatterMe() {
      var sheet = SpreadsheetApp.getActiveSheet();
      var chart = sheet.newChart().asScatterChart()
         .addRange(sheet.getRange("C5:D13"))
         .setPosition(2, 10, 0, 0)
         .setOption('series', {0: {pointSize: 2, color: 'black'}})
         .build();
      sheet.insertChart(chart);
  };
  </code></pre>
  
  <p>I created 2 columns containing the intervals for the errors bars, let's say <code>G5:H13</code>. How could I use this range to create errors bars (<code>style: 'bars'</code>) in my chart?</p>
  
  <p>Thanks a lot!</p>