算法艺术创作
algorithmic-art
通过代码和可调参数创作生成艺术与交互式视觉效果。
antv-gpt-vis【设计与创意】Recommend and generate appropriate data visualization charts using the GPT-Vis library. Supports two output modes — (1) Syntax mode, which generates Syntax or JSON configurations, and (2) Code mode, which generates complete runnable code. Supports 26 chart types.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
GPT-Vis is an AI-native visualization library designed for the LLM era. It uses a framework-agnostic architecture, supports 26 chart types, and enables LLMs to easily generate high-quality visualizations through a simple, natural syntax.
| type value | Use case |
|---|---|
| line | Time series trends |
| area | Time series trends + totals |
| column | Categorical data comparison |
| bar | Categorical comparison (long labels) |
| pie | Part-to-whole proportions |
| scatter | Relationship between two variables |
| dual-axes | Comparison of data at different scales |
| histogram | Frequency distribution of continuous values |
| boxplot | Data distribution and outliers |
| violin | Data distribution density |
| radar | Multi-dimensional comparison |
| funnel | Process conversion rates |
| waterfall | Cumulative increases and decreases |
| liquid | Percentage / progress |
| word-cloud | Word frequency display |
| venn | Set intersection/union relationships |
| treemap | Hierarchical data proportions |
| sankey | Flow and direction of quantities |
| flow-diagram | Process steps |
| mindmap | Hierarchical knowledge organization |
| indented-tree | Tree node hierarchy / directories |
| network-graph | Relationships between entities |
| organization-chart | Organizational hierarchy |
| fishbone-diagram | Root cause analysis |
| table | Tabular data display |
| summary | Content summary |
Used for LLM application integration scenarios. Generates chart configurations consumed by GPTVis.render(). Supports two formats:
Both formats are equivalent and can be passed directly to GPTVis.render().
Used when the user needs complete runnable code. Generates output including installation instructions and full code.
GPTVis is the unified entry class of the library, responsible for creating, rendering, and destroying charts.
new GPTVis(options: VisualizationOptions)
VisualizationOptions:
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
container | string | HTMLElement | Yes | — | CSS selector or DOM element |
width | number | No | — | Chart width (px) |
height | number | No | — | Chart height (px) |
theme | 'default' | 'light' | 'dark' | 'academy' | No | 'light' | Theme |
wrapper | boolean | No | false | Whether to show the outer UI container (tabs, download, copy) |
locale | string | No | 'zh-CN' | Language of the text inside the wrapper |
render(config: string | object): voidRenders a chart. Accepts two kinds of input:
vis [type], automatically parsed into a configuration objecttype fieldvis are rendered as the summary typeCalling render() multiple times automatically destroys the previous chart before rendering the new one.
destroy(): voidDestroys the current chart instance and releases resources.
Directly output a JSON object conforming to the chart's TypeScript type; GPTVis.render() can consume it directly.
{
"type": "column",
"data": [
{ "category": "Product A", "value": 30, "group": "Online" },
{ "category": "Product B", "value": 50, "group": "Online" }
],
"title": "Product Sales Comparison",
"axisXTitle": "Product",
"axisYTitle": "Sales (10k)",
"stack": true,
"theme": "academy",
"style": {
"palette": ["#5B8FF9", "#61DDAA"]
}
}
Markdown-like indentation syntax that supports streaming rendering. The first line must be vis [type].
Basic properties — key value, one per line:
title Annual Trend
theme dark
Object arrays — under data, each item starts with - , with sub-fields indented:
{ data: { time: string; value: number; }[]; }
Corresponds to:
data
- time 2020
value 100
- time 2021
value 120
Plain value arrays — each item starts with - :
{ data: number[] }
Corresponds to:
data
- 10
- 20
String values containing spaces — wrap in quotes (single or double); quotes can be omitted when there are no spaces:
categories
- "North America"
- 'Southeast Asia'
- Europe
Nested objects — the object name occupies its own line, with sub-properties indented:
{ style?: { backgroundColor?: string; palette?: string[] } }
Corresponds to:
style
backgroundColor #f0f2f5
palette
- #5B8FF9
- #61DDAA
Recursive trees — the children array is indented with - :
type TreeData = { name: string; children?: TreeData[] };
{ data: TreeData; }
Corresponds to:
data
name Root
children
- name Child A
children
- name Grandchild
- name Child B
vis column
data
- category Product A
value 30
group Online
- category Product B
value 50
group Online
title Product Sales Comparison
axisXTitle Product
axisYTitle Sales (10k)
stack true
theme academy
style
palette
- #5B8FF9
- #61DDAA
When the output is in Markdown format, use GPT-Vis as the language tag of the fenced code block, and write the complete Syntax format in the content area:
```GPT-Vis
vis line
data
- time 2020
value 100
```
Format:
```GPT-Vis
<complete Syntax content, first line: vis <chart-type>>
```
Syntax rules:
GPT-Visvis <chart-type> (see the full list in Supported Chart Types above)Note: In Markdown mode, the content area must include the first line
vis <type>, consistent with the plain Syntax mode format.
Generate complete runnable code based on the target framework.
NPM:
npm install @antv/gpt-vis
import { GPTVis } from '@antv/gpt-vis';
CDN:
<script src="https://unpkg.com/@antv/gpt-vis/dist/umd/index.min.js"></script>
After loading via CDN, access the main class through GPTVis.GPTVis.
<html>
<head>
<script src="https://unpkg.com/@antv/gpt-vis/dist/umd/index.min.js"></script>
</head>
<body>
<div id="container"></div>
<script>
const gptVis = new GPTVis.GPTVis({
container: '#container',
width: 600,
height: 400,
});
gptVis.render(`
vis line
data
- time 2020
value 100
- time 2021
value 120
title Annual Trend
`);
</script>
</body>
</html>
All charts include the following fields, which are omitted from the individual chart type definitions below. Each section heading is the type value (e.g. line, column), corresponding to the type column in the chart type table above.
{ type: string; title?: string; theme?: 'default' | 'light' | 'dark' | 'academy'; style?: { backgroundColor?: string; palette?: string[] } }
{ data: { time: string | number; value: number; group?: string }[]; axisXTitle?: string; axisYTitle?: string; stack?: boolean; style?: { lineWidth?: number } }
stack is only supported by area.
{ data: { category: string; value: number; group?: string }[]; axisXTitle?: string; axisYTitle?: string; stack?: boolean; group?: boolean }
Values must not be percentage numbers.
{ data: { category: string; value: number }[]; innerRadius?: number }
Set innerRadius to 0.6 to turn it into a donut chart.
{ data: { x: number; y: number; group?: string }[]; axisXTitle?: string; axisYTitle?: string }
{ categories: string[]; series: { type: 'line' | 'column'; data: number[]; axisYTitle?: string }[]; axisXTitle?: string; style?: { startAtZero?: boolean } }
{ data: number[]; binNumber?: number; axisXTitle?: string; axisYTitle?: string }
Multiple data points are required for the same category to show distribution.
{ data: { category: string; value: number; group?: string }[]; axisXTitle?: string; axisYTitle?: string; style?: { startAtZero?: boolean } }
{ data: { name: string; value: number; group?: string }[]; align?: boolean }
align: whether to align the scales of all dimensions. Defaults to false (each axis scales independently); when true, all axes share the same maximum value, suitable for comparing absolute values across multiple series.
{ data: { category: string; value: number; }[]; }
Values can be negative to indicate decrease. palette is a color array in the order [positive color, negative color, total color].
{ data: { category: string; value: number }[]; axisXTitle?: string; axisYTitle?: string; style?: { palette?: string[] } }
percent ranges from 0 to 1.
{ percent: number; shape?: 'rect' | 'circle' | 'pin' | 'triangle' }
{ data: { text: string; value: number; }[]; }
Intersections use commas to separate set identifiers: sets: "A,B". label is used to display the name of the corresponding set on the chart.
{ data: { sets: string | string[]; value: number; label?: string }[] }
type TreeNode = { name: string; value: number; children?: TreeNode[] };
{ data: TreeNode[] }
{ data: { source: string; target: string; value: number }[]; nodeAlign?: 'left' | 'center' | 'right' | 'justify' }
source/target reference node name values.
type GraphData = { nodes: { name: string }[]; edges: { source: string; target: string; name?: string }[] };
// flow-diagram
{ data: GraphData }
// network-graph
{ data: GraphData; layout?: 'force' | 'circular' | 'grid' | 'radial' | 'concentric' | 'dagre' }
type TreeData = { name: string; children?: TreeData[] };
// mindmap
{ data: TreeData; direction?: 'H' | 'LR' | 'RL' }
// indented-tree
{ data: TreeData; direction?: 'LR' | 'RL' | 'H' }
// organization-chart
type OrganizationChartData = {
name: string;
description?: string;
children?: OrganizationChartData[];
};
{ data: OrganizationChartData }
mindmap defaults to 'H'; indented-tree defaults to 'LR'.
type FishboneNode = { name: string; children?: FishboneNode[] };
{ data: FishboneNode; style?: { texture?: 'rough' | 'default' } }
texture: 'rough' produces a hand-drawn style.
{ data: Record<string, string | number>[]; }
summary is completely different from other chart types: it does not use Syntax/JSON configuration, but instead uses T8 syntax (Markdown + semantic annotations).
⚠️ Before generating a summary, you must: first read references/summary.md to get the T8 syntax rules, the complete entity type list, attribute field definitions, generation requirements, and examples, and only then generate the content. Skipping this step will cause syntax errors.
time/category and the other as group