在使用功能编辑谷歌工作表中的饼图标题后,饼图显示错误

问题描述 投票:0回答:0

你好,我对谷歌表格中的饼图有疑问。我的图表只使用一列 (B)

这就是图表的外观。

我正在使用一个函数来动态更改字幕。

function onEdit(event) {
  var sheet = event.source.getActiveSheet();
  var cell = sheet.getRange("W2");
  var games = cell.getValue();
  var valuss = "Bei "+ games + " Spielen";
  //chartID: 406659648
  // Get the chart to update
  var chart = sheet.getCharts()[0]; // replace 0 with the index of the chart you want to update (if you have multiple charts)
  
    // Update the chart title with the new value
    chart = chart.modify().setOption('subtitle', valuss).build();
    sheet.updateChart(chart);


    var values = sheet.getRange("A1:B").getValues();

      // Update the appropriate cell with the new subtitle
      values[0][1] = newValue;

      // Set the updated values back to the range
      sheet.getRange("A1:B").setValues(values);
  
  chart = chart.modify().setOption('options', options).build();
    
    sheet.withSuccessHandler(function(){
        SpreadsheetApp.flush(); // Force the changes to be applied immediately
      }).getCharts();
}

但是执行此代码后,我的饼图显示以下内容

在德语中表示“至少需要 2 列,但只有 1 列可用”

如果我现在单击“聚合”复选框,图表看起来非常好并且副标题已正确编辑。

有人知道这是为什么吗

最好的问候, 卢卡斯

javascript google-apps-script google-sheets pie-chart
© www.soinside.com 2019 - 2024. All rights reserved.