0

I am adding charts to a Google Sheet using Google Script

var chart = sheet.newChart()
.setChartType(Charts.ChartType.BAR)
.addRange(sheetdata.getRange("E2:E99"))
.setPosition(5, 5, 0, 0)
.setOption("title", "Leads")
.build();

sheet.insertChart(chart);

Aggragate Aggragate

How do you set the Aggregate from Google Script. I have looked in the doco but cannot see it.

Any ideas welcome.

TheMaster
  • 45,448
  • 6
  • 62
  • 85
  • There is no straight method in Apps Script that offers the `Aggregate` option from Sheets. You can check a workaround in this [question](https://stackoverflow.com/questions/36142327). Could you please share your anonymized spreadsheet so we all can help you better? – Jacques-Guzel Heron Feb 04 '20 at 11:14
  • Does this answer your question? [Many Chart options for EmbeddedChartBuilder.setOption() function not available to Google Apps Script](https://stackoverflow.com/questions/52009364/many-chart-options-for-embeddedchartbuilder-setoption-function-not-available-t) – TheMaster Feb 04 '20 at 20:56
  • Related: https://stackoverflow.com/questions/13594839/google-apps-script-how-to-set-use-column-a-as-labels-in-chart-embedded-in-spr – TheMaster Feb 04 '20 at 20:57

1 Answers1

2

Here is what worked for me, simply add this to your chart

.setOption('applyAggregateData',0)

Hemant
  • 1,127
  • 1
  • 10
  • 18