Google App脚本图表选项 [英] Google App Script Chart Options

查看:50
本文介绍了Google App脚本图表选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Google App脚本中创建一个柱形图.该图表是根据我拥有的Google工作表创建的.该图表按原样显示,但我想使x轴的标签垂直.将返回的图表添加到StackPanel对象中.这是我为图表创建的代码:

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;
}

这些选项不起作用.我找不到任何有关如何设置它们的文档.看来,我看到的每个网站示例都是针对HTML中嵌入的javascript的.我不是网络开发人员,所以我对一切工作原理的理解很低:/

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 :/

推荐答案

我刚刚弄清楚了...这些选项需要单独设置.也许有更好的方法可以做到这一点,但这对我有用.您可以使用点"表示法来探究其他属性,例如hAxis的各种属性(slantedText,slantedTextAngle等).

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.

这篇关于Google App脚本图表选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆