6
votes

First I couldn't find how to set the dimension for an embedded chart.

The solution to that was setOption('width', width) + setOption('height', height)

Now I want to set the min and max values for the vertical axis when I create the chart.

Google's doc just says ...

setOption(name, value)

Sets advanced options for this chart. See https://developers.google.com/chart/interactive/docs/reference for what options are available.

... but I cant find the name of the available options there.

I.e. I lack the method setDimension(pixwidth, pixheight) in the EmbeddedChartBuilder ...

function addChart(dataSheetName) {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
 var sheet = ss.getSheetByName('Graphs');


  var dataSheet = SpreadsheetApp.getActive().getSheetByName(dataSheetName);
  var dataRange = dataSheet.getDataRange();

  var chart = sheet.newChart()
  .setChartType(Charts.ChartType.LINE)
  .addRange(dataRange)
  .setPosition(5, 1, 0, 0)
  // .setDimension(800, 400)    // This method does not exist!

  .build();

  sheet.insertChart(chart);
}
3
I can't find any reference for the "advanced options" in that link, other than a few examples in the code samples.Rikki

3 Answers

3
votes

I found it ...

.setOption('width', 700)
.setOption('height', 200)
0
votes

I found a list of chart options here: https://developers.google.com/chart/interactive/docs/gallery/linechart#configuration-options

The width and height options you mentioned are present there.

0
votes

As lacton's answer mentioned, the documentation is under the guides section of the site linked in the question. There is a section for each chart type listed on the left-hand side of the page, and each contains a list of configuration options which details what you can use in apps script's .setOption().

The maximum and minimum values for the vertical axis are set with vAxis.maxValue and vAxis.minValue respectively, e.g. .setOption('vAxis.maxValue',100).