I've encountered a problem while attempting to convert all column charts in my spreadsheet to 3D column charts. Despite following Google's documentation, I receive an error message when running the code below.
Could this be an issue with the API? Or is there an error in my code?
function threeDCharts(){
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var sheetID = sheet.getId();
var charts = sheet.getSheetByName("Data").getCharts();
var ids = [];
var requests = [];
for(i=0;i<charts.length;i++){
ids.push(charts[i].getChartId())
}
for(i=0;i<charts.length;i++){
requests.push({"updateChartSpec":{
"chartId": ids[i],"spec":{
"basicChart": {
"chartType": "column", "threeDimensional":true
}
}
}});
}
var resp = Sheets.Spreadsheets.batchUpdate({requests:requests}, sheetID);
}
The exact error message reads as follows:
GoogleJsonResponseException: API call to sheets.spreadsheets.batchUpdate failed with error: Invalid requests[0].updateChartSpec: chartSpec.basicChart.threeDimensional not supported when chartSpec.basicChart.chartType is COLUMN.
The "threeDimensional" attribute should work according to Google's documentation at the link provided below.
Edit for clarity:
Attached is a sample spreadsheet illustrating the issue.
Another part of my script will generate two column charts based on the averages calculated by the spreadsheet from individual measurements.
The function mentioned earlier locates all charts in the sheet and updates them using an updateChartSpec request to switch the column charts to the "3D" format.
Measurement | Sample A | Sample B | Sample C |
---|
Click here to see the expected transformation from the left chart to the right chart