Google Sheets is used everywhere for reports and dashboards. Charts make data easier to understand, but sometimes they end up in the wrong spot. A chart might block data, overlap text, or just look messy.
That’s where Google Apps Script comes in. With a few lines of code, you can move charts automatically, keep layouts clean, and even set them to reposition when data changes.
Can Apps Script Move Charts in Google Sheets?
Yes, you can move charts in Google Sheets with Apps Script — but only embedded charts (charts placed inside a sheet). Apps Script does not move full “chart sheets.”
Here’s what Apps Script can do with charts:
- Move a chart to a specific cell.
- Adjust its position with pixel offsets.
- Copy or move charts to another sheet.
- Rearrange multiple charts at once.
- Auto-move charts after edits with triggers.
Why Move Charts in Google Sheets?
There are many reasons you may want to reposition charts in a sheet. A common one is building a dashboard where charts should line up in rows or columns. If charts overlap cells, your sheet looks unorganized.
Some users also need auto-layout. For example, if data refreshes every day, new charts can end up out of place. Moving them with code saves time. Reports shared with teams also look more professional when charts are aligned.
How Chart Positioning Works in Google Sheets?
Charts in Google Sheets don’t live inside cells. Each one is an EmbeddedChart object with its own container. Apps Script moves them by setting an anchor cell and adding pixel offsets.
- Anchor cell: row and column where the chart starts.
- Pixel offsets: small shifts inside that cell (right or down).
You control both with .setPosition(row, column, offsetX, offsetY)
.
Move a Chart to a Specific Cell with Apps Script
Moving a chart to a specific cell is the most common task. This works by anchoring the chart to a row and column with zero or small offsets.
Here are the steps:
- Open your spreadsheet.
- Click Extensions > Apps Script.
- Paste this code:
function moveChartToCell() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var chart = sheet.getCharts()[0]; // first chart on the sheet
var updated = chart.modify().setPosition(5, 2, 0, 0).build();
sheet.updateChart(updated);
} - Save and run the function.
- The chart will now sit at row 5, column 2.
Nudge a Chart by Pixels for Fine Control
Sometimes you don’t want to change the anchor cell, just move the chart slightly. Pixel offsets let you nudge charts in small amounts.
Steps:
- Open Apps Script.
- Add
.setPosition(row, column, offsetX, offsetY)
. - Example:
function nudgeChart() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var chart = sheet.getCharts()[0];
var updated = chart.modify().setPosition(5, 2, 20, 15).build();
sheet.updateChart(updated);
} - Run it to move the chart 20 pixels right and 15 pixels down.
Move a Chart to Another Sheet in Google Sheets
You can also move charts between sheets, but this works by copying and inserting. A chart is tied to its current sheet, so you must create a new one in the target sheet.
Checklist for cross-sheet movement:
- Get the chart with
getCharts()
. - Copy it using
.copy()
. - Insert into the new sheet with
insertChart()
. - Remove the old chart with
removeChart()
.
This way, your chart is safely relocated without rebuilding it.
Reposition Multiple Charts at Once with Apps Script
If your sheet has many charts, you can arrange them in rows and columns using a loop. This is useful for dashboards where you want a clean grid.
Steps:
- Get all charts with
getCharts()
. - Create a loop with
for
orfor...of
. - Use math to calculate row and column positions.
- Apply
.setPosition()
with spacing. - Update each chart with
updateChart()
. - Repeat until all charts are neatly arranged.
Automate Chart Placement with Google Apps Script Triggers
Instead of running scripts by hand, you can set triggers to move charts automatically. This is helpful if your sheet updates often.
Ways to use triggers:
onEdit(e)
→ run when a user edits a cell.onChange
→ run when structure or data changes.- Time-driven trigger → run daily or hourly.
- Event objects → control how charts update.
- Dashboard refresh → reposition charts after new imports.
With triggers, your charts always stay in place.
Limits and Errors You Should Know When Moving Charts
App Script chart control is powerful, but there are some limits:
- Only embedded charts are supported (chart sheets not supported).
- Pixel offsets can look different for people on different zoom levels.
- Protected sheets may block updates.
- You need edit permissions to move charts.
- Big dashboards with many charts may run slower.
Advanced Option: Using Sheets API for Charts
For people who need more precise control, the Advanced Sheets API can be used inside Apps Script. This method allows you to send detailed update requests for charts beyond what SpreadsheetApp alone can handle. It becomes especially useful if you need to move a large number of charts in one batch, or if you want to update charts at the same time as formatting ranges and other data changes.
The API is also helpful when building custom dashboards that rely on heavy automation. Setting it up takes more effort compared to basic Apps Script, but it provides more flexibility and control over how charts are managed.
Best Practices for Stable Chart-Moving Scripts
To keep your scripts reliable, follow some best practices:
- Always name or label charts so you know which one you’re moving.
- Add comments in code for clarity.
- Use V8 runtime for faster loops.
- Add small delays (
Utilities.sleep
) if moving many charts. - Test on a copy of the sheet before using in production.
Tips to Keep Google Sheets Charts Organized Automatically
You can avoid messy layouts with a few habits.
- Place charts in consistent anchor cells.
- Use triggers to reposition charts after edits.
- Keep dashboards simple to reduce lag.
- Share helper scripts with your team.
- Plan space for charts before adding them.
These steps save time and make dashboards look professional.
Conclusion
Yes, you can use Google Apps Script to move charts in Google Sheets. By using setPosition, you control anchor cells and pixel offsets. You can also copy charts to new sheets, arrange multiple charts, and even automate with triggers.
For dashboards and reports, this means less manual work and cleaner layouts — your charts always stay right where they should.