Chart
npx tool-agent "integrate the chart component to visualize data with interactive charts"npx shadcn@latest add @tool-ui/chart"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.
Getting Started
Run this once from your project root.
npx tool-agent "integrate the chart component to visualize data with interactive charts"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.
import { type Toolkit } from "@assistant-ui/react";import { Chart } from "@/components/tool-ui/chart";import { safeParseSerializableChart } from "@/components/tool-ui/chart/schema";export const toolkit: Toolkit = { showChart: { type: "backend", render: ({ result }) => { const parsed = safeParseSerializableChart(result); if (!parsed) { return null; } return <Chart {...parsed} />; }, },};Key Features
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
Variants
Line Charts
Use type="line" for time-series or continuous data.
Minimal Configuration
Only data, xKey, and series are required. Title, description, legend, and grid are all optional.
Props
Prop
Type
Series Schema
Prop
Type
ChartDataPoint (click handler payload)
Prop
Type
Accessibility
- Built on Recharts with semantic SVG structure
- Tooltips and legends provide text alternatives for visual data
- Inherits focus management from shadcn/ui Card primitives
Related
- Stats Display: key metrics as a grid of numbers with sparklines