AI-generated Key Takeaways
-
ContainerInfo
allows you to access and update an embedded chart's position within a Google Sheet. -
You can get the chart's anchor column and row, which determine its main positioning.
-
OffsetX
andOffsetY
properties provide pixel-level control over the chart's placement relative to the anchor point. -
Use the
modify()
andsetPosition()
functions along withupdateChart()
to change the chart's position programmatically.
Access the chart's position within a sheet. Can be updated using the Embedded
function.
const sheet = SpreadsheetApp.getActiveSheet(); const chart = sheet.getCharts()[0]; const modifiedChart = chart.modify().setPosition(5, 5, 0, 0).build(); sheet.updateChart(modifiedChart);
Methods
Method | Return type | Brief description |
---|---|---|
get | Integer | The chart's left side is anchored in this column. |
get | Integer | The chart's top side is anchored in this row. |
get | Integer | The chart's upper left hand corner is offset from the anchor column by this many pixels. |
get | Integer | The chart's upper left hand corner is offset from the anchor row by this many pixels. |
Detailed documentation
getAnchorColumn()
The chart's left side is anchored in this column.
Return
Integer
— 1-indexed column (that is, column C is 3).
getAnchorRow()
The chart's top side is anchored in this row.
Return
Integer
— 1-indexed row (that is, row 5 returns 5).
getOffsetX()
The chart's upper left hand corner is offset from the anchor column by this many pixels.
Return
Integer
— The horizontal offset in pixels for the upper left hand corner of the chart.
getOffsetY()
The chart's upper left hand corner is offset from the anchor row by this many pixels.
Return
Integer
— The vertical offset in pixels for the upper left hand corner of the chart.