This was tricky.
Chart options are documented in a wide galaxy of different documents, and none of them seems to explain multiple axes charts:
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName(GlideChartName);
var chart = sheet.newChart()
.setChartType(Charts.ChartType.AREA)
.addRange(sheet.getRange("A:A"))
.addRange(sheet.getRange("B:B"))
.setOption("title", "Chart Name")
.setOption("width", 800)
.setOption("height", 600)
.setOption("hAxis.title", "X")
.setOption("series", { 0: { targetAxisIndex: 0 }, 1: { targetAxisIndex: 1 } })
.setOption("vAxes", { 0: { title: "Y1" }, 1: { title: "Y2" } })
.setPosition(1, 1, 0, 0)
.build();
sheet.insertChart(chart);
No comments:
Post a Comment