Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set options for embedded charts in google spreadsheets

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);
}
like image 612
Gunnar Eketrapp Avatar asked Sep 08 '13 11:09

Gunnar Eketrapp


1 Answers

I found it ...

.setOption('width', 700)
.setOption('height', 200)
like image 54
Gunnar Eketrapp Avatar answered Oct 27 '22 03:10

Gunnar Eketrapp