pptx_add_chart
Add a chart to a PowerPoint slide by specifying chart type, data with categories and series, and position, returning the new shape index.
Instructions
Add a chart to a slide.
The data argument must follow the structure documented in
:func:_build_chart_data: a dict with "categories" (list of
x-axis labels) and "series" (list of {"name", "values"}
dicts).
Args:
path: Path to an existing .pptx.
chart_type: One of column, bar, line, pie,
etc. — see :data:_CHART_TYPE_MAP. (VAL-PPTX-051,
VAL-PPTX-052.)
data: Chart data structure with categories and series
keys (VAL-PPTX-051).
x: Left edge in inches.
y: Top edge in inches.
w: Width in inches.
h: Height in inches.
slide: 0-based slide index (VAL-PPTX-055).
folder: Optional base folder for relative paths.
Returns:
{"shape_index": <int>} — 0-based index of the new chart
within the slide's shape list.
Raises:
OfficeMCPError: ERR_INVALID_PARAMS for unknown
chart_type (VAL-PPTX-053), empty series
(VAL-PPTX-054), out-of-range slide
(VAL-PPTX-055), or non-numeric geometry;
ERR_FILE_NOT_FOUND if the file is missing;
ERR_UNSUPPORTED_FMT for non-.pptx extensions.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | ||
| chart_type | Yes | ||
| data | Yes | ||
| x | Yes | ||
| y | Yes | ||
| w | Yes | ||
| h | Yes | ||
| slide | No | ||
| folder | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||