Reputation: 303
I have 'manually' created a chart in google sheets by selecting a range and inserting a stacked column chart:
I changed the vertical axis minimum value to 79.000.000.
However, I would like to automate this process. So, therefore I wrote a little script:
/**
* @OnlyCurrentDoc
*/
function buildChart() {
// Get the sheet
var sheet = SpreadsheetApp.getActiveSheet()
//Create new chart
var chart = sheet.newChart()
.setChartType(Charts.ChartType.COLUMN)
.addRange(sheet.getRange("D1:H8"))
.setPosition(10, 10, 0, 0)
//.setOption('title', 'Cost Price Development - Stage 3')
.setOption('isStacked', 'TRUE')
.setOption('colors', ['tranparant', '#93CCEA', 'green', 'black'])
.setOption('vAxis.title', 'test test')
//.setOption('vAxis', {'title': 'Something Here'})
//.setOption('vAxis.viewWindowMode', 'explicit')
.setOption('vAxis.viewWindow.min', 79000000)
//.setOption('vAxis.textStyle.fontSize',8)
.build();
// Insert chart in sheet
sheet.insertChart(chart);
}
With the line
.setOption('vAxis.viewWindow.min', 79000000)
I want to change the minimum value of the vertical axis. However, the vertical axis does still start at 0 instead op 79.000.000.
I have also tried:
.setOption('vAxis.minValue', 79000000)
which does not help either: the code above results in the following chart:
Upvotes: 2
Views: 1930
Reputation: 303
I solved it with this code line:
setOption('vAxes', {0: {title: '€', textStyle: {fontSize: 10}, titleTextStyle: {fontSize : 8}, viewWindow: {min: 79000000}}})
So, I used vAxes instead of vAxis.
Upvotes: 4