AntV Infographic
Home
Learn
Reference
Examples
Icon
AI
Enterprise

目录

  • Overview
  • 语法结构
  • 语法规范
  • template
  • design
  • data
  • theme
  • 使用案例
  • 常规渲染
  • 流式渲染
  • 快速开始
    • 入门指南
    • 信息图语法
  • 核心概念
    • 设计
    • 模版
    • 数据
    • 主题
    • 资源
  • 自定义设计
    • 自定义结构
    • 自定义数据项
    • 自定义模版
    • 自定义主题
    • 自定义色板
    • 自定义字体
    • 自定义资源加载器
    • 自定义图案
  • 信息图理论
    • 信息图分类
    • 核心理论
    • 信息图构成要素
    • 信息图设计
  • 参与贡献
文档
快速开始

信息图语法

信息图语法是一套类 Mermaid 的语法,用于描述模板、设计、数据与主题。它适合 AI 流式输出,也适合人工编写,并通过 Infographic 的 render(syntax) 直接渲染。

Syntax input

信息图语法受到 AntV G2、G6 的图形语法启发,并结合信息图理论和设计原则。它的目标是让你专注于内容和视觉,不必陷入底层细节。

我们将信息图表示为:信息图 = 信息结构 + 图形表意

信息结构对应数据的抽象,决定内容与层级;图形表意对应设计的抽象,决定视觉呈现与风格。

语法结构

入口使用 infographic [template-name],之后通过块(block)描述 template、design、data、theme。

PLAIN
infographic list-row-horizontal-icon-arrow data title 客户增长引擎 desc 多渠道触达与复购提升 items - label 线索获取 value 18.6 desc 渠道投放与内容获客 icon company-021_v1_lineal - label 转化提效 value 12.4 desc 线索评分与自动跟进 icon antenna-bars-5_v1_lineal

语法规范

  • 入口使用 infographic [template-name]
  • 键值对使用空格分隔,缩进使用两个空格
  • structure [name]、item [name]、title [name] 省略 type
  • 对象数组使用 - 换行(如 data.items),简单数组使用行内写法(如 palette)
  • 容器相关配置写在 new Infographic({ ... })(如 width、height、padding、editable),语法中只写 template/design/theme

template

模板在入口处直接指定。

PLAIN
infographic <template-name>

design

设计块用于选择结构、卡片与标题等模块。

PLAIN
design structure <structure-name> gap 12 item <item-name> showIcon true title default align center

data

数据块是信息结构的核心,通常包含标题、描述与列表项,支持嵌套层级。

PLAIN
data title 组织结构 desc 产品增长团队 items - label 产品增长 icon company-021_v1_lineal children - label 增长策略 desc 指标与实验设计 icon antenna-bars-5_v1_lineal - label 用户运营 desc 生命周期运营 icon activities-037_v1_lineal

theme

主题块用于切换主题与调整色板、字体与风格化能力。

使用预设主题:

PLAIN
theme <theme-name>

搭配自定义主题:

PLAIN
theme colorBg #0b1220 colorPrimary #ff5a5f palette #ff5a5f #1fb6ff #13ce66 stylize rough roughness 0.3

使用案例

常规渲染

直接一次性渲染完整语法。

TS
import {Infographic} from '@antv/infographic'; const instance = new Infographic({ container: '#container', width: 900, height: 540, padding: 24, }); const syntaxText = ` infographic list-row-horizontal-icon-arrow data title 客户增长引擎 desc 多渠道触达与复购提升 items - label 线索获取 value 18.6 desc 渠道投放与内容获客 icon company-021_v1_lineal - label 转化提效 value 12.4 desc 线索评分与自动跟进 icon antenna-bars-5_v1_lineal `; instance.render(syntaxText);

流式渲染

模型输出片段后持续调用 render 更新(伪代码)。每次收到新的语法片段,就追加到缓冲区并重新渲染,让画面与输出同步更新。

TS
import {Infographic} from '@antv/infographic'; const instance = new Infographic({ container: '#container', width: 900, height: 540, padding: 24, }); const chunks = [ 'infographic list-row-horizontal-icon-arrow\n', 'data\n title 客户增长引擎\n desc 多渠道触达与复购提升\n', ' items\n - label 线索获取\n value 18.6\n', ' desc 渠道投放与内容获客\n icon company-021_v1_lineal\n', ]; let buffer = ''; for (const chunk of chunks) { buffer += chunk; instance.render(buffer); }
Previous入门指南
Next核心概念

AntV Infographic
Copyright © Ant Group Co.
Docs
Quick Start
Core Concepts
Custom Design
Infographic Theory
API Reference
JSX
API
Design Assets
More
More Examples
AI Generated Infographics
GitHub
Contribute
Friendly Links
AntV
G2
G6
L7
PLAIN
infographic list-row-horizontal-icon-arrow
data
title 客户增长引擎
desc 多渠道触达与复购提升
items
- label 线索获取
value 18.6
desc 渠道投放与内容获客
icon company-021_v1_lineal
- label 转化提效
value 12.4
desc 线索评分与自动跟进
icon antenna-bars-5_v1_lineal
PLAIN
infographic <template-name>
PLAIN
design
structure <structure-name>
gap 12
item <item-name>
showIcon true
title default
align center
PLAIN
data
title 组织结构
desc 产品增长团队
items
- label 产品增长
icon company-021_v1_lineal
children
- label 增长策略
desc 指标与实验设计
icon antenna-bars-5_v1_lineal
- label 用户运营
desc 生命周期运营
icon activities-037_v1_lineal
PLAIN
theme <theme-name>
PLAIN
theme
colorBg #0b1220
colorPrimary #ff5a5f
palette #ff5a5f #1fb6ff #13ce66
stylize rough
roughness 0.3
TS
import {Infographic} from '@antv/infographic';

const instance = new Infographic({
container: '#container',
width: 900,
height: 540,
padding: 24,
});

const syntaxText = `
infographic list-row-horizontal-icon-arrow
data
title 客户增长引擎
desc 多渠道触达与复购提升
items
- label 线索获取
value 18.6
desc 渠道投放与内容获客
icon company-021_v1_lineal
- label 转化提效
value 12.4
desc 线索评分与自动跟进
icon antenna-bars-5_v1_lineal
`;

instance.render(syntaxText);
TS
import {Infographic} from '@antv/infographic';

const instance = new Infographic({
container: '#container',
width: 900,
height: 540,
padding: 24,
});

const chunks = [
'infographic list-row-horizontal-icon-arrow\n',
'data\n title 客户增长引擎\n desc 多渠道触达与复购提升\n',
' items\n - label 线索获取\n value 18.6\n',
' desc 渠道投放与内容获客\n icon company-021_v1_lineal\n',
];

let buffer = '';
for (const chunk of chunks) {
buffer += chunk;
instance.render(buffer);
}