Chart
A line, bar or area chart of figures from a tool result, with event markers.
≈ 1,282 tokens per use (tool 784 · guidance 292 · typical payload 206)How token costs are estimated
Example: Chart
Did the 4.12 release move signups?
Weekly signups
Last 12 weeks
| Week of | Signups |
|---|---|
| Jul 6, 2026 | 1,240 |
| Jul 13, 2026 | 1,310 |
| Jul 20, 2026 | 1,285 |
| Jul 27, 2026 | 1,352 |
| Aug 3, 2026 | 1,330 |
| Aug 10, 2026 | 1,398 |
| Aug 17, 2026 | 1,415 |
| Aug 24, 2026 | 1,730 |
| Aug 31, 2026 | 1,846 |
| Sep 7, 2026 | 1,902 |
| Sep 14, 2026 | 1,878 |
| Sep 21, 2026 | 1,951 |
- Marked: Release 4.12 at Aug 24, 2026
Up about 22% since 4.12 shipped, and holding.
When to use
- The user asks how a number changed over time or how categories compare, and you have the figures from a tool.
- The shape matters more than any single value: a trend, a spike, a gap between two series.
When not to use
- There are one or two numbers. Say them in a sentence.
- The user needs exact values across many fields. Use a Data Table.
- You don't have the data from a tool. Never invent or estimate points.
- The series use different units. Show two charts instead of mixing them on one axis.
How the agent should use it
- Copy
datafrom the tool result unchanged. Don't round, fill gaps or extrapolate. - Pick the type for the job:
linefor trends,barfor comparing categories,areafor volumes over time. - Set
stacked: trueon a bar chart only when the series are parts of a whole (revenue by product line per region). Each x value then gets one bar split into a piece per series. Leave bars side by side when the series are separate measures to compare (Q2 vs Q3). - Keep to 1–4 series that share a unit. They share one y-axis.
- Only annotate real events that explain the shape, like a release, and use an x value that exists in the data.
- Put the takeaway in
summaryin plain words, without repeating every number.
Hover
On bar charts the hover card is anchored above the hovered bar, centred on it, and stays put while the pointer moves inside the bar: it doesn't follow the cursor. On line and area charts the tooltip is pinned to one height and doesn't slide between points.
With stacked: true, hovering a piece lights up that series in every bar and fades the others, and the card shows the piece's value and its share of the bar. Pieces are rounded and separated by a small gap; the card rises over the heading when a bar is too tall to leave room above it.
Accessibility
The chart's SVG is hidden from screen readers. A visually hidden table with the same rows, captioned with the title, carries the numbers instead (with a Total column when stacked), and annotations are listed after it. Values are formatted with Intl in the axis, the tooltip and the table, so they follow the user's locale.
Installation
npx shadcn@latest add https://your-site.com/r/chart.json
Usage
The Chart is display-only, so the tool can return immediately:
import { tool } from "ai"
import { chartTool } from "@/components/genui/chart.schema"
const tools = {
[chartTool.name]: tool({
description: chartTool.description,
inputSchema: chartTool.inputSchema,
execute: async () => ({ shown: true }),
}),
}Render it through the Renderer under show_chart, or directly:
<Chart {...part.input} status={part.state === "input-streaming" ? "streaming" : "ready"} />Points render as they stream in, so a long series draws progressively.
With LangGraph
Push it from a graph node with ui.push({ name: "show_chart", props }, { message }), and render the thread's UI messages with the Renderer.
Schema
| Prop | Type | Notes |
|---|---|---|
title | string | What the chart shows. Also the data table's caption |
description | string? | Scope or source |
type | "line" | "bar" | "area" | |
stacked | boolean? | Bar only: one bar per x value, split into a piece per series |
x | { key, label?, format? } | format: text (default) or date for ISO dates |
series | { key, label, format?, currency? }[] | 1–4 series on one axis. format: number, currency or percent (12.5 means 12.5%) |
data | Record<string, string | number>[] | Data-bound. Rows with the x key and every series key |
annotations | { x, label }[]? | Up to 5 markers, e.g. a release |
summary | string? | One-sentence takeaway, shown under the chart |
Host props: status (streaming or ready) and className.