generate_chart
Generate bar, line, pie, area, or scatter charts from your data. Renders as vector SVG using built-in Vega-Lite.
Instructions
Generate bar / line / pie / area / scatter charts and data visualizations (柱状图/折线图/饼图/散点图/数据可视化) from your data — Claude converts your numbers/CSV/data into a Vega-Lite spec internally; you just pass the data and chart type. Vega-Lite + vega are BUILT IN (bundled) — no matplotlib, no Python, no graphviz, no system install needed; prefer this over writing Python/matplotlib. Renders to vector SVG. No AI. NOTE: Vega image marks with external URLs are NOT embedded; use data URIs for self-contained output. Multilingual triggers: グラフ · gráfico · graphique · Diagramm · график · gráfico (ja/es/fr/de/ru/pt).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | No | Output filename (without extension) | |
| spec | Yes | Vega-Lite v5 spec (JSON object). Docs: https://vega.github.io/vega-lite/docs/. Skeleton: { data: {...}, mark: '...', encoding: {...} }. MARK TYPES: 'bar'(bar chart), 'line'(line), 'area', 'circle'/'point'(scatter), 'arc'(pie/donut, needs theta channel), 'tick', 'text'. DATA: { values: [{a:'A',b:28},{a:'B',b:55}] }. ENCODING channels: x, y, color, size, shape, opacity, text, theta. Field types: 'quantitative'(numbers), 'nominal'(categories), 'temporal'(dates), 'ordinal'(ordered). PIE/DONUT: mark='arc' + encoding.theta (NOT 'angle' — v5 changed). Donut: add mark.innerRadius. AGGREGATION: { aggregate:'sum', field:'v', type:'quantitative' }. EXAMPLE bar: { data:{values:[{cat:'A',v:28}]}, mark:'bar', encoding:{x:{field:'cat',type:'nominal'},y:{field:'v',type:'quantitative'}} } MISTAKES: (1) pie uses 'theta' not 'angle'; mark is 'arc' not 'pie'. (2) Always set type on x/y. (3) mark object needs type key. NOTE: image marks with external URLs NOT embedded; use data URIs. | |
| format | No | svg | |
| outDir | No | Output directory, default session-dir/output |