chart
Create, manage, and configure Excel charts: add series, set axes, trendlines, legends, and more.
Instructions
Perform chart lifecycle and series/configuration operations on a worksheet.
Args:
action: One of "create", "delete", "list", "add_series", "set_axes", "trendline", "combo", "data_labels", "legend", "update".
- "create": create a chart from data_range at target_cell; optional categories_range overrides x-axis category labels.
- "delete": remove a chart (optionally chart_index). Destructive.
- "list": return list of charts (read-only).
- "add_series": add a series to an existing chart (requires chart_index, data_range).
- "set_axes": configure axis titles/ranges/number format; optional categories_range sets x-axis category labels.
- "trendline": add a trendline to a series.
- "combo": create a combo chart; requires bar_columns and line_columns.
- "data_labels": configure data labels by chart_title.
- "legend": configure legend by chart_title.
- "update": update basic title/size/anchor of an existing chart.
file_path: Workbook path.
sheet_name: Worksheet name containing chart or data.
chart_index: Optional index of target chart (default 0 or required for some actions).
data_range: Range string used for chart creation or series.
chart_type: Chart kind (e.g. "column", "line").
target_cell: Anchor cell for new chart.
... (other visual/series parameters)
Returns: str or list[ChartInfo]: Created chart id/string or list of ChartInfo for "list".
Raises:
ValueError: If required parameters are missing for the selected action.
Notes: - Dispatch mapping: see function source; common destructive actions include "delete". - Chart creation mutates the workbook; consider documenting expected anchor and sizing units.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | No | ||
| style | No | ||
| title | No | ||
| width | No | ||
| x_max | No | ||
| x_min | No | ||
| y_max | No | ||
| y_min | No | ||
| action | Yes | ||
| height | No | ||
| x_title | No | ||
| y_title | No | ||
| file_path | Yes | ||
| chart_type | No | column | |
| data_range | No | ||
| sheet_name | Yes | ||
| show_value | No | ||
| anchor_cell | No | F1 | |
| bar_columns | No | ||
| chart_index | No | ||
| chart_title | No | ||
| log_scale_y | No | ||
| show_legend | No | ||
| target_cell | No | E1 | |
| line_columns | No | ||
| series_index | No | ||
| x_axis_title | No | ||
| y_axis_title | No | ||
| show_category | No | ||
| x_axis_column | No | ||
| label_position | No | ||
| trendline_type | No | linear | |
| legend_position | No | ||
| periods_forward | No | ||
| show_percentage | No | ||
| title_from_data | No | ||
| y_number_format | No | ||
| categories_range | No | ||
| periods_backward | No | ||
| show_series_name | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |