Reputation: 1772
I'm trying to create a column chart in a google app script. The chart is created from a google sheet that I have. The chart appears as it should, but I'd like to make the label for the x-axis vertical. The chart that's being returned is being added to a StackPanel object. Here's the code I've created for the chart:
function createXPLeaderboard() {
var sheet = pointsSheet.getSheets()[1];
var cell = sheet.getRange("A1");
cell.setFormula("=QUERY(Sheet1!B1:T29, \"select D, E where D <> 'Avatar' order by E\", 1)");
var options = {'title':'Experience Points',
'width':'927',
'height':'510'};
var chart = Charts.newColumnChart()
.setDataTable(sheet.getDataRange())
//.setColors(["green", "red"])
//.setDimensions(1000, 400)
.setTitle("Experience Pointsn")
.setOption('option', options)
.build();
return chart;
}
The options are not working. I can't find any documentation on how to set them up. It seems that every site I see examples is for javascript embedded in HTML. I'm not a web developer, so my understanding about how everything works is pretty low :/
Upvotes: 1
Views: 1841
Reputation: 1772
I just figured it out...the options need to be set separately. There may be a better way to do this, but this works for me. You can use "dot" notation to burrow down to other properties such as the various properties of hAxis (slantedText, slantedTextAngle, etc).
var chart = Charts.newColumnChart()
.setDataTable(sheet.getDataRange())
.setDimensions(1000, 400)
.setTitle("Experience Pointsn")
.setOption('title', 'XP')
.setOption('width', '1200')
.setOption('hAxis.slantedText', 'true')
.setOption('hAxis.slantedTextAngle', '90')
.build();
I hope this helps someone.
Upvotes: 1