Skip to main contentChart Creation
Use X21 to generate charts without leaving the chat. Claude can analyse a dataset, select an appropriate visual, and request the create_chart tool to build it directly inside Excel.
- Inputs
workbookName, worksheet
chartType – e.g., ColumnClustered, Line, Pie, BarStacked.
sourceData – Range containing the data (e.g., A1:C20).
- Optional metadata: chart title, axis labels, series names, chart position (
top, left, width, height).
- The Excel API adds a chart object to the specified worksheet, positions it relative to the top-left cell of the destination range, and returns coordinates for verification.
Typical Workflow
- Ask Claude to analyse the current selection and recommend a chart.
- Review the proposed chart data and configuration in the chat response.
- Approve the
create_chart tool request. Use View to preview and adjust before final approval.
- After creation, Claude can suggest follow-up formatting (e.g., colour changes via
write_format on chart elements).
Customisation Tips
- Encourage Claude to name series explicitly. The tool accepts a
series array so legends stay meaningful even when column headers are ambiguous.
- Use
read_values to verify the data range before charting—especially when data contains blanks or totals that should be excluded.
- Charts respect existing theme colours. For custom palettes, instruct Claude to apply formatting via subsequent tool calls.
Supported Chart Types
The default implementation covers the most common Excel charts:
- Clustered and stacked column/ bar charts.
- Line and area charts (single or multi-series).
- Pie and doughnut charts.
- Scatter plots (using X/Y ranges).
Extend HandleCreateChart in the Excel API to add specialised types like combo charts or waterfall visualisations.
Troubleshooting
- If the chart appears off-screen, adjust the position parameters or ask Claude to move it using
write_format on the chart object.
- Invalid ranges or non-numeric data trigger errors returned to the UI. Review the range and ensure it contains headers + numeric series.
- Charts created on protected sheets require the sheet to be unlocked first.
By combining chart creation with Claude’s descriptive explanations, you can produce polished visuals faster than manual Excel workflows.