Nearly duplicate question
I am currently trying to create a couple charts through Google App Script. I would like to have one of the series in one of the charts to be aggregated to an average, but I cannot figure out how. The default is sum
and I have yet to find a way to change it. I have been trying everything I can find to solve this issue. It does not seem to be documented at all in the chart options, and I have found minimal documentation elsewhere.
What I've tried:
Reverse engineering the code myself
.setOption('applyAggregateData',0)
(from link above)
.setOption("series", {"0":{"applyAggregateData":"average"}})
(combination of answers I found)
.setOption('aggregateFunction',0)
(combination of answers I found)
None of this has worked for me, and the best I'm able to get is aggregation by sum. I am not sure what I am missing here, as it seems to have worked for others in the past.
Chart code:
var chart2 = exportSheet.newChart()
.setChartType(Charts.ChartType.COLUMN)
.setPosition(2, 2, 0, 0)
.addRange(searchSheet.getRange('B11:B'))
.addRange(searchSheet.getRange('G11:G'))
.setOption("series", {"0":{"aggregateFunction":"average"}}) //Does not work
.setOption("title", 'Avg. Ton Per Mile')
.setOption('hAxis.title', 'Dates')
.setOption('vAxis.title', 'Salt Usage (T)')
.build();