Discussion:
[visualization-api] Need Google Chart Documentation to edit Google Script to build 2 Y-axis LINE Chart
CPU Lawrence
2016-08-22 14:58:03 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:

<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 lot of Google Chart information available on the Internet, such as
Google doc, Youtube, and StackOverflow, and I pretty much try most of them.
Since none of them addresses the 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/7be72a09-27b9-4e0a-8267-cf587dda80f9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
'Daniel LaLiberte' via Google Visualization API
2016-08-22 15:19:32 UTC
Permalink
Hi Lawrence,

It appears you are using AppsScript, which has a limited API for charts.
The addRange() call appears to be modifying the query that is sent to the
spreadsheet, and I suspect you will need to merge your two ranges into one
call, though I don't know the syntax for that. If this idea doesn't help,
you should probably ask on a more appropriate forum:
https://developers.google.com/apps-script/support Good luck.
Post by CPU Lawrence
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);
}
<https://lh3.googleusercontent.com/-lf11gTA-Lr4/V7sPDNQoV3I/AAAAAAAAAi4/9F7MUH7x500Mw6lIqJmI9WLDPVDHSs-HACLcB/s1600/CPU-16-08-22a.png>
<https://lh3.googleusercontent.com/-v3-FVa95YF4/V7sPtQL3hcI/AAAAAAAAAjA/_tXGtdfmTEIe2lw0-C_4BQYl929W0xrUACLcB/s1600/CPU-16-08-22b.png>
In order to get the work done, I need Google Embedded Chart documentation
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 lot of Google Chart information available on the Internet, such as
Google doc, Youtube, and StackOverflow, and I pretty much try most of them.
Since none of them addresses the 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
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/7be72a09-27b9-4e0a-8267-
cf587dda80f9%40googlegroups.com
<https://groups.google.com/d/msgid/google-visualization-api/7be72a09-27b9-4e0a-8267-cf587dda80f9%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
Daniel LaLiberte <https://plus.google.com/100631381223468223275?prsrc=2>
***@Google.com <***@google.com> 5CC, Cambridge MA
--
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/CAOtcSJPk7u%3DUAYCrDTrzLZdmuGp_cbKV3KDYz0resj4LXCTxEw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Loading...