<Chart id="chart-example" type="bar" title="Monthly Revenue" description="Revenue vs Expenses (2024)" data={[ { "month": "Jan", "revenue": 4000, "expenses": 2400 }, { "month": "Feb", "revenue": 3000, "expenses": 1398 }, { "month": "Mar", "revenue": 5000, "expenses": 3200 }, { "month": "Apr", "revenue": 2780, "expenses": 3908 }, { "month": "May", "revenue": 1890, "expenses": 4800 }, { "month": "Jun", "revenue": 2390, "expenses": 3800 } ]} xKey="month" series={[ { "key": "revenue", "label": "Revenue" }, { "key": "expenses", "label": "Expenses" } ]} colors={[ "#14B8A6", "#F87171" ]} showLegend showGrid/>"How did I spend money this week?" is a question best answered visually. Chart renders bar or line visualizations inline in the conversation. You pass data, an x-axis key, and one or more series. The assistant can show spending breakdowns, revenue trends, or performance over time without describing the numbers in prose.
Role: Information. For displaying data the user reads. See Design Guidelines for how component roles work.
Run this once from your project root.
npx shadcn@latest add @tool-ui/chartRender Chart in your UI with tool-compatible props.
import { Chart } from "@/components/tool-ui/chart";<Chart id="monthly-revenue" type="bar" title="Monthly Revenue" description="2024 YTD" data={[ { month: "Jan", revenue: 4000, expenses: 2400 }, { month: "Feb", revenue: 3000, expenses: 1398 }, // ... ]} xKey="month" series={[ { key: "revenue", label: "Revenue" }, { key: "expenses", label: "Expenses" }, ]} showLegend showGrid/>;Register this renderer so tool results display as Chart.
<Chart id="clickable" type="line" data={data} xKey="time" series={[{ key: "value", label: "Value" }]} onDataPointClick={(point) => { console.log("Clicked:", point.xValue, point.yValue); }}/>Bar for categorical data, line for time-series
Plot multiple datasets with automatic color assignment
Hover tooltips and click handlers on data points
Optional legends, grid lines, and custom color palettes
Use type="line" for time-series or continuous data.
Only data, xKey, and series are required. Title, description, legend, and grid are all optional.
Prop
Type
Prop
Type
Prop
Type