GPT-Vis: Turn AI answers into charts. ✨
An open-source visualization library for AI agents and applications.
Render charts from JSON or Syntax, add analysis annotations, and reuse your theme everywhere.
Website · Documentation · Examples · Theme Studio · Agent Skill
- 🚀 Framework Agnostic — Works with vanilla JavaScript, React, Vue, Angular, or any framework
- ✍️ Markdown-like Syntax — Simple syntax that LLMs can generate directly, easy to learn and use
- 🌊 Streaming Rendering — Native support for AI model streaming output, renders as it generates
- 🛡️ Fault Tolerant — Gracefully handles incomplete or malformed data, adapts to the uncertainty of AI-generated content
- 📊 26 Chart Types — Statistical charts, relationship graphs, and text visualizations covering mainstream scenarios
- 🎨 Reusable Themes — Share one ThemeSpec across all chart types; preview and refine it in Theme Studio, or create it with an AI skill
- 28 Analysis Capabilities — Mark extremes, ranks, means, targets, regions, and crossings, with statistical references computed by the SDK
- Agent Skill — Give AI assistants guidance for chart selection, configuration, framework integration, and theme creation
Built on G2, G6, and T8. Works with vanilla JavaScript, React, Vue, and other browser frameworks.
Run this command from your project directory and choose a compatible assistant:
npx skills add https://github.com/antvis/GPT-Vis/tree/ai --skill chart-visualizationThen ask your agent to create its first report:
Use the GPT-Vis Skill to create an H1 revenue report: Jan 84, Feb 96, Mar 91, Apr 118, May 126, Jun 148, in USD 10k. Include a line chart, a table, and a short summary. Use a shared theme and save a report.html that I can open in a browser.
The Skill includes chart selection guidance, runnable configuration patterns, and a Theme Creator reference. Read the Skill source.
npm install @antv/gpt-visAdd a container and run the following after it mounts:
<div id="chart" style="width: 100%; height: 360px;"></div>import { GPTVis } from '@antv/gpt-vis';
const chart = new GPTVis({ container: '#chart', height: 360, theme: 'product' });
const data = [
{ time: 'Jan', value: 84 },
{ time: 'Feb', value: 96 },
{ time: 'Mar', value: 91 },
{ time: 'Apr', value: 118 },
{ time: 'May', value: 126 },
{ time: 'Jun', value: 148 },
];
chart.render({
type: 'line',
title: 'Monthly revenue (USD 10k)',
data,
});
// When the view unmounts:
// chart.destroy();Prefer text? Render the same chart with Syntax
The same render() method accepts this text:
chart.render(`vis line
title Monthly revenue (USD 10k)
data
- time Jan
value 84
- time Feb
value 96
- time Mar
value 91
- time Apr
value 118
- time May
value 126
- time Jun
value 148`);Quickstart · Syntax guide · API reference
Pass the accumulated output to render() on each update. GPT-Vis supports partial input so charts can appear before the response is complete.
import { GPTVis, isVisSyntax } from '@antv/gpt-vis';
const chart = new GPTVis({ container: '#chart', width: 600, height: 400 });
let buffer = '';
function onToken(token) {
buffer += token;
if (isVisSyntax(buffer)) {
chart.render(buffer);
}
}Use annotations to put means, targets, rankings, and outliers directly on the chart.
Reuse the quickstart data and add a mean reference and a revenue target of 140:
chart.render({
type: 'line',
data,
annotations: [{ type: 'mean' }, { type: 'thresholdY', threshold: 140, label: 'Target 140' }],
});The mean is 110.5 and June's revenue of 148 exceeds the target, in USD 10k. The SDK computes the mean; your configuration supplies the target.
See all 28 analysis capabilities
| Intent | Capabilities | type identifiers |
|---|---|---|
| Extremes & observations · 8 | X/Y maximum and minimum, first and last observation, local peaks and valleys | maxX, minX, maxY, minY, first, last, peak, valley |
| Ranking & contribution · 4 | Top N, Bottom N, series emphasis, contribution | topN, bottomN, group, contribution |
| Statistical references · 5 | Mean, median, quantile, IQR outliers, scatter center or weighted center | mean, median, quantile, outlier, centroid |
| Thresholds & targets · 4 | X/Y threshold lines, target or baseline, threshold emphasis | thresholdX, thresholdY, target, thresholdHighlight |
| Ranges & regions · 5 | X/Y intervals, inside/outside range, quadrants | rangeX, rangeY, rangeInside, rangeOutside, quadrant |
| Events & crossings · 2 | Event markers, threshold crossings or two-series intersections | event, crossing |
Explore all 28 capabilities · Supported charts, selectors, and calculation rules
These capabilities describe the current source. Check that your chosen SDK release includes the annotations you need; installing the Skill does not upgrade the rendering library.
render() supports two input formats: JSON objects (ideal for programmatic use) and DSL syntax (ideal for LLM streaming).
Pass JSON objects directly for programmatic chart creation:
Line chart:
chart.render({
type: 'line',
data: [
{ time: '2020', value: 100 },
{ time: '2021', value: 120 },
{ time: '2022', value: 150 },
],
});Pie chart:
chart.render({
type: 'pie',
data: [
{ category: 'Android', value: 72 },
{ category: 'iOS', value: 28 },
],
innerRadius: 0.6,
});For theme names, custom ThemeSpec objects, and style overrides, see Themes and styles.
Custom Styles:
chart.render({
type: 'line',
data: [
{ time: '2020', value: 100 },
{ time: '2021', value: 120 },
],
style: { mark: { line: { lineWidth: 3 } }, palette: ['#5B8FF9', '#5AD8A6'] },
});Declarative markdown-like syntax that LLMs can generate without learning complex APIs:
vis [chart-type]
[property] [value]
data
- [field] [value]
Pie chart:
vis pie
data
- category Sales
value 30
- category Marketing
value 25
innerRadius 0.6
Themes:
vis line
data
- time 2020
value 100
- time 2021
value 120
theme dark
Custom Styles:
Use style to set line width, custom palettes, and more:
vis line
data
- time 2020
value 100
- time 2021
value 120
style
mark
line
lineWidth 3
palette
- #5B8FF9
- #5AD8A6
Quoted string values (for values with spaces):
vis pie
data
- category "Q1 Sales"
value 30
- category "Q2 Sales"
value 25
Hierarchical data:
vis mindmap
data
- name Project Plan
children
- name Phase 1
- name Phase 2
Render DSL syntax:
const visSyntax = `
vis line
data
- time 2020
value 100
- time 2021
value 120
- time 2022
value 150
`;
chart.render(visSyntax);Share colors, typography, and styles across charts and tables. Choose from 10 gallery presets, including gpt-vis, midnight, paper, and pop, alongside the three original base themes:
Built-in themes are switchable via the theme property. The original base themes keep their existing appearance:
| Theme | Identifier | Background | Palette |
|---|---|---|---|
| Default (Light) | default |
#FFF |
#5B6CFF #2DAF9E #F2B84B #EF6A6A #55A6D9 ... |
| Dark | dark |
#141414 |
#5B6CFF #2DAF9E #F2B84B #EF6A6A #55A6D9 ... |
| Academy | academy |
#FFF |
#4e79a7 #f28e2c #e15759 #76b7b2 #59a14f ... |
The website's 10 gallery styles are also built in:
| Theme | Identifier |
|---|---|
| GPT-Vis | gpt-vis |
| Midnight | midnight |
| Paper | paper |
| Product | product |
| Neon Circuit | neon-circuit |
| Terra Print | terra-print |
| Mono Signal | mono-signal |
| Candy Pop | candy-pop |
| Pop | pop |
| Bauhaus | bauhaus |
The branded gpt-vis preset is separate from the SDK's default.
const themedChart = new GPTVis({ container: '#chart', theme: 'pop' });Names work in the constructor, chart JSON, and Syntax (theme pop). Summary receives its theme through the constructor. The supported name type is BuiltinThemeName.
chart.render({
type: 'line',
data: [
{ time: '2020', value: 100 },
{ time: '2021', value: 120 },
],
theme: 'dark',
});Pass a ThemeSpec object to the constructor's theme option to share colors, typography, spacing, and mark styles across all 26 chart types, including graphs, Table, and Summary:
import { GPTVis, type ThemeSpec } from '@antv/gpt-vis';
const theme: ThemeSpec = {
id: 'my-report',
label: 'My report',
tokens: { colorDefault: '#7047eb', fontFamily: 'Arial, sans-serif', radius: 6 },
};
const chart = new GPTVis({ container: '#chart', theme });Precedence: single-chart config > custom ThemeSpec > GPT-Vis built-in theme. Within this hierarchy: built-in defaults < tokens < global style < charts[type].style < local style. Nested objects merge; arrays replace. A chart-level theme replaces the constructor's theme selection. Summary uses a constructor theme and T8 text, without a per-render style object.
Explore Theme Studio, read the theme documentation, or use the theme creation guide to generate a ThemeSpec from your brand references.
Unchanged Studio presets can be used by their built-in names. After customization, pass the full object as theme; a custom id is metadata and does not register a new name.
Use a chart’s style to override theme colors and mark styles, as shown in the object configuration and Syntax examples above.
26 chart types covering statistical analysis, relationship networks, and text visualization.
| Chart | Type Identifier |
|---|---|
| Line | line |
| Area | area |
| Column | column |
| Bar | bar |
| Pie | pie |
| Scatter | scatter |
| Radar | radar |
| Funnel | funnel |
| Waterfall | waterfall |
| Dual Axes | dual-axes |
| Histogram | histogram |
| Boxplot | boxplot |
| Violin | violin |
| Venn | venn |
| Sankey | sankey |
| Treemap | treemap |
| Word Cloud | word-cloud |
| Liquid | liquid |
| Chart | Type Identifier |
|---|---|
| Flow Diagram | flow-diagram |
| Network Graph | network-graph |
| Mindmap | mindmap |
| Indented Tree | indented-tree |
| Organization Chart | organization-chart |
| Fishbone Diagram | fishbone-diagram |
| Chart | Type Identifier |
|---|---|
| Table | table |
| Summary | summary |
Explore all examples → Examples Gallery
| Integration | Starting point |
|---|---|
| React & Vue | Framework lifecycle examples |
| Markdown | Render visualization blocks in model responses |
| shadcn/ui | Copy universal or chart-specific React components into your project |
| MCP | MCP Server Chart |
| Server rendering, Streamlit & Dify | Explore the ecosystem |
Vanilla JavaScript
import { GPTVis } from '@antv/gpt-vis';
const chart = new GPTVis({ container: '#chart', width: 600, height: 400 });
chart.render({
type: 'line',
data: [
{ time: '2020', value: 100 },
{ time: '2021', value: 120 },
{ time: '2022', value: 150 },
],
});
// Call chart.destroy() when the view unmounts.React
import { GPTVis } from '@antv/gpt-vis';
import { useEffect, useRef } from 'react';
function ChartComponent({ visSyntax }) {
const containerRef = useRef();
const chartRef = useRef();
useEffect(() => {
chartRef.current = new GPTVis({ container: containerRef.current, width: 600, height: 400 });
return () => chartRef.current?.destroy();
}, []);
useEffect(() => {
if (chartRef.current && visSyntax) {
chartRef.current.render(visSyntax);
}
}, [visSyntax]);
return <div ref={containerRef} />;
}Vue
<template>
<div ref="chartRef"></div>
</template>
<script setup>
import { ref, watch, onMounted, onUnmounted } from 'vue';
import { GPTVis } from '@antv/gpt-vis';
const props = defineProps(['visSyntax']);
const chartRef = ref(null);
let chart = null;
onMounted(() => {
chart = new GPTVis({ container: chartRef.value, width: 600, height: 400 });
if (props.visSyntax) chart.render(props.visSyntax);
});
watch(
() => props.visSyntax,
(syntax) => {
if (chart && syntax) chart.render(syntax);
},
);
onUnmounted(() => chart?.destroy());
</script>Markdown Renderer (marked)
GPT-Vis syntax naturally works with Markdown code fences and integrates with any Markdown renderer. The following example uses marked + marked-highlight — normal code blocks get syntax highlighting, while vis code blocks are rendered as interactive charts.
Install dependencies:
npm install @antv/gpt-vis marked marked-highlight highlight.jsComplete example:
import { Marked } from 'marked';
import { markedHighlight } from 'marked-highlight';
import hljs from 'highlight.js';
import { GPTVis } from '@antv/gpt-vis';
class GPTVisElement extends HTMLElement {
connectedCallback() {
const syntax = decodeURIComponent(this.dataset.syntax);
this._instance = new GPTVis({ container: this });
this._instance.render(syntax);
}
disconnectedCallback() {
this._instance?.destroy();
}
}
if (!customElements.get('gpt-vis')) {
customElements.define('gpt-vis', GPTVisElement);
}
const marked = new Marked(
markedHighlight({
langPrefix: 'hljs language-',
highlight(code, lang) {
if (lang?.startsWith('vis')) return code;
const language = hljs.getLanguage(lang) ? lang : 'plaintext';
return hljs.highlight(code, { language }).value;
},
}),
{
renderer: {
code({ text, lang }) {
if (lang?.startsWith('vis')) {
const syntax = encodeURIComponent(lang + '\n' + text);
return `<gpt-vis data-syntax="${syntax}" style="display:block;min-height:300px"></gpt-vis>`;
}
return false;
},
},
},
);
const markdown = `# My Report
\`\`\`vis bar
data
- category Python
value 28.1
- category JavaScript
value 18.5
- category Java
value 15.6
- category "C/C++"
value 12.3
title 2024 Programming Language Popularity
\`\`\`
`;
// Add <div id="content"></div> to your page.
document.getElementById('content').innerHTML = marked.parse(markdown);Copy GPT-Vis React components directly into your project via shadcn CLI — full source control, fully customizable.
The universal GPTVis component accepts vis syntax strings or config objects for all 26 chart types:
npx shadcn@latest add @gpt-vis/gpt-visimport { GPTVis } from '@/components/ui/gpt-vis';
<GPTVis
content={`vis line
data
- time 2020
value 100
- time 2021
value 120
- time 2022
value 150
title Sales Trend`}
theme="academy"
/>;Each chart type has its own component with a typed config prop — JSON only, chart-specific TypeScript validation:
npx shadcn@latest add @gpt-vis/lineimport { Line } from '@/components/ui/line';
<Line
config={{
data: [
{ time: '2020', value: 100 },
{ time: '2021', value: 120 },
{ time: '2022', value: 150 },
],
title: 'Sales Trend',
axisXTitle: 'Year',
}}
height={400}
/>;All 26 chart types are available. Install any by name:
npx shadcn@latest add @gpt-vis/pie
npx shadcn@latest add @gpt-vis/bar
npx shadcn@latest add @gpt-vis/mindmap
# ...and moreEach typed component automatically bundles the base GPTVis component as a dependency. Props like width, height, theme, wrapper, locale, className, and containerStyle are the same across all components.
GPT-Vis provides a complete AI integration solution:
-
MCP Server — Enable AI models to directly invoke visualization capabilities via Model Context Protocol
-
Chart Skill — Help AI assistants choose charts, generate JSON, Syntax or integration code, and create reusable themes with the bundled Theme Creator reference
-
Server rendering and community integrations — Explore server-side chart rendering, Streamlit, and Dify integrations
AI-Generated Code Policy: This project only merges AI-generated code.
- Submit an Issue describing the problem or feature request
- Tag @copilot to generate the implementation
- Submit a PR with AI-generated code