Google apps script 更改数据标签在嵌入式组合图中的位置

Google apps script 更改数据标签在嵌入式组合图中的位置,google-apps-script,google-sheets,google-visualization,embedded-resource,Google Apps Script,Google Sheets,Google Visualization,Embedded Resource,我正在尝试使用谷歌应用程序脚本修改谷歌工作表中的图表。除了一件事之外,我知道如何做我需要做的大部分事情。我需要更改数据标签在图表中的位置。该图表是一个组合图表,包含线条图和条形图 下面的代码显示了数据标签,但我找不到如何更改其位置(例如“中心”、“下方”等) 显然,现在已经有了关于它的文档,但是一些人找到了显示dataLabel()的方法。我想知道是否有人知道如何更改数据标签的位置。答案是 var vAxes = [{minValue:0,maxValue:''},{minValue:0,max

我正在尝试使用谷歌应用程序脚本修改谷歌工作表中的图表。除了一件事之外,我知道如何做我需要做的大部分事情。我需要更改数据标签在图表中的位置。该图表是一个组合图表,包含线条图和条形图

下面的代码显示了数据标签,但我找不到如何更改其位置(例如“中心”、“下方”等)

显然,现在已经有了关于它的文档,但是一些人找到了显示dataLabel()的方法。我想知道是否有人知道如何更改数据标签的位置。

答案是

var vAxes = [{minValue:0,maxValue:''},{minValue:0,maxValue:''}];
var series = {
  0: {dataLabel: 'value',dataLabelPlacement:"insideBase"},
  1: {dataLabel: 'value',targetAxisIndex: 1,dataLabelPlacement:"center"}
};

chart = chart.modify()
.setOption('vAxes',vAxes)
.setOption('series',series)
.build();
我按照这个答案上的说明做了()。只需发布图表并检查代码

这里是我发现的财产清单:

options":{
"treatLabelsAsText":true,
"vAxes":[
{
"minValue":0,
"maxValue":""
},
{
"minValue":0,
"maxValue":""
}
],
"legacyScatterChartLabels":true,
"title":"July/2018, August/2018 and September/2018",
"type":"line",
"lineWidth":2,
"hAxis":{
"useFormatFromData":true,
"title":"Month",
"viewWindow":{
}
},
"series":{
"0":{
"dataLabelPlacement":"insideBase",
"dataLabel":"value",
"annotations":{
"position":"center"
},
"hasAnnotations":true
},
"1":{
"dataLabelPlacement":"below",
"dataLabel":"value",
"annotations":{
"position":"center"
},
"hasAnnotations":true,
"targetAxisIndex":1
}
},
"useFirstColumnAsDomain":true,
"domainAxis":{
"direction":1
},
"width":818,
"booleanRole":"certainty",
"height":506
}

什么类型的图表?很好。这是一个使用线条和条形图的组合图,采用与答案中所述类似的方法,看看有什么变化?我应该开始阅读整个答案。=)谢谢
options":{
"treatLabelsAsText":true,
"vAxes":[
{
"minValue":0,
"maxValue":""
},
{
"minValue":0,
"maxValue":""
}
],
"legacyScatterChartLabels":true,
"title":"July/2018, August/2018 and September/2018",
"type":"line",
"lineWidth":2,
"hAxis":{
"useFormatFromData":true,
"title":"Month",
"viewWindow":{
}
},
"series":{
"0":{
"dataLabelPlacement":"insideBase",
"dataLabel":"value",
"annotations":{
"position":"center"
},
"hasAnnotations":true
},
"1":{
"dataLabelPlacement":"below",
"dataLabel":"value",
"annotations":{
"position":"center"
},
"hasAnnotations":true,
"targetAxisIndex":1
}
},
"useFirstColumnAsDomain":true,
"domainAxis":{
"direction":1
},
"width":818,
"booleanRole":"certainty",
"height":506
}