本文介绍了以编程方式在Google Spreadsheet Embedded Line Chart中显示数据标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设法通过Google App脚本生成了嵌入式折线图.

I managed to generate an embedded line chart via a Google App Script.

当前实施:

var mySheet = SpreadsheetApp.getActive().getSheetByName("Sheet1");
var myDataRange = mySheet.getRange(1, 1, 10, 5);
var chart = mySheet.newChart();
chart.setChartType(Charts.ChartType.LINE);
chart.addRange(myDataRange);
chart.setPosition(1, 1, 0, 0);

var series = {
  0: {
    color: 'blue',
    annotations: {
      textStyle: {
        fontName: 'Times-Roman',
        fontSize: 18,
        color: '#871b47'
      }
    }
  },
  1: { color: '#a9c5e3' }
};
// styling of series works as long as I display data labels manually
chart.setOption('series', series);
var embeddedChart = chart.build();
mySheet.insertChart(embeddedChart);

现在,我还想在图表的某些系列中显示数据标签.我能够设置手动添加的现有数据标签的样式,但仅使用Apps Script不能在新创建的图表中显示它们.我该如何实现?

Now I also want to show data labels in some of the series in the chart.I was able to style existing data labels that I added manually, but I'm not able to display them in a newly created chart only using Apps Script.How can I achieve this?

推荐答案

找到了答案显示我使用的系列的数据标签

Found the answer hereTo display data labels for a series I used

var series = {
  0: {
    dataLabel: "value"
  }
};
chart.setOption('series', series);

这篇关于以编程方式在Google Spreadsheet Embedded Line Chart中显示数据标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 17:59