如何在Google表图中显示数据系列标签



我制作了一个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);

这就是我所拥有的:

这就是我想要的:

您的评论帮助我解决了这个问题。我不知道关键词是注释。

这是我用来更新数据标签字体和颜色

的代码
.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运行

我希望这会有所帮助

最新更新