narrative-text-visualization by antvis/chart-visualization-skills
npx skills add https://github.com/antvis/chart-visualization-skills --skill narrative-text-visualization此技能提供了一个工作流程,用于使用 T8 语法 将数据转换为结构化的叙事文本可视化。T8 语法是一种声明式的类 Markdown 语言,用于创建带有语义实体标注的数据叙事。
T8 是 AntV 技术栈下的文本可视化解决方案,专为基于洞察的叙事文本展示而设计。您无需手动构建 DOM 元素,只需编写简单、人类可读的语法来描述您的数据叙事。
主要特性:
要生成叙事文本可视化,请遵循以下步骤:
分析用户的请求以确定:
根据以下规范,使用 T8 语法创建叙事文本。内容必须包括:
根据用户偏好的框架,创建 HTML、React 或 Vue 代码来渲染 T8 内容。
确保:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
T8 语法是一种类 Markdown 语言,用于创建带有语义实体标注的叙事文本。它使数据分析报告更具表现力和视觉吸引力。
使用标准的 Markdown 标题语法:
# Level 1 Heading (Main Title)
## Level 2 Heading (Section)
### Level 3 Heading (Subsection)
#### Level 4 Heading
##### Level 5 Heading
###### Level 6 Heading
规则:
# 符号后添加一个空格常规文本段落通过空行分隔:
This is the first paragraph with some content.
This is the second paragraph, separated by a blank line.
规则:
T8 语法支持无序列表和有序列表。
无序列表:
- First item
- Second item
- Third item
有序列表:
1. First step
2. Second step
3. Third step
规则:
-、*)或数字后添加一个空格T8 语法支持使用 Markdown 语法进行内联文本格式化:
粗体文本: This is **bold text** that stands out.
斜体文本: This is *italic text* for emphasis.
下划线文本: This is __underlined text__ for importance.
链接: Visit [our website](https://example.com) for more information.
规则:
[text](URL) 语法,其中 URL 以 http://、https:// 或 / 开头T8 语法的核心特性是 实体标注 —— 用语义含义和元数据标记特定的数据点。
[displayText](entityType)
displayText:向读者显示的文本entityType:此实体的语义类型示例:
The [sales revenue](metric_name) reached [¥1.5 million](metric_value) this quarter.
[displayText](entityType, key1=value1, key2=value2, key3="string value")
元数据规则:
origin=1500000、active=true)unit="元"、region="Asia")示例:
Revenue grew by [15.3%](ratio_value, origin=0.153, assessment="positive") compared to last year.
使用这些实体类型来标注不同类型的数据:
| 实体类型 | 描述 | 何时使用 | 示例 |
|---|---|---|---|
metric_name | 指标或 KPI 的名称 | 当提及您正在测量的内容时 | "revenue", "user count", "market share" |
metric_value | 主要指标值 | 报告的主要数字/值 | "¥1.5 million", "50,000 users", "250 units" |
other_metric_value | 次要或辅助指标值 | 提供上下文的附加指标 | "average order value: $120" |
delta_value | 绝对变化/差异 | 当展示不同时期之间的数值变化时 | "+1,200 units", "-$50K", "increased by 500" |
ratio_value | 百分比变化/比率 | 当展示百分比变化时 | "+15.3%", "-5.2%", "grew 23%" |
contribute_ratio | 贡献百分比 | 当展示某物贡献的百分比时 | "accounts for 45%", "represents 30% of total" |
trend_desc | 趋势描述 | 描述变化的方向/模式 | "steadily rising", "declining trend", "stable" |
dim_value | 维度值/类别 | 地理、分类或细分数据 | "North America", "Enterprise segment", "Q3" |
time_desc | 时间段或时间戳 | 当指定某事何时发生时 | "Q3 2024", "January-March", "fiscal year 2023" |
proportion | 比例或比率 | 当表达整体的部分时 | "3 out of 5", "60% of customers" |
rank | 排名或位置 | 当指示列表中的顺序或位置时 | "ranked 1st", "top 3", "5th place" |
difference | 比较差异 | 当突出两个项目之间的差异时 | "difference of $50K", "gap of 200 units" |
anomaly | 异常或意外值 | 当指出异常值或意外情况时 | "unusual spike", "unexpected drop" |
association | 关系或相关性 | 当描述指标之间的连接时 | "strongly correlated", "linked to", "related" |
distribution | 数据分布模式 | 当描述数据如何分布时 | "evenly distributed", "concentrated in", "spread across" |
seasonality | 季节性模式或趋势 | 当描述重复出现的季节性模式时 | "seasonal peak", "holiday period", "Q4 surge" |
添加这些可选字段以提供更丰富的数据上下文:
origin (数字)显示文本背后的原始数值。
示例:
[¥1.5M](metric_value, origin=1500000)[23.7%](ratio_value, origin=0.237)[5.2K users](metric_value, origin=5200)[3 out of 4](proportion, origin=0.75)为何使用它: 支持数据可视化、排序和计算
assessment (字符串)评估变化是积极、消极还是中性。
有效值: "positive", "negative", "equal", "neutral"
示例:
[increased 15%](ratio_value, assessment="positive")[dropped 8%](ratio_value, assessment="negative")[remained flat](trend_desc, assessment="equal")为何使用它: 支持为好坏趋势提供视觉指示器(颜色、图标)
unit (字符串)值的度量单位。
示例:
[¥1,500,000](metric_value, unit="元", origin=1500000)[150](metric_value, unit="units")detail (任意)用于图表渲染的附加上下文或细分数据。某些实体类型需要此字段。
以下实体类型需要此字段:
rank:表示排名数据的数字数组
[top performer](rank, detail=[5, 8, 12, 15, 20])difference:显示比较值的数字数组
[gap narrowing](difference, detail=[100, 80, 60, 40])anomaly:突出异常值的数字数组
[unusual spike](anomaly, detail=[10, 12, 11, 45, 13])association:用于相关性数据的 {x, y} 对象数组
[strong correlation](association, detail=[{"x":1,"y":2},{"x":2,"y":4},{"x":3,"y":6}])distribution:显示数据分布的数字数组
[uneven distribution](distribution, detail=[5, 15, 45, 25, 10])seasonality:包含数据数组和可选范围的对象
[Q4 peak](seasonality, detail={"data":[10,12,15,30],"range":[0,40]})其他类型的可选字段:
[steady growth](trend_desc, detail=[100, 120, 145, 180, 210])关键点:所有数据必须来自公开的真实来源:
# 2024 Smartphone Market Analysis
## Market Overview
Global [smartphone shipments](metric_name) reached [1.2 billion units](metric_value, origin=1200000000) in [2024](time_desc), showing a [modest decline of 2.1%](ratio_value, origin=-0.021, assessment="negative") year-over-year.
The **premium segment** (devices over $800) showed *remarkable* [resilience](trend_desc, assessment="positive"), growing by [5.8%](ratio_value, origin=0.058, assessment="positive"). [Average selling price](other_metric_value) was [$420](metric_value, origin=420, unit="USD").
## Key Findings
1. [Asia-Pacific](dim_value) remains the __largest market__
2. [Premium devices](dim_value) showed **strong growth**
3. Budget segment faced *headwinds*
## Regional Breakdown
### Asia-Pacific
[Asia-Pacific](dim_value) remains the largest market with [680 million units](metric_value, origin=680000000) shipped, though this represents a [decline of 180 million units](delta_value, origin=-180000000, assessment="negative") from the previous year.
Key markets:
- [China](dim_value): [320M units](metric_value, origin=320000000) - down [8.5%](ratio_value, origin=-0.085, assessment="negative"), [ranked 1st](rank, detail=[320, 180, 90, 65, 45]) globally, accounting for [47%](contribute_ratio, origin=0.47, assessment="positive") of regional sales
- [India](dim_value): [180M units](metric_value, origin=180000000) - up [12.3%](ratio_value, origin=0.123, assessment="positive"), [ranked 2nd](rank, detail=[320, 180, 90, 65, 45])
- [Southeast Asia](dim_value): [180M units](metric_value, origin=180000000) - [stable](trend_desc, assessment="equal")
For detailed methodology, visit [our research page](https://example.com/methodology).
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>T8 Narrative Text</title>
</head>
<body>
<div id="container"></div>
<!-- Import T8 from unpkg CDN -->
<script src="https://unpkg.com/@antv/t8/dist/t8.min.js"></script>
<script>
// T8 is available as a global variable
const { Text } = window.T8;
// Initialize T8 instance
const text = new Text(document.getElementById('container'));
// Render narrative text using T8 Syntax
const narrativeText = `
# Sales Report
This quarter, [bookings](metric_name) are higher than usual. They are [¥348k](metric_value, origin=348.12).
[Bookings](metric_name) are up [¥180.3k](delta_value, assessment="positive") relative to the same time last quarter.
`;
text.theme('light').render(narrativeText);
</script>
</body>
</html>
安装:
npm install @antv/t8
# or
yarn add @antv/t8
import { Text } from '@antv/t8';
import { useEffect, useRef } from 'react';
function T8Component() {
const containerRef = useRef<HTMLDivElement>(null);
useEffect(() => {
if (!containerRef.current) return;
// Initialize T8 instance
const text = new Text(containerRef.current);
// Render narrative text using T8 Syntax
const narrativeText = `
# Sales Report
This quarter, [bookings](metric_name) are higher than usual. They are [¥348k](metric_value, origin=348.12).
[Bookings](metric_name) are up [¥180.3k](delta_value, assessment="positive") relative to the same time last quarter.
`;
text.theme('light').render(narrativeText);
// Cleanup on unmount
return () => {
text.unmount();
};
}, []);
return <div ref={containerRef} />;
}
export default T8Component;
<template>
<div ref="containerRef"></div>
</template>
<script setup lang="ts">
import { Text } from '@antv/t8';
import { ref, onMounted, onBeforeUnmount } from 'vue';
const containerRef = ref<HTMLDivElement>();
let textInstance: Text | null = null;
onMounted(() => {
if (!containerRef.value) return;
// Initialize T8 instance
textInstance = new Text(containerRef.value);
// Render narrative text using T8 Syntax
const narrativeText = `
# Sales Report
This quarter, [bookings](metric_name) are higher than usual. They are [¥348k](metric_value, origin=348.12).
[Bookings](metric_name) are up [¥180.3k](delta_value, assessment="positive") relative to the same time last quarter.
`;
textInstance.theme('light').render(narrativeText);
});
onBeforeUnmount(() => {
if (textInstance) {
textInstance.unmount();
}
});
</script>
<template>
<div ref="container"></div>
</template>
<script>
import { Text } from '@antv/t8';
export default {
name: 'T8Component',
data() {
return {
textInstance: null,
};
},
mounted() {
// Initialize T8 instance
this.textInstance = new Text(this.$refs.container);
// Render narrative text using T8 Syntax
const narrativeText = `
# Sales Report
This quarter, [bookings](metric_name) are higher than usual. They are [¥348k](metric_value, origin=348.12).
[Bookings](metric_name) are up [¥180.3k](delta_value, assessment="positive") relative to the same time last quarter.
`;
this.textInstance.theme('light').render(narrativeText);
},
beforeDestroy() {
if (this.textInstance) {
this.textInstance.unmount();
}
},
};
</script>
origin、assessment 和其他相关字段✅ 应标注:
❌ 不应标注:
为用户生成 T8 语法内容时:
渲染输出提供:
每周安装量
165
仓库
GitHub 星标数
34
首次出现
Jan 24, 2026
安全审计
安装于
opencode128
claude-code122
codex114
gemini-cli106
github-copilot103
cursor94