I'm trying to update the title of my chart through the code so it is changed dynamically. When this happens, the title changes successfully, but the number format for the vertical axis changes to dates (changes to from source data).
I'm not sure where it's getting the dates either because the source data is set to Number. Changing it to 'format by' anything else using the script has no effect. It just ignores it.
Even a macro doesn't work. When I try to do this with a macro I get the error: "Exception: Unexpected error while getting the method or property setOption on object SpreadsheetApp.EmbeddedChartBuilder."
I have this code that runs when the button is pressed. It changes the title of the chart to the value in K1 but I don't understand why it changes the vertical axis to dates as well. I just want it to remain at "none" or "decimal":
function updateTitle() {
var sheet = SpreadsheetApp.getActive().getActiveSheet();
var chart = sheet.getCharts()[0];
var title = sheet.getRange('K1').getValue();
chart = chart.modify()
.setOption('title', title || 'Empty')
.setOption('vAxis.format', 'none')
.build();
sheet.updateChart(chart);
}
I'm thinking the formatting of the code must be incorrect, is that true? I've searched all over the Internet, and I've found tons of different ways to format modifying google charts, and have tried many different variations. I'm not getting it right and am kind of lost about what format is correct and why what I'm doing isn't working.
Here is an example of my chart: https://docs.google.com/spreadsheets/d/16vmDv5sJvle4hLXaz1ZTgkP8V2-5dlWJvdJ9eqPxc-w/edit?usp=sharing
Thank you
