google-apps-script - 如何在谷歌表格图表中显示数据系列标签
问题描述
我制作了一个 google Apps 脚本来修改图表,我想显示系列号 0 的数据标签,但线.setOption('series',{ 1:{color: '#2ecc71'}})
(我更改系列 1 的颜色)删除了系列 0 的数据标签。
var Vmax =1.1*ss.getRangeByName("D285").getValue(); //get max and min here (before, it's equal to 0)
var Vmin =0.9*ss.getRangeByName("C285").getValue();
var sheet = SpreadsheetApp.getActiveSheet();
var chart = sheet.getCharts()[46];
chart = chart.modify()
.setChartType(Charts.ChartType.AREA)
.setOption('title',string)
.setOption('vAxes', {0: {textStyle: {fontSize: 10}, titleTextStyle: {fontSize : 8}, viewWindow: {min: Vmin, max:Vmax}}})
.setOption('series',{ 1:{color: '#2ecc71'}})
.setOption('titleTextStyle',{alignment:"center"})
.setOption('animation.startup',true)
.setOption('animation.duration', 5000)
.setOption('hAxis.slantedText',true)
.setPosition(290,6,0,0)
.build();
Logger.log(Vmax);
Logger.log(Vmin);
sheet.updateChart(chart);
解决方案
您的评论帮助我解决了这个问题。我不知道关键字是注释。
这是我用来更新 dataLabel 字体和颜色的代码
.setOption("series", {1 : {dataLabel: "value"}}) //this creates the data label
.setOption("series", {1: {annotations: {textStyle : {fontSize : 24, color : 'white'}}}}) //this updates the color and font size of the data label.
我通过 updateChart 运行它
我希望这有帮助
推荐阅读
- delphi - 条形系列变化的 TChart 大小
- vector - 如何保护矢量不调整大小?
- laravel - Laravel 多对多关系更新
- jquery - 映射响应以创建动态表时出现问题
- javascript - 不使用 javascript 在 div 上设置属性值
- laravel - 如何为 Lumen 上的 Route 浮动参数设置正则表达式参数约束
- php - 如何在共享主机中正确执行 laravel queue worker?
- python - 我想根据熊猫中的另一列数据添加新列
- solr - solr 查询时间随着 q 项的增加而变长
- mysql - 有没有办法在 MYSQL 中加入来自不同服务器的不同表?