Manage charts
manage_chartsAdd, update, or delete embedded charts in Google Sheets by defining chart type, data ranges, and placement. Supports standard chart types or custom Sheets API specs.
Instructions
Manages embedded charts. action=add builds a chart from chart_type (COLUMN/BAR/LINE/AREA/STEPPED_AREA/SCATTER/PIE), domain_range (x-axis labels / pie labels), series_ranges (one grid range per data series; PIE takes exactly one) and optional title/legend_position/header_count (rows of the ranges treated as headers, default 1) — place it with anchor {sheet_id,row_index,column_index} (the cell under the chart's top-left corner) or new_sheet=true for its own chart sheet; the reply carries the new chartId. Ranges should be single columns (or rows) including the header cell. For chart kinds beyond the basic set (combo, waterfall, histogram, org …) pass a raw Sheets API ChartSpec via spec instead — it overrides the simplified fields. action=update REPLACES the whole spec of an existing chart (chart_id + the same spec-building fields; there is no partial chart update). action=delete removes the chart by chart_id. Find chartIds via get_spreadsheet (sheets[].charts).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| spec | No | Raw Sheets API ChartSpec — full control; overrides the simplified fields above. | |
| title | No | Chart title. | |
| action | Yes | What to do with the charts. | |
| anchor | No | add: place the chart over the grid, top-left at this cell. | |
| chart_id | No | update/delete: the chartId from get_spreadsheet or the add reply. | |
| new_sheet | No | add: put the chart on its own new chart sheet instead. | |
| chart_type | No | add/update: the chart kind (required unless spec is given). | |
| domain_range | No | The x-axis (or pie label) values, incl. header cell. | |
| header_count | No | How many leading rows of the ranges are headers (default 1). | |
| series_ranges | No | One range per data series, incl. header cells (PIE: exactly one). | |
| spreadsheet_id | Yes | The spreadsheet id — the long id from the URL (docs.google.com/spreadsheets/d/<spreadsheetId>/edit) or from create_spreadsheet / search_spreadsheets output. | |
| legend_position | No | BOTTOM_LEGEND, LEFT_LEGEND, RIGHT_LEGEND, TOP_LEGEND or NO_LEGEND (default: API's choice). |