chart_from_block
Create charts from spreadsheet data blocks by naming fields instead of cell ranges. The chart stays linked to the block, so new records and row/column insertions don't break it.
Instructions
Chart a block by naming its fields, instead of working out which cells they occupy.
The chart stays bound to the block: it plots whatever the named fields hold, so records added to the block later appear on their own and inserting rows or columns cannot leave it pointing at the wrong cells. A col-schema block works the same way as a row-schema one.
Use edit__describe_block or inspect first if you do not know the field names. Blocks with a "random" schema have no field axis and cannot be charted this way — chart their cell range with chart__insert instead.
Fields are held by name. Renaming one breaks the link (the series goes empty); moving its column does not.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| title | No | Defaults to the block's schema name. | |
| anchor | No | Top-left cell of the chart. Defaults to two rows below the block. | |
| blockId | Yes | ||
| sheetIdx | Yes | Zero-based sheet index. | |
| chartType | No | Defaults to col. | |
| sizeInCells | No | ||
| valueFields | Yes | Field names to plot, one series each, in order. | |
| categoryField | No | Field whose values label the categories (the X axis). The block's key column is not addressable as a range, so name the field that reads as a label. Omitted, the categories are just 1..n. |