下载地址
https://www.zhengdianxue.com/wp-content/uploads/skills/org-1wxsh60v--infographic-skill.zip将提示词发送给你的 AI 安装该 skills
请根据 https://skillhub.cn/install/skillhub.md,安装 @org-1wxsh60v/infographic-skill。阅读全文 (展开查看完整说明)
概述
Infographic Skill — 信息图生成
宪法:[CONSTITUTION.md](./CONSTITUTION.md) | Phase 1–6:Gantt · ERD · Timeline · Venn · Sankey · Radar · Treemap · Wardley · Ishikawa · WordCloud · Bar · Line · Pie · Scatter · Heatmap · Funnel · Dashboard
将结构化输入渲染为信息图 HTML。Token 驱动的主题系统,图表代码零硬编码颜色。
一、图表类型匹配规则
按优先级匹配,命中即停:
| 优先级 | 条件 | 图表类型 | 模板 |
|---|---|---|---|
| 1 | type: gantt 或含关键词「甘特/时间线/进度/roadmap/gantt」 | gantt | [references/gantt.md](references/gantt.md) |
| 2 | type: erd 或含关键词「ER/实体/数据模型/表关系/database」 | erd | [references/erd.md](references/erd.md) |
| 3 | type: timeline 或含关键词「时间轴/里程碑/发展历程/历史/timeline」 | timeline | [references/timeline.md](references/timeline.md) |
| 4 | type: venn 或含关键词「韦恩/交集/重叠/集合/venn」 | venn | [references/venn.md](references/venn.md) |
| 5 | type: sankey 或含关键词「桑基/流向/流量/能源/sankey」 | sankey | [references/sankey.md](references/sankey.md) |
| 6 | type: radar 或含关键词「雷达/多维/蜘蛛网/能力对比/radar」 | radar | [references/radar.md](references/radar.md) |
| 7 | type: treemap 或含关键词「树图/矩形树/层级/面积/treemap」 | treemap | [references/treemap.md](references/treemap.md) |
| 8 | type: wardley 或含关键词「沃德利/战略地图/价值链/演进/wardley」 | wardley | [references/wardley.md](references/wardley.md) |
| 9 | type: ishikawa 或含关键词「鱼骨/因果/根本原因/石川/ishikawa/fishbone」 | ishikawa | [references/ishikawa.md](references/ishikawa.md) |
| 10 | type: wordcloud 或含关键词「词云/标签云/词频/文字云/wordcloud」 | wordcloud | [references/wordcloud.md](references/wordcloud.md) |
| 11 | type: bar 或含关键词「柱状/柱形/bar chart」 | bar | [references/bar.md](references/bar.md) |
| 12 | type: line 或含关键词「折线/趋势/line chart」 | line | [references/line.md](references/line.md) |
| 13 | type: pie 或含关键词「饼图/环形/donut/pie chart」 | pie | [references/pie.md](references/pie.md) |
| 14 | type: scatter 或含关键词「散点/气泡/相关性/scatter chart」 | scatter | [references/scatter.md](references/scatter.md) |
| 15 | type: heatmap 或含关键词「热力/矩阵/heat map」 | heatmap | [references/heatmap.md](references/heatmap.md) |
| 16 | type: funnel 或含关键词「漏斗/转化/funnel chart」 | funnel | [references/funnel.md](references/funnel.md) |
| 17 | type: dashboard 或含关键词「仪表盘/看板/组合/dashboard」 | dashboard | [schemas/dashboard.md](schemas/dashboard.md) |
| 18 | 未匹配 | — | 要求用户明确指定图表类型 |
关键词权重
- 精确匹配优先:
type字段值直接决定图表类型 - 上下文推断:无
type字段时,从title/自然语言描述中检测关键词 - 歧义消解:当多个关键词同时命中时,按表格优先级(序号小的优先)
- 模糊匹配示例:「画个甘特图」→ gantt、「ER 图」→ erd、「时间轴梳理」→ timeline、「韦恩图」→ venn
二、工作流
用户输入 → 类型匹配 → 加载 schema → 校验输入 → 加载 reference
→ 加载主题 → Token 注入 → 渲染 HTML → 输出Step 1 — 解析输入
读取用户输入 → 提取 type/title/theme 等字段 → 匹配图表类型Step 2 — 校验
对照对应 schemas/<type>.md 的字段定义校验。必填字段缺失时返回具体错误信息。
Step 3 — 加载主题
input.theme → themes/<name>.json
(默认 "default" → themes/default.json)Step 4 — Token 注入 + 渲染
Step | 操作—|—4a | 从主题 JSON 提取所有 token 值4b | 将 token 值注入 HTML wrapper 的 CSS 变量4c | 将 token 值注入 Mermaid %%{init}%% 的 themeVariables(或 SVG 属性)4d | 将 input 数据按 reference 模板变量规则转换为渲染代码4e | 组装完整 HTML:wrapper + 标题区 + 渲染代码 + 脚注
Step 5 — 输出
输出一个自包含 HTML 文件,嵌入:
<div class="infographic-chart">包装器(含 CSS 变量)- Phase 1 (Mermaid 族):Mermaid JS CDN 引用 +
mermaid.initialize() - Phase 2 (d3/echarts 族):d3.v7 / d3-sankey / ECharts 5.5 CDN 引用 + 对应渲染脚本
- Venn 图使用 inline SVG,无需 JS 依赖
三、主题系统
Token 分类
类别 | Token 数量 | 用途—|—|— color | 13 | primary, secondary, accent, background, surface, text, border, 3 state colors, palette[8] typography | 11 | font_family × 3 (heading/mono/num), sizes × 5, weights × 2, line_height, letter_spacing geometry | 6 | border_radius, stroke_width, node_radius, gap, padding, shadow| overrides | 按图表类型 | gantt, sankey, venn, radar, treemap 等专属覆盖
完整 schema 见 [tokens/schema.json](tokens/schema.json)
主题继承
新建主题只需覆盖差异字段:
{
"name": "Dark",
"extends": "default",
"color": {
"primary": "#6C9BD2",
"background": "#1A1A2E",
"text_primary": "#EAEAEA"
}
}继承链:自定义 → default → tokens/schema.json
零硬编码原则
图表 reference 中所有颜色/字体/尺寸均通过 CSS 变量引用:
/* ✅ 正确 — token 引用 */
fill: var(--color-primary);
font-size: var(--size-label)px;
/* ❌ 禁止 — 硬编码 */
fill: #4A90D9;
font-size: 12px;四、图表速查
| 图表 | 渲染引擎 | Schema | Reference | Token Overrides | |
|---|---|---|---|---|---|
| Gantt | Mermaid gantt | [gantt](schemas/gantt.md) | [gantt](references/gantt.md) | bar_height, today_color, milestone_shape | |
| ERD | Mermaid erDiagram | [erd](schemas/erd.md) | [erd](references/erd.md) | — | |
| Timeline | Mermaid timeline | [timeline](schemas/timeline.md) | [timeline](references/timeline.md) | — | |
| Venn | SVG inline | [venn](schemas/venn.md) | [venn](references/venn.md) | border_style, label_position | |
| Sankey | d3-sankey | [sankey](schemas/sankey.md) | [sankey](references/sankey.md) | link_opacity, node_width, node_padding | |
| Radar | ECharts Radar | [radar](schemas/radar.md) | [radar](references/radar.md) | shape, split_area_opacity, axis_label_gap, symbol_size | |
| Treemap | d3-hierarchy | [treemap](schemas/treemap.md) | [treemap](references/treemap.md) | padding_inner, padding_top, label_min_width, border_width | |
| Wardley | SVG inline | [wardley](schemas/wardley.md) | [wardley](references/wardley.md) | axis_color, component_radius | |
| Ishikawa | SVG inline | [ishikawa](schemas/ishikawa.md) | [ishikawa](references/ishikawa.md) | spine_width, bone_color | |
| WordCloud | SVG inline + JS | [wordcloud](schemas/wordcloud.md) | [wordcloud](references/wordcloud.md) | min_font, max_font, rotation | |
| Bar | ECharts Bar | [bar](schemas/bar.md) | [bar](references/bar.md) | bar_gap, bar_width, label_position | |
| Line | ECharts Line | [line](schemas/line.md) | [line](references/line.md) | line_width, symbol_size, area_opacity | |
| Pie | ECharts Pie | [pie](schemas/pie.md) | [pie](references/pie.md) | inner_radius, outer_radius, rose_type | |
| Scatter | ECharts Scatter | [scatter](schemas/scatter.md) | [scatter](references/scatter.md) | symbol_shape, symbol_size, opacity | |
| Heatmap | ECharts Heatmap | [heatmap](schemas/heatmap.md) | [heatmap](references/heatmap.md) | cell_gap, label_font_size, color_range | |
| Funnel | ECharts Funnel | [funnel](schemas/funnel.md) | [funnel](references/funnel.md) | gap_size, label_position, sort | |
| Dashboard | 组合布局 | [dashboard](schemas/dashboard.md) | [two-col](layouts/two-col.md) [three-col](layouts/three-col.md) [grid](layouts/grid.md) | — |
五、Mermaid 公共配置
所有 Mermaid 图表共享以下初始化配置:
mermaid.initialize({
startOnLoad: true,
theme: 'base',
securityLevel: 'sandbox',
gantt: { barHeight: {{bar_height}}, fontSize: {{size_axis}},
useWidth: {{width}} },
er: { fontSize: {{size_label}} },
fontFamily: '{{font_family}}'
});六、输入格式规范
最小输入示例(Gantt)
type: gantt
title: 项目计划
sections:
- name: 阶段一
tasks:
- { name: 任务A, start: "2026-01-01", end: "2026-01-10", status: done }
- { name: 任务B, start: "2026-01-11", duration: "7d" }通用字段
所有图表类型共享(详见 [schemas/input-common.md](schemas/input-common.md)):
type: string # 必填,图表类型
title: string # 必填,标题
subtitle: string # 可选,副标题
theme: string # 可选,主题名(默认 "default")
width: integer # 可选,画布宽
height: integer # 可选,画布高
ratio: string # 可选,宽高比七、错误处理
| 错误类型 | 行为 |
|---|---|
| 无法识别图表类型 | 列出支持的 17 种类型,要求明确指定 |
| 必填字段缺失 | 指出缺失字段 + schema 位置 |
| 字段类型错误 | 指出字段名 + 期望类型 + 实际类型 |
| 主题文件不存在 | 回退 default 主题 + 警告 |
| Token 缺失 | 使用 schema.json 默认值 + 警告 |
八、目录结构
infographic/
├── CONSTITUTION.md # 设计宪法
├── SKILL.md # 本文件(入口路由)
├── DESIGN_RESEARCH.md # 设计研究
├── references/ # 图表渲染模板
│ ├── _shared/ # 跨图表共享组件
│ │ ├── README.md
│ │ ├── color-scale.md # 颜色比例尺
│ │ ├── legend.md # 图例(active)
│ │ └── tooltip.md # 悬浮提示
│ ├── gantt.md # Phase 1 — Mermaid
│ ├── erd.md
│ ├── timeline.md
│ ├── venn.md # Phase 1 — SVG inline
│ ├── sankey.md # Phase 2 — d3-sankey
│ ├── radar.md # Phase 2 — ECharts
│ ├── treemap.md # Phase 2 — d3-hierarchy
│ ├── wardley.md # Phase 3 — SVG inline
│ ├── ishikawa.md # Phase 3 — SVG inline
│ └── wordcloud.md # Phase 3 — SVG inline + JS
│ ├── bar.md # Phase 6 — ECharts
│ ├── line.md # Phase 6 — ECharts
│ ├── pie.md # Phase 6 — ECharts
│ ├── scatter.md # Phase 6 — ECharts
│ ├── heatmap.md # Phase 6 — ECharts
│ └── funnel.md # Phase 6 — ECharts
├── themes/ # 8 套主题 (Phase 7)
│ ├── default.json # 基础主题
│ ├── dark.json / corporate.json / academic.json
│ ├── minimal.json / warm.json / tech.json / nature.json
│ └── selection-index.json
├── tokens/ # Token 声明
│ ├── schema.json
│ └── validate.py
├── schemas/ # 输入 schema
│ ├── input-common.md
│ ├── gantt.md
│ ├── erd.md
│ ├── timeline.md
│ ├── venn.md
│ ├── sankey.md # Phase 2
│ ├── radar.md # Phase 2
│ ├── treemap.md # Phase 2
│ ├── wardley.md # Phase 3
│ ├── ishikawa.md # Phase 3
│ └── wordcloud.md # Phase 3
│ ├── bar.md # Phase 6
│ ├── line.md # Phase 6
│ ├── pie.md # Phase 6
│ ├── scatter.md # Phase 6
│ ├── heatmap.md # Phase 6
│ ├── funnel.md # Phase 6
│ └── dashboard.md # Phase 6C — Dashboard
├── presets/ # 场景预设
│ ├── report-16-9.json # Phase 4
│ ├── social-3-4.json # Phase 4
│ ├── social-1-1.json # Phase 5
│ └── story-9-16.json # Phase 5
├── layouts/ # Phase 6C — 仪表盘布局
│ ├── two-col.md # 左右 2 列
│ ├── three-col.md # 3 列等宽
│ └── grid.md # 2×2 网格
├── metadata/ # 元数据
│ ├── registry.yaml
│ ├── fields.yaml
│ └── dependencies.yaml
└── scripts/ # 工具脚本
├── build.py # Phase 4 — active
├── render_mermaid.py # Phase 5 — Mermaid 族
├── render_svg.py # Phase 5 — SVG 族
├── render_js.py # Phase 5 — d3/echarts 族
├── run_tests.py # Phase 6E — CI 测试运行器
└── png_export.js # Phase 5 — Puppeteer PNG 导出
├── .github/workflows/ # Phase 6E — CI/CD
│ └── test.yml # GitHub Actions: 57 tests
├── gallery/ # Phase 6F — 图表画廊
│ └── index.html # 17 种图表交互式展示