google-apps-script - 在 Google Apps 脚本中更改图表边框颜色
问题描述
我正在使用 Google Apps 脚本,并且正在通过脚本将图表插入到我的工作表中。我注意到在使用宏记录图表的创建时,并非图表的所有属性都被记录下来。
例如,我录制了一个宏,并将图表的背景设置为透明(或任何颜色),然后当我运行该宏时,背景会恢复为标准白色。
我可以通过将其设置在下面来修复背景颜色.setOptions
(请参见下面的代码),但我似乎无法弄清楚如何更改边框的颜色(真的我想摆脱它)。
chart = sheet.getSheetByName("Sheet1").newChart()
.asLineChart()
.addRange(sheet.getSheetByName("ForGraphs").getRange(1, 1, 22, team_names.length + 1))
.setMergeStrategy(Charts.ChartMergeStrategy.MERGE_COLUMNS)
.setTransposeRowsAndColumns(false)
.setNumHeaders(-1)
.setHiddenDimensionStrategy(Charts.ChartHiddenDimensionStrategy.IGNORE_BOTH)
.setOption('backgroundColor.fill', "#0000ffff")
.setOption('bubble.stroke', '#000000')
.setOption('useFirstColumnAsDomain', true)
.setOption('focusTarget', 'category')
.setOption('curveType', 'none')
.setOption('legend.position', 'top')
.setOption('annotations.domain.textStyle.color', '#808080')
.setOption('textStyle.color', '#000000')
.setOption('legend.textStyle.color', '#1a1a1a')
.setOption('subtitleTextStyle.color', '#999999')
.setOption('titleTextStyle.color', '#757575')
.setOption('annotations.total.textStyle.color', '#808080')
.setOption('hAxis.slantedText', true)
.setOption('hAxis.slantedTextAngle', 0)
.setOption('hAxis.textStyle.color', '#000000')
.setOption('hAxis.titleTextStyle.color', '#000000')
.setOption('vAxes.0.minorGridlines.count', 5)
.setOption('vAxes.0.minorGridlines.color', '#f3f3f3')
.setOption('vAxes.0.textStyle.color', '#000000')
.setOption('vAxes.0.titleTextStyle.color', '#000000')
.setOption('height', 322)
.setOption('width', 659)
.setPosition(26, 5, 2, 16)
.build();
我已手动将其添加.setOption('backgroundColor', "#0000ffff")
到此块中。
我在谷歌的官方文档中看到他们说该backgroundColor.fill
选项可以将对象作为输入,但他们忽略了他们反对的样子。我会认为这将是带有.stroke
and的东西.strokeWeight
,但这似乎不起作用。
非常感谢!
解决方案
这意味着您可以通过设置setOption('backgroundcolor', 'white')
或setOption('backgroundcolor', {fill:'white'})
根据该文件,不支持进一步的背景选项
线条颜色由setOptions('colors', ['blue', 'red'])
图表区域背景颜色由chartArea.backgroundColor
文件中对此进行了说明。
推荐阅读
- c# - C# 传递类型(类)方法,如参数
- apache-spark - Zeppelin/Hive/Spark 上的笛卡尔积查询
- laravel - 如何在作业中使用事务或当内存不足时如何在作业中回滚模型写入操作?
- php - 使用正则表达式从文本中删除 URL,当前域除外
- c++ - Boost Spirit x3 -- Parameterizing Parsers with other Parsers
- c++ - 创建 min-cur-max 条形图
- java - 在多个嵌套属性的情况下,Apache Delta 峰值 findBy* 方法的正确语法是什么?
- jquery - Ajax 使用 Django 后端发送 GET,而不是 PUT 和 DELETE
- java - 在 Java 中使用 UDP 广播
- c++ - 如何使用来自 ostringstream 的猫鼬发送 png 数据?