/antv-g2-chart
Use this skill whenever the user wants to create, customize, or troubleshoot G2 v5 chart visualizations. Triggers include: any mention of 'G2', 'antv g2', '@antv/g2', 'G2 chart', 'G2 可视化', or requests to produce charts like bar charts (柱状图), line charts (折线图), pie charts (饼图),
$ npx -y skills add antvis/chart-visualization-skills --skill antv-g2-chart --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/antv-g2-chart
Context preview
The summary Claude sees to decide when to auto-load this skill.
Use this skill whenever the user wants to create, customize, or troubleshoot G2 v5 chart visualizations. Triggers include: any mention of 'G2', 'antv g2', '@antv/g2', 'G2 chart', 'G2 可视化', or requests to produce charts like bar charts (柱状图), line charts (折线图), pie charts (饼图),
SKILL.md
antv-g2-chart.SKILL.mdname: antv-g2-chart
description: "Use this skill whenever the user wants to create, customize, or troubleshoot G2 v5 chart visualizations. Triggers include: any mention of 'G2', 'antv g2', '@antv/g2', 'G2 chart', 'G2 可视化', or requests to produce charts like bar charts (柱状图), line charts (折线图), pie charts (饼图), scatter plots (散点图), area charts (面积图), heatmap (热力图), radar charts (雷达图), treemap (矩形树图), funnel charts (漏斗图), sankey diagrams (桑基图), gauge (仪表盘), wordcloud (词云), boxplot (箱线图), as well as G2-specific topics like encode channels, scale config, coordinate systems, transforms, interactions, themes, labels, and animations. Also use when debugging G2 rendering errors, V4→V5 migration issues, or chart type selection. Do NOT use for G6 graph/network visualization, X6 editor diagrams, or S2 pivot tables."
tools:
- curl
G2 v5 Chart Visualization
Overview
G2 v5 is AntV's grammar-of-graphics charting library. It uses **Spec Mode** — a declarative, JSON-like configuration style where `chart.options()` defines the entire visualization in one call.
import { Chart } from '@antv/g2';
const chart = new Chart({ container: 'container', autoFit: true });
chart.options({
type: 'interval',
data: [{ genre: 'Sports', sold: 275 }],
encode: { x: 'genre', y: 'sold' },
});
chart.render();CDN Usage
<script src="https://unpkg.com/@antv/g2@5/dist/g2.min.js"></script>
<script>
const chart = new G2.Chart({ container: 'container', autoFit: true });
chart.options({
type: 'interval',
data: [{ genre: 'Sports', sold: 275 }],
encode: { x: 'genre', y: 'sold' },
});
chart.render();
</script>Content Retrieval Service
When using AntV G2 for data visualization, if you need to understand the concepts, usage, API, examples, and other aspects of G2 v5, you can use the provided context retrieval service. When using the skill, content is retrieved via an antv HTTP API server using GET requests.
- Host: `https://sive.antv.antgroup.com`
- Endpoint: `/api/v1/context/retrieve`
- Method: `GET`
- Parameters: `query`, `library`, `topK`, `content`, `maxTokens`, `progressiveLevel`
Retrieve skills by query (hybrid search = FTS + vector + RRF fusion). Constraints docs are indexed as regular skill documents and will appear in search results naturally.
| Parameter | Type | Required | Description | |---|---|---|---| | `query` | string | ✅ | Search keywords, e.g. `bar chart interval` | | `library` | string | ✅ | Library name: `g2`, `g6`, `x6` | | `topK` | number | | Number of results to return (default: 5) | | `content` | boolean | | Return full reference doc markdown (default: true) | | `maxTokens` | number | | Max tokens per result (default: unlimited) | | `progressiveLevel` | number | | Progressive disclosure level: `0`=full, `1`=summary+code, `2`=summary-only |
curl "https://sive.antv.antgroup.com/api/v1/context/retrieve?query=bar+chart+stacked&library=g2"
Critical Rules
MUST: Use V5 Spec Mode ONLY
// ❌ WRONG — V4 chain API (deprecated, will not render)
chart.interval()
.data([...])
.encode('x', 'genre')
.encode('y', 'sold')
.style({ radius: 4 });
// ✅ CORRECT — V5 Spec Mode
chart.options({
type: 'interval',
data: [...],
encode: { x: 'genre', y: 'sold' },
style: { radius: 4 },
});MUST: `chart.options()` called exactly ONCE
Multiple calls **overwrite** each other. For multi-mark overlays, use `type: 'view'` + `children`:
// ❌ WRONG — second options() overwrites the first
chart.options({ type: 'line', data, encode: { x: 'date', y: 'value' } });
chart.options({ type: 'point', data, encode: { x: 'date', y: 'value' } });
// ✅ CORRECT — children array for multi-mark
chart.options({
type: 'view',
data,
children: [
{ type: 'line', encode: { x: 'date', y: 'value' } },
{ type: 'point', encode: { x: 'date', y: 'value' } },
],
});MUST: `container` is mandatory, `chart.render()` at the end
// ❌ WRONG — no container, no render
const chart = new Chart();
chart.options({ type: 'interval', data });
// ✅ CORRECT
const chart = new Chart({ container: 'container', autoFit: true });
chart.options({ type: 'interval', data, encode: { x: 'genre', y: 'sold' } });
chart.render();MUST: Correct mark types only
| ❌ Hallucinated (from ECharts/Vega) | ✅ G2 correct replacement | |---|---| | `type: 'ruleX'` | `type: 'lineX'` | | `type: 'ruleY'` | `type: 'lineY'` | | `type: 'regionX'` | `type: 'rangeX'` | | `type: 'regionY'` | `type: 'rangeY'` | | `type: 'venn'` | `type: 'path'` + transform |
**Legal G2 marks**: `interval`, `line`, `area`, `point`, `rect`, `cell`, `text`, `image`, `path`, `polygon`, `shape`, `link`, `connector`, `vector`, `lineX`, `lineY`, `rangeX`, `rangeY`, `range`, `box`, `boxplot`, `density`, `heatmap`, `beeswarm`, `treemap`, `pack`, `partition`, `tree`, `sankey`, `chord`, `wordCloud`, `gauge`, `liquid`. `sunburst` requires `@antv/g2-extension-plot`.
MUST: `encode` is an object, `transform` is an array
// ❌ WRONG
.encode('x', 'genre')
.transform: { type: 'stackY' }
// ✅ CORRECT
encode: { x: 'genre', y: 'sold' }
transform: [{ type: 'stackY' }]MUST: `labels` is plural, range encoding uses y/y1
// ❌ WRONG
label: { text: 'sold' }
encode: { y: ['start', 'end'] }
// ✅ CORRECT
labels: [{ text: 'sold' }]
encode: { y: 'start', y1: 'end' }MUST: No d3 in user code
// ❌ WRONG — d3 is not exposed in user scope
const total = d3.sum(data, d => d.value);
// ✅ CORRECT — use native JS or G2 built-in transforms
const total = data.reduce((sum, d) => sum + d.value, 0);
MUST: No white/near-white fill, no `padding` as array
// ❌ WRONG
style: { fill: '#fff' } // invisible on white background
padding: [40, 30, 40, 50] // invalid in G2 v5
// ✅ CORRECT
encode: { color: 'group' } // let G2 assign colors
padding: 40 // single numbRead more
name: antv-g2-chart description: "Use this skill whenever the user wants to create, customize, or troubleshoot G2 v5 chart visualizations. Triggers include: any mention of 'G2', 'antv g2', '@antv/g2', 'G2 chart', 'G2 可视化', or requests to produce charts like bar charts (柱状图), line charts (折线图), pie charts (饼图), scatter plots (散点图), area charts (面积图), heatmap (热力图), radar charts (雷达图), treemap (矩形树图), funnel charts (漏斗图), sankey diagrams (桑基图), gauge (仪表盘), wordcloud (词云), boxplot (箱线图), as well as G2-specific topics like encode channels, scale config, coordinate systems, transforms, interactions, themes, labels, and animations. Also use when debugging G2 rendering errors, V4→V5 migration issues, or chart type selection. Do NOT use for G6 graph/network visualization, X6 editor diagrams, or S2 pivot tables." tools: - curl
G2 v5 Chart Visualization
Overview
G2 v5 is AntV's grammar-of-graphics charting library. It uses **Spec Mode** — a declarative, JSON-like configuration style where `chart.options()` defines the entire visualization in one call.
import { Chart } from '@antv/g2';
const chart = new Chart({ container: 'container', autoFit: true });
chart.options({
type: 'interval',
data: [{ genre: 'Sports', sold: 275 }],
encode: { x: 'genre', y: 'sold' },
});
chart.render();CDN Usage
<script src="https://unpkg.com/@antv/g2@5/dist/g2.min.js"></script>
<script>
const chart = new G2.Chart({ container: 'container', autoFit: true });
chart.options({
type: 'interval',
data: [{ genre: 'Sports', sold: 275 }],
encode: { x: 'genre', y: 'sold' },
});
chart.render();
</script>Content Retrieval Service
When using AntV G2 for data visualization, if you need to understand the concepts, usage, API, examples, and other aspects of G2 v5, you can use the provided context retrieval service. When using the skill, content is retrieved via an antv HTTP API server using GET requests.
- Host: `https://sive.antv.antgroup.com`
- Endpoint: `/api/v1/context/retrieve`
- Method: `GET`
- Parameters: `query`, `library`, `topK`, `content`, `maxTokens`, `progressiveLevel`
Retrieve skills by query (hybrid search = FTS + vector + RRF fusion). Constraints docs are indexed as regular skill documents and will appear in search results naturally.
| Parameter | Type | Required | Description | |---|---|---|---| | `query` | string | ✅ | Search keywords, e.g. `bar chart interval` | | `library` | string | ✅ | Library name: `g2`, `g6`, `x6` | | `topK` | number | | Number of results to return (default: 5) | | `content` | boolean | | Return full reference doc markdown (default: true) | | `maxTokens` | number | | Max tokens per result (default: unlimited) | | `progressiveLevel` | number | | Progressive disclosure level: `0`=full, `1`=summary+code, `2`=summary-only |
curl "https://sive.antv.antgroup.com/api/v1/context/retrieve?query=bar+chart+stacked&library=g2"
Critical Rules
MUST: Use V5 Spec Mode ONLY
// ❌ WRONG — V4 chain API (deprecated, will not render)
chart.interval()
.data([...])
.encode('x', 'genre')
.encode('y', 'sold')
.style({ radius: 4 });
// ✅ CORRECT — V5 Spec Mode
chart.options({
type: 'interval',
data: [...],
encode: { x: 'genre', y: 'sold' },
style: { radius: 4 },
});MUST: `chart.options()` called exactly ONCE
Multiple calls **overwrite** each other. For multi-mark overlays, use `type: 'view'` + `children`:
// ❌ WRONG — second options() overwrites the first
chart.options({ type: 'line', data, encode: { x: 'date', y: 'value' } });
chart.options({ type: 'point', data, encode: { x: 'date', y: 'value' } });
// ✅ CORRECT — children array for multi-mark
chart.options({
type: 'view',
data,
children: [
{ type: 'line', encode: { x: 'date', y: 'value' } },
{ type: 'point', encode: { x: 'date', y: 'value' } },
],
});MUST: `container` is mandatory, `chart.render()` at the end
// ❌ WRONG — no container, no render
const chart = new Chart();
chart.options({ type: 'interval', data });
// ✅ CORRECT
const chart = new Chart({ container: 'container', autoFit: true });
chart.options({ type: 'interval', data, encode: { x: 'genre', y: 'sold' } });
chart.render();MUST: Correct mark types only
| ❌ Hallucinated (from ECharts/Vega) | ✅ G2 correct replacement | |---|---| | `type: 'ruleX'` | `type: 'lineX'` | | `type: 'ruleY'` | `type: 'lineY'` | | `type: 'regionX'` | `type: 'rangeX'` | | `type: 'regionY'` | `type: 'rangeY'` | | `type: 'venn'` | `type: 'path'` + transform |
**Legal G2 marks**: `interval`, `line`, `area`, `point`, `rect`, `cell`, `text`, `image`, `path`, `polygon`, `shape`, `link`, `connector`, `vector`, `lineX`, `lineY`, `rangeX`, `rangeY`, `range`, `box`, `boxplot`, `density`, `heatmap`, `beeswarm`, `treemap`, `pack`, `partition`, `tree`, `sankey`, `chord`, `wordCloud`, `gauge`, `liquid`. `sunburst` requires `@antv/g2-extension-plot`.
MUST: `encode` is an object, `transform` is an array
// ❌ WRONG
.encode('x', 'genre')
.transform: { type: 'stackY' }
// ✅ CORRECT
encode: { x: 'genre', y: 'sold' }
transform: [{ type: 'stackY' }]MUST: `labels` is plural, range encoding uses y/y1
// ❌ WRONG
label: { text: 'sold' }
encode: { y: ['start', 'end'] }
// ✅ CORRECT
labels: [{ text: 'sold' }]
encode: { y: 'start', y1: 'end' }MUST: No d3 in user code
// ❌ WRONG — d3 is not exposed in user scope const total = d3.sum(data, d => d.value); // ✅ CORRECT — use native JS or G2 built-in transforms const total = data.reduce((sum, d) => sum + d.value, 0);
MUST: No white/near-white fill, no `padding` as array
// ❌ WRONG
style: { fill: '#fff' } // invisible on white background
padding: [40, 30, 40, 50] // invalid in G2 v5
// ✅ CORRECT
encode: { color: 'group' } // let G2 assign colors
padding: 40 // single numbTurning data into a visual language for better thinking. AntV , initiated by Ant Group and open-sourced starting in 2017, reimagines data visualization by embedding the theory of graphical grammar into the JavaScript language.
Repo: antvis/chart-visualization-skills
Other skills on chart-visualization-skills.
- /antv-g6-graph
Use this skill whenever the user wants to create, customize, or troubleshoot G6 v5 graph/network visualizations. Triggers include: any mention of 'G6', 'antv g6', '@antv/g6', 'G6 graph', 'G6 图', '网络图', '关系图', '拓扑图', '树形图', '流程图', '思维导图', '鱼骨图', '力导向图', 'force graph', 'network
Open skill - /antv-x6-editor
Use this skill whenever the user wants to create, customize, or troubleshoot X6 v3 graph editor diagrams. Triggers include: any mention of 'X6', 'antv x6', '@antv/x6', 'X6 editor', 'X6 图编辑', '流程图', 'DAG', 'ER图', '实体关系图', '血缘图', '组织架构图', 'UML类图', 'flowchart', 'DAG diagram', 'ER
Open skill - /chart-visualization
将数据可视化为图表。当用户需要生成柱状图、折线图、饼图、散点图、雷达图、桑基图、思维导图、流程图等图表时调用此技能,通过 curl 工具调用 AntV API 生成图表图片
Open skill - /gpt-vis
推荐并生成合适的数据可视化图表,使用 GPT-Vis 库。支持两种输出模式:(1)语法模式——生成 Syntax 或 JSON 配置;(2)代码模式——生成完整的运行代码。支持 26 种图表类型。
Open skill - /icon-retrieval
Search icons through HTTP API and retrieve SVG strings with curl.
Open skill - /infographic-creator
Create beautiful infographics based on given text content. Use when users request to create infographics.
Open skill

