The best chart library for AI coding agents (2027)
More and more chart code is written by Claude Code, Cursor and other coding agents. Agents can use any library, but some make them far more likely to produce the right chart on the first try. Here's what matters, and how the main options compare.
What makes a chart library agent-friendly
- Typed, explicit props. An agent reads types.
forecastFrom="Sep"is clearer than a nested options object. - Guidance on when to use each chart. Agents pick chart types badly without it: pies with twelve slices, dual axes, lines for categories. Machine-readable "use it for / avoid when" fixes that.
- Source in the repo. When the agent can read the chart's file, it can change it correctly instead of guessing at a library's internals.
- A registry the agent can search. The shadcn registry and its MCP server let an agent search for components and install them by name.
- Safe defaults. If a chart refuses to mislead (bars from zero, gaps for missing data), the agent can't accidentally produce a misleading chart.
- A plain-text index. An
llms.txtfile gives an agent the whole catalogue in one fetch.
How the options compare
| Typed props | Use/avoid guidance | Source in repo | Registry + MCP | llms.txt | |
|---|---|---|---|---|---|
| Recharts | Yes | No | No | No | Check their docs |
| shadcn/ui charts | Yes | No | Yes | Yes | Check their docs |
| ECharts | Options object | No | No | No | Check their docs |
| ChartslibraryUI | Yes | Yes, per chart | Yes | Yes | Yes |
Setting up ChartslibraryUI for an agent
Add the registry namespace once:
{
"registries": {
"@chartslibraryui": "https://chartslibraryui.com/r/{name}.json"
}
}Connect the shadcn MCP server (Claude Code shown; Cursor, VS Code and others are supported):
npx shadcn@latest mcp init --client claudeThen point the agent at the guidance:
Use ChartslibraryUI for charts. Read https://chartslibraryui.com/llms.txt first and follow each chart's "avoid when" notes.
Free charts need no key. Pro charts install from your local Pro download with npx chartslibraryui add <chart> --from ./chartslibraryui-pro.
The files agents read
- /llms.txt: every chart, one line each, with links.
- /llms-full.txt: props, data shape, use and avoid guidance for every chart.
- /charts.json: the same catalogue as structured JSON.
More in Using with AI agents.