add_chart
Insert a native Word chart from tabular data, JSON, or CSV, choosing bar, column, line, pie, or scatter. Embeds an editable workbook, so the chart renders consistently and supports Edit Data in Word.
Instructions
Insert a native, theme-following Word chart built from data (no image rendering). chart_type: 'bar' (horizontal), 'column' (vertical), 'line', 'pie', or 'scatter'. data shapes: rows like import_table ([["", "S1", "S2"], ["Alpha", 4.3, 1.2], ...]; first row series names, first column categories), a dict {"categories": [...], "series": [{"name", "values"}]} (scatter: {"series": [{"name", "x", "y"}]}), or a .csv/.json file path. The chart part carries literal data caches AND a matching embedded workbook, so it renders everywhere and right-click > Edit Data works in Word. Size defaults to 6.0 x 3.5 in (width_pt/height_pt override); position with at most one of after_index/after_anchor/at_end (default document end); colors takes one hex per series (default: theme accents). Refused: other chart types (3D/area/doughnut/radar/...), ragged or non-numeric data, multi-series pie. Auto-backup: prev/anchor slots in .ks4w-backups (backup=False skips rotation only); atomic validated save. Refuses documents open in Word.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data | Yes | ||
| title | No | ||
| at_end | No | ||
| backup | No | ||
| colors | No | ||
| legend | No | ||
| width_pt | No | ||
| alignment | No | center | |
| file_path | Yes | ||
| height_pt | No | ||
| chart_type | Yes | ||
| after_index | No | ||
| after_anchor | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||