Hello I have a problem with a pie chart in google sheets. My chart only uses one column (B)
And this is how the chart should look.
I am using a function in order to change the subtitle dynamically.
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();
}
But after this code gets executed my pie chart displays the following
which is German for "At least 2 columns required, but only 1 available"
If I now I click the "Aggregate" checkbox the chart looks perfectly fine and the subtitle is correctly edited.
Does anyone know why that is ?
Best Regards, Lukas