Discussion:
[visualization-api] Google Script to build 2 Y-axis LINE Chart
CPU Lawrence
2016-08-22 15:19:15 UTC
Permalink
I have hundred of Google Sheets that have the same data schema, and I want
to create the same set of 6 charts on each sheet.

Instead of creating them manually, I'm thinking to use Google Script to
accomplish the challenge.

Through trial and error, I can get the script as follows.

function SheetChart02(){

var aSheetMB = GetSheet("MB"); // Function that I created to get target
sheet
var aClose = GetSheet("DOHLCV");

var chart = aSheetMB.newChart()
.setChartType(Charts.ChartType.LINE)
.addRange(aSheetMB.getRange("A931:B1177"))
// .addRange(aClose.getRange("E931:E1177")) ... try to add second line
here; result: fail
.setOption("title", "MB")
.setOption("backgroundColor", "#000080")
.setOption("titleTextStyle.color", "white")
.setOption("width", 640)
.setOption("height", 320)
.setPosition(1, 1, 0, 0)
.build();

aSheetMB.insertChart(chart);
}

The script creates the following chart in the target sheet:

<Loading Image...>

The chart that I want to create:

<Loading Image...>

In order to get the work done, I need Google Embedded Chart documentation
that depicts all the necessary options, such as:

1. how to add second range/line in Google Script?

2. how to assign the newly added range/line to second Y-axis

3. Options to modify the chart.


I see a lot of instruction to help populating Google Charts in HTML on
Google doc, Youtube, and StackOverflow, and I pretty much try most of them.
Since none of them addresses the SCRIPT options that I'm looking for, I
hope someone in this community with the insight can help.


Thank you,


Lawrence
--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualization-api+***@googlegroups.com.
To post to this group, send email to google-visualization-***@googlegroups.com.
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/f2099201-b079-492a-89bb-680e6b403a0a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...