I would like to add a "Gauge chart" in Google sheets programmatically. This is an example that I found on the internet but it is coded to display the chart on a webpage. I will, however, try to work off of that example code. But, any help is appreciated. Here's the example https://developers.google.com/chart/interactive/docs/gallery/gauge
If my understanding is correct, how about this sample script?
Before you run the script, as a test case, please set sample
and 50
to the cells of "A1" and "B1", respectively.
function myFunction() {
var sheet = SpreadsheetApp.getActiveSheet();
var chart = sheet.newChart()
.setChartType(Charts.ChartType.GAUGE)
.addRange(sheet.getRange('A1:B1'))
.setPosition(3, 1, 0, 0)
.setOption('height', 300)
.setOption('width', 300)
.setOption('title', 'Sample chart')
.build();
sheet.insertChart(chart);
}
If I misunderstood your question and this was not the direction you want, I apologize.