Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google apps script 修改图表而不更改它';s属性_Google Apps Script_Google Sheets - Fatal编程技术网

Google apps script 修改图表而不更改它';s属性

Google apps script 修改图表而不更改它';s属性,google-apps-script,google-sheets,Google Apps Script,Google Sheets,我正在编写一个脚本来更改图表中的一些数据(本例中的标题),当我运行此函数时,我正在更改图表上的一些属性,图表将完全更改 这是我正在使用的代码: function ChangeChart() { var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Test'); var chart = sheet.getCharts()[0]; chart = chart.modify() .setOption('title',

我正在编写一个脚本来更改图表中的一些数据(本例中的标题),当我运行此函数时,我正在更改图表上的一些属性,图表将完全更改

这是我正在使用的代码:

function ChangeChart() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Test');
var chart = sheet.getCharts()[0];
chart = chart.modify()
  .setOption('title', 'Title Test')
  .build();
sheet.updateChart(chart);
}
这是运行脚本之前图表的外观:

及之后:

我正在使用此数据范围:

这是我运行函数前后的属性:

我看不出您的代码片段有任何错误,它与另一个代码片段类似,只是
EmbeddedChartBuilder
没有设置为变量,您正在
图表中直接修改它。可能是因为这个吗?尝试将
EmbeddedChartBuilder
设置为与博客文章中的代码段类似的变量。我看不出您的代码段有任何错误,它与另一个类似,只是
EmbeddedChartBuilder
未设置为变量,您正在
chart
中直接修改它。可能是因为这个吗?尝试将中的
EmbeddedChartBuilder
设置为与博客文章中的代码片段类似的变量。