insertChart
Adds bar, line, pie, treemap, and other charts to Google Sheets from a specified data range, placing them as overlays at an anchor cell.
Instructions
Inserts a chart into a Google Sheet. Supports bar, column, line, area, scatter, pie, donut, and treemap (hierarchical) chart types. For treemap charts, the data must have a label column and a parent label column (use empty string for root nodes) plus a numeric size column. Chart is placed as an overlay at the specified anchor cell.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"spreadsheetId": "<spreadsheetId>",
"chartType": "<chartType>",
"dataRange": "<dataRange>"
},
"name": "insertChart"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| title | No | Chart title. | |
| anchorRow | No | Row index (0-based) of the anchor cell for chart placement. | |
| chartType | Yes | Chart type to create. | |
| dataRange | Yes | A1 notation range of the data (e.g., "A1:E50"). Include the header row if present. | |
| headerRow | No | Whether the first row of the data range is a header row. | |
| sheetName | No | Name of the sheet/tab containing the data. Defaults to the first sheet. | |
| stackedType | No | For bar/column/area charts: whether to stack series. NOT_STACKED = grouped, STACKED = absolute stacked, PERCENT_STACKED = 100% stacked. | NOT_STACKED |
| widthPixels | No | Chart width in pixels. | |
| anchorColumn | No | Column index (0-based) of the anchor cell for chart placement. | |
| heightPixels | No | Chart height in pixels. | |
| offsetXPixels | No | Horizontal offset in pixels from the anchor cell. | |
| offsetYPixels | No | Vertical offset in pixels from the anchor cell. | |
| spreadsheetId | Yes | The spreadsheet ID — the long string between /d/ and /edit in a Google Sheets URL. | |
| labelColumnIndex | No | For pie/donut/treemap: 1-based column index for node labels (default: 1). For treemap this is the leaf/child label. | |
| valueColumnIndex | No | For pie/donut/treemap: 1-based column index for the numeric size/value (default: 2). | |
| parentColumnIndex | No | For treemap: 1-based column index for parent node labels. Root nodes should have an empty string in this column. |