I'm having trouble getting specific charts from a spreadsheet using an array. The code below is an extract of a function that sends an email which includes charts:
var sheetSummary = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Summary");
var charts = sheetSummary.getCharts();
var chartBlobs = new Array(charts.length);
var emailImages = {};
for(var i=0; i < charts.length; i++){
chartBlobs[i] = charts[i].getAs("image/png").setName("chartBlob"+i);
var emailChart = "<img src='cid:chart" + i + "'> test<br> "
emailImages["chart"+i] = chartBlobs[i]
}
The only values of chartBlobs in the final line of this extract that sends an image of a chart in the email are
chartBlobs[i]
and
chartBlobs[0]
even though there are 4 charts [0,1,2,3] in the charts.length array and on the sheet.
How can I change this to send e.g. chart [2] or [3], and how can I change this to send e.g. chart [2] and [3] together as two separate images in the email?
Thanks a lot for your help.