Reputation: 301
I managed to generate an embedded line chart via a Google App Script.
Current implementation:
var mySheet = SpreadsheetApp.getActive().getSheetByName("Sheet1");
var myDataRange = mySheet.getRange(1, 1, 10, 5);
var chart = mySheet.newChart();
chart.setChartType(Charts.ChartType.LINE);
chart.addRange(myDataRange);
chart.setPosition(1, 1, 0, 0);
var series = {
0: {
color: 'blue',
annotations: {
textStyle: {
fontName: 'Times-Roman',
fontSize: 18,
color: '#871b47'
}
}
},
1: { color: '#a9c5e3' }
};
// styling of series works as long as I display data labels manually
chart.setOption('series', series);
var embeddedChart = chart.build();
mySheet.insertChart(embeddedChart);
Now I also want to show data labels in some of the series in the chart. I was able to style existing data labels that I added manually, but I'm not able to display them in a newly created chart only using Apps Script. How can I achieve this?
Upvotes: 2
Views: 1664