如何在Script Services中向堆叠的柱形图添加标签?例如,在下面的代码中,SQL,COI,COD和GIA堆栈的2016列分别为“ 5”,“ 6”,“ 2”和“ 0”。所有列都将被标记。当前没有列标签。
我已阅读Chart服务documentation,visualization reference和堆栈溢出,但没有找到解决方案。
var dataTimeline = Charts.newDataTable()
.addColumn(Charts.ColumnType.STRING, "Year")
.addColumn(Charts.ColumnType.NUMBER, "SQL")
.addColumn(Charts.ColumnType.NUMBER, "COI")
.addColumn(Charts.ColumnType.NUMBER, "COD")
.addColumn(Charts.ColumnType.NUMBER, "GIA")
.addRow(["2016", 5, 6, 2, 0])
.addRow(["2017", 10, 5, 1, 1])
.addRow(["2018", 7, 8, 0, 1])
.addRow(["2019", 2,0,0,0])
.build();
var timelineChart = Charts.newColumnChart()
.setTitle('Timeline')
.setXAxisTitle('Year')
.setDataTable(dataTimeline)
.setStacked()
.setOption('annotation', value) // Is this close?
.setColors(["ffc000", "c00000", "558ed5", "00b050"])
.build();
var htmlOutput = HtmlService.createHtmlOutput().setTitle('Timeline');
var imageData = Utilities.base64Encode(timelineChart.getAs('image/png').getBytes());
var imageUrl = "data:image/png;base64, " + encodeURI(imageData);
htmlOutput.append("<img border=\"1\" src=\"" + imageUrl + "\">");
return htmlOutput.getContent();