I’m trying to make my Google Sheets line chart automatically fit the Y-axis range to my data values. My chart shows very small decimal changes like 0.745, 0.749, 0.753, etc. over different dates.
The problem is that the default axis range is too wide and makes my data look flat. I want the Y-axis to zoom in close to the actual data range so the variations are more visible.
I found some solutions online that suggest using .setOption() method, but when I try it I get this error message: “Exception: Unexpected error while getting the method or property setOption on object SpreadsheetApp.EmbeddedLineChartBuilder.”
It seems like this method doesn’t work with Google Apps Script for embedded charts. I also tried adding extra data points above and below my range but that didn’t help either.
Does anyone know a working way to make the vertical axis scale automatically adjust to fit tightly around the data values in Google Sheets charts?
Had this exact problem six months ago building financial dashboards. Yeah, setOption is broken with Google Sheets embedded charts through Apps Script. Here’s what actually worked: Use MINIFS and MAXIFS functions in helper cells to calculate your data range’s min and max values. Then manually set the vertical axis bounds in chart editor - go to ‘Customize’ tab, find ‘Vertical axis’ section, and input your custom min/max values. For decimal data, add a tiny buffer (like 0.001) above and below your calculated range so data points don’t touch the axis edges. Reference those calculated min/max cells so when data updates, you just refresh the axis bounds occasionally instead of doing everything manually. Gave me way better visual clarity for small variations without the scripting nightmare.
This drove me nuts for weeks until I found a workaround through the chart editor. Skip Apps Script entirely - just create your chart normally and double-click to edit it. Hit the Setup tab, click the three dots menu, and select “Switch to legacy charts” if you’re on the new editor. The legacy version actually works for axis control. Once you’re there, go to Customize > Vertical axis and set your min/max values manually based on your data. I calculate min/max in separate cells using MIN() and MAX() functions, then add about 5% buffer above and below for the axis bounds. Yeah, you’ll need to adjust these manually when your data updates, but it’s way more reliable than the broken setOption method. The difference is huge when you’re dealing with small decimal variations - tight axis scaling makes everything so much clearer.
Honestly, just use conditional formatting on your data range first, then create the chart. Google Sheets auto-scales way better when it recognizes formatted data. Also switch to ‘smooth line chart’ instead of regular line - it handles tight y-axis scaling much better with decimal data.