Narrative Text Visualization Skill
This skill provides a workflow for transforming data into structured narrative text visualizations using T8 Syntax - a declarative Markdown-like language for creating data narratives with semantic entity annotations.
What is T8
T8 is a text visualization solution under the AntV technology stack designed specifically for insight-based narrative text display. Instead of manually constructing DOM elements, you write simple, human-readable syntax that describes your data narrative.
Key Features:
- LLM-Friendly: The syntax is intuitive and can be easily generated by AI models
- Declarative & Readable: Write what you want, not how to build it
- Framework Agnostic: Works with React, Vue, or vanilla JavaScript
- Standardized Styling: Professional appearance by default
- Built-in Data Visualizations: Mini charts (pie, line) are native to the syntax
- Lightweight: Less than 20KB before gzip
Workflow
To generate narrative text visualizations, follow these steps:
1. Understand the Requirements
Analyze the user's request to determine:
- The topic or data to be analyzed
- The type of narrative needed (report, summary, article)
- The key insights to highlight
- Any specific data sources or metrics
2. Generate T8 Syntax Content
Create narrative text using T8 Syntax following the specification below. The content must include:
- Proper document structure (headings, paragraphs, lists)
- Entity annotations for all meaningful data points
- Appropriate metadata for entities (origin, assessment, etc.)
3. Generate Frontend Code
Create HTML, React, or Vue code to render the T8 content based on user's preferred framework.
4. Validate Output
Ensure:
- All data is from authentic sources
- Minimum content length (800 words or equivalent)
- Proper entity annotations throughout
- Clear structure and logical flow
T8 Syntax Specification
T8 Syntax is a Markdown-like language for creating narrative text with semantic entity annotations. It makes data analysis reports more expressive and visually appealing.
Document Structure
Headings (6 levels)
Use standard Markdown heading syntax:
# Level 1 Heading (Main Title)
## Level 2 Heading (Section)
### Level 3 Heading (Subsection)
#### Level 4 Heading
##### Level 5 Heading
###### Level 6 Heading
Rules:
- Each heading must be on its own line
- Add one space after the
# symbols
- Headings create visual hierarchy in the rendered output
Paragraphs
Regular text paragraphs are separated by blank lines:
This is the first paragraph with some content.
This is the second paragraph, separated by a blank line.
Rules:
- Paragraphs can span multiple lines
- Use blank lines to separate distinct paragraphs
- Text within a paragraph flows naturally
Lists
T8 Syntax supports both unordered and ordered lists.
Unordered Lists:
- First item
- Second item
- Third item
Ordered Lists:
1. First step
2. Second step
3. Third step
Rules:
- Each list item must be on its own line
- Add one space after the bullet marker (
-, *) or number
- Lists can contain entities and text formatting
Text Formatting
T8 Syntax supports inline text formatting using Markdown syntax:
Bold Text: This is **bold text** that stands out.
Italic Text: This is *italic text* for emphasis.
Underline Text: This is __underlined text__ for importance.
Links: Visit [our website](https://example.com) for more information.
Rules:
- Formatting markers must be balanced (opening and closing)
- Formatting can be combined with entities
- Links use
[text](URL) syntax where URL starts with http://, https://, or /
Entity Annotation Syntax
The core feature of T8 Syntax is entity annotation - marking specific data points with semantic meaning and metadata.
Basic Entity Syntax
[displayText](entityType)
displayText: The text shown to readers
entityType: The semantic type of this entity
Example:
The [sales revenue](metric_name) reached [¥1.5 million](metric_value) this quarter.
Entity with Metadata
[displayText](entityType, key1=value1, key2=value2, key3="string value")
Metadata Rules:
- Separate multiple metadata fields with commas
- Numbers and booleans: write directly (e.g.,
origin=1500000, active=true)
- Strings: wrap in double quotes (e.g.,
unit="元", region="Asia")
Example:
Revenue grew by [15.3%](ratio_value, origin=0.153, assessment="positive") compared to last year.
Entity Types Reference
Use these entity types to annotate different kinds of data:
| Entity Type |
Description |
When to Use |
Examples |
metric_name |
Name of a metric or KPI |
When mentioning what you're measuring |
"revenue", "user count", "market share" |
metric_value |
Primary metric value |
The main number/value being reported |
"¥1.5 million", "50,000 users", "250 units" |
other_metric_value |
Secondary or supporting metric value |
Additional metrics that provide context |
"average order value: $120" |
delta_value |
Absolute change/difference |
When showing numeric change between periods |
"+1,200 units", "-$50K", "increased by 500" |
ratio_value |
Percentage change/rate |
When showing percentage change |
"+15.3%", "-5.2%", "grew 23%" |
contribute_ratio |
Contribution percentage |
When showing what % something contributes |
"accounts for 45%", "represents 30% of total" |
trend_desc |
Trend description |
Describing direction/pattern of change |
"steadily rising", "declining trend", "stable" |
dim_value |
Dimensional value/category |
Geographic, categorical, or segmentation data |
"North America", "Enterprise segment", "Q3" |
time_desc |
Time period or timestamp |
When specifying when something occurred |
"Q3 2024", "January-March", "fiscal year 2023" |
proportion |
Proportion or ratio |
When expressing parts of a whole |
"3 out of 5", "60% of customers" |
rank |
Ranking or position |
When indicating order or position in a list |
"ranked 1st", "top 3", "5th place" |
difference |
Comparative difference |
When highlighting difference between two items |
"difference of $50K", "gap of 200 units" |
anomaly |
Unusual or unexpected value |
When pointing out outliers or anomalies |
"unusual spike", "unexpected drop" |
association |
Relationship or correlation |
When describing connections between metrics |
"strongly correlated", "linked to", "related" |
distribution |
Data distribution pattern |
When describing how data is spread |
"evenly distributed", "concentrated in", "spread across" |
seasonality |
Seasonal pattern or trend |
When describing recurring seasonal patterns |
"seasonal peak", "holiday period", "Q4 surge" |
Common Metadata Fields
Add these optional fields to provide richer data context:
origin (number)
The raw numerical value behind the displayed text.
Examples:
[¥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)
Why use it: Enables data visualization, sorting, and calculations
assessment (string)
Evaluates whether a change is positive, negative, or neutral.
Valid values: "positive", "negative", "equal", "neutral"
Examples:
[increased 15%](ratio_value, assessment="positive")
[dropped 8%](ratio_value, assessment="negative")
[remained flat](trend_desc, assessment="equal")
Why use it: Enables visual indicators (colors, icons) for good/bad trends
unit (string)
The unit of measurement for the value.
Examples:
[¥1,500,000](metric_value, unit="元", origin=1500000)
[150](metric_value, unit="units")
detail (any)
Additional context or breakdown data for chart rendering. Required for certain entity types.
Required for these entity types:
rank: Array of numbers representing ranking data
- Example:
[top performer](rank, detail=[5, 8, 12, 15, 20])
difference: Array of numbers showing comparative values
- Example:
[gap narrowing](difference, detail=[100, 80, 60, 40])
anomaly: Array of numbers highlighting outliers
- Example:
[unusual spike](anomaly, detail=[10, 12, 11, 45, 13])
association: Array of {x, y} objects for correlation data
- Example:
[strong correlation](association, detail=[{"x":1,"y":2},{"x":2,"y":4},{"x":3,"y":6}])
distribution: Array of numbers showing data spread
- Example:
[uneven distribution](distribution, detail=[5, 15, 45, 25, 10])
seasonality: Object with data array and optional range
- Example:
[Q4 peak](seasonality, detail={"data":[10,12,15,30],"range":[0,40]})
Optional for other types:
[steady growth](trend_desc, detail=[100, 120, 145, 180, 210])
Data Requirements
Critical: All data must be from publicly authentic sources:
- Official announcements/financial reports
- Authoritative media (Reuters, Bloomberg, TechCrunch, etc.)
- Industry research institutions (IDC, Canalys, Counterpoint Research, etc.)
- Never use fictional, AI-guessed, or simulated data
- Use specific numbers (e.g., "146 million units", "7058 units"), not vague approximations
Complete T8 Syntax Example
# 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).
Using T8 in HTML, React, and Vue
Using in HTML (via CDN)
<!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>
Installation:
npm install @antv/t8
# or
yarn add @antv/t8
Using in React
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;
Using in Vue 3
<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>
Using in Vue 2
<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>
Writing Guidelines and Best Practices
Content Requirements
- Minimum Length: No less than 800 words (adjust based on data complexity)
- Structure: Clear hierarchy with logical flow between sections
- Analysis: Don't just list numbers - explain their significance and context
- Tone: Natural, fluent, objective, and professional
- Entity Usage: Annotate ALL meaningful data points - metrics, values, trends, times, changes, percentages
Entity Annotation Best Practices
- Be Comprehensive: Mark all quantitative data, not just major figures
- Use Appropriate Types: Choose the entity type that best describes the semantic meaning
- Add Metadata: Include
origin, assessment, and other relevant fields when applicable
- Natural Flow: Entities should blend seamlessly into readable prose
What to Annotate
✅ DO annotate:
- All numeric values (revenue, counts, measurements)
- All percentages (changes, contributions, proportions)
- Metric names and KPIs
- Time periods
- Geographic regions and categories
- Trend descriptions
- Comparisons and changes
❌ DON'T annotate:
- Generic text without specific data meaning
- Connecting phrases and transitions
- Context that doesn't represent measurable concepts
Output Format
When generating T8 Syntax content for the user:
- Output the T8 Syntax content directly without wrapping in code blocks
- Provide the frontend code (HTML/React/Vue) based on user preference
- Ensure all entities are properly annotated with appropriate metadata
- Verify that content meets minimum length and quality requirements
The rendered output provides:
- Rich semantic markup for data entities
- Interactive entity highlighting
- Clear visual hierarchy
- Professional report-style formatting
- Responsive design for all devices
Reference Links
1---2name: narrative-text-visualization3description: Generate structured narrative text visualizations from data using T8 Syntax. Use when users want to create data interpretation reports, summaries, or structured articles with semantic entity annotations. T8 is designed for unstructured data visualization where T stands for Text and 8 represents a byte of 8 bits, symbolizing deep insights beneath the text.4---5
6# Narrative Text Visualization Skill
7
8This skill provides a workflow for transforming data into structured narrative text visualizations using **T8 Syntax** - a declarative Markdown-like language for creating data narratives with semantic entity annotations.
9
10## What is T8
11
12T8 is a text visualization solution under the AntV technology stack designed specifically for insight-based narrative text display. Instead of manually constructing DOM elements, you write simple, human-readable syntax that describes your data narrative.
13
14**Key Features:**
15- **LLM-Friendly**: The syntax is intuitive and can be easily generated by AI models
16- **Declarative & Readable**: Write what you want, not how to build it
17- **Framework Agnostic**: Works with React, Vue, or vanilla JavaScript
18- **Standardized Styling**: Professional appearance by default
19- **Built-in Data Visualizations**: Mini charts (pie, line) are native to the syntax
20- **Lightweight**: Less than 20KB before gzip
21
22## Workflow
23
24To generate narrative text visualizations, follow these steps:
25
26### 1. Understand the Requirements
27
28Analyze the user's request to determine:
29- The topic or data to be analyzed
30- The type of narrative needed (report, summary, article)
31- The key insights to highlight
32- Any specific data sources or metrics
33
34### 2. Generate T8 Syntax Content
35
36Create narrative text using T8 Syntax following the specification below. The content must include:
37- Proper document structure (headings, paragraphs, lists)
38- Entity annotations for all meaningful data points
39- Appropriate metadata for entities (origin, assessment, etc.)
40
41### 3. Generate Frontend Code
42
43Create HTML, React, or Vue code to render the T8 content based on user's preferred framework.
44
45### 4. Validate Output
46
47Ensure:
48- All data is from authentic sources
49- Minimum content length (800 words or equivalent)
50- Proper entity annotations throughout
51- Clear structure and logical flow
52
53---
54
55## T8 Syntax Specification
56
57T8 Syntax is a Markdown-like language for creating narrative text with semantic entity annotations. It makes data analysis reports more expressive and visually appealing.
58
59### Document Structure
60
61#### Headings (6 levels)
62
63Use standard Markdown heading syntax:
64
65```
66# Level 1 Heading (Main Title)
67## Level 2 Heading (Section)
68### Level 3 Heading (Subsection)
69#### Level 4 Heading
70##### Level 5 Heading
71###### Level 6 Heading
72```
73
74**Rules:**
75- Each heading must be on its own line
76- Add one space after the `#` symbols
77- Headings create visual hierarchy in the rendered output
78
79#### Paragraphs
80
81Regular text paragraphs are separated by blank lines:
82
83```
84This is the first paragraph with some content.
85
86This is the second paragraph, separated by a blank line.
87```
88
89**Rules:**
90- Paragraphs can span multiple lines
91- Use blank lines to separate distinct paragraphs
92- Text within a paragraph flows naturally
93
94#### Lists
95
96T8 Syntax supports both unordered and ordered lists.
97
98**Unordered Lists:**
99```
100- First item
101- Second item
102- Third item
103```
104
105**Ordered Lists:**
106```
1071. First step
1082. Second step
1093. Third step
110```
111
112**Rules:**
113- Each list item must be on its own line
114- Add one space after the bullet marker (`-`, `*`) or number
115- Lists can contain entities and text formatting
116
117### Text Formatting
118
119T8 Syntax supports inline text formatting using Markdown syntax:
120
121**Bold Text:** `This is **bold text** that stands out.`
122
123**Italic Text:** `This is *italic text* for emphasis.`
124
125**Underline Text:** `This is __underlined text__ for importance.`
126
127**Links:** `Visit [our website](https://example.com) for more information.`
128
129**Rules:**
130- Formatting markers must be balanced (opening and closing)
131- Formatting can be combined with entities
132- Links use `[text](URL)` syntax where URL starts with `http://`, `https://`, or `/`
133
134### Entity Annotation Syntax
135
136The core feature of T8 Syntax is **entity annotation** - marking specific data points with semantic meaning and metadata.
137
138#### Basic Entity Syntax
139
140```
141[displayText](entityType)
142```
143
144- `displayText`: The text shown to readers
145- `entityType`: The semantic type of this entity
146
147**Example:**
148```
149The [sales revenue](metric_name) reached [¥1.5 million](metric_value) this quarter.
150```
151
152#### Entity with Metadata
153
154```
155[displayText](entityType, key1=value1, key2=value2, key3="string value")
156```
157
158**Metadata Rules:**
159- Separate multiple metadata fields with commas
160- Numbers and booleans: write directly (e.g., `origin=1500000`, `active=true`)
161- Strings: wrap in double quotes (e.g., `unit="元"`, `region="Asia"`)
162
163**Example:**
164```
165Revenue grew by [15.3%](ratio_value, origin=0.153, assessment="positive") compared to last year.
166```
167
168### Entity Types Reference
169
170Use these entity types to annotate different kinds of data:
171
172| Entity Type | Description | When to Use | Examples |
173| -------------------- | ------------------------------------ | ---------------------------------------------- | -------------------------------------------------------- |
174| `metric_name` | Name of a metric or KPI | When mentioning what you're measuring | "revenue", "user count", "market share" |
175| `metric_value` | Primary metric value | The main number/value being reported | "¥1.5 million", "50,000 users", "250 units" |
176| `other_metric_value` | Secondary or supporting metric value | Additional metrics that provide context | "average order value: $120" |
177| `delta_value` | Absolute change/difference | When showing numeric change between periods | "+1,200 units", "-$50K", "increased by 500" |
178| `ratio_value` | Percentage change/rate | When showing percentage change | "+15.3%", "-5.2%", "grew 23%" |
179| `contribute_ratio` | Contribution percentage | When showing what % something contributes | "accounts for 45%", "represents 30% of total" |
180| `trend_desc` | Trend description | Describing direction/pattern of change | "steadily rising", "declining trend", "stable" |
181| `dim_value` | Dimensional value/category | Geographic, categorical, or segmentation data | "North America", "Enterprise segment", "Q3" |
182| `time_desc` | Time period or timestamp | When specifying when something occurred | "Q3 2024", "January-March", "fiscal year 2023" |
183| `proportion` | Proportion or ratio | When expressing parts of a whole | "3 out of 5", "60% of customers" |
184| `rank` | Ranking or position | When indicating order or position in a list | "ranked 1st", "top 3", "5th place" |
185| `difference` | Comparative difference | When highlighting difference between two items | "difference of $50K", "gap of 200 units" |
186| `anomaly` | Unusual or unexpected value | When pointing out outliers or anomalies | "unusual spike", "unexpected drop" |
187| `association` | Relationship or correlation | When describing connections between metrics | "strongly correlated", "linked to", "related" |
188| `distribution` | Data distribution pattern | When describing how data is spread | "evenly distributed", "concentrated in", "spread across" |
189| `seasonality` | Seasonal pattern or trend | When describing recurring seasonal patterns | "seasonal peak", "holiday period", "Q4 surge" |
190
191### Common Metadata Fields
192
193Add these optional fields to provide richer data context:
194
195#### `origin` (number)
196
197The raw numerical value behind the displayed text.
198
199**Examples:**
200- `[¥1.5M](metric_value, origin=1500000)`
201- `[23.7%](ratio_value, origin=0.237)`
202- `[5.2K users](metric_value, origin=5200)`
203- `[3 out of 4](proportion, origin=0.75)`
204
205**Why use it:** Enables data visualization, sorting, and calculations
206
207#### `assessment` (string)
208
209Evaluates whether a change is positive, negative, or neutral.
210
211**Valid values:** `"positive"`, `"negative"`, `"equal"`, `"neutral"`
212
213**Examples:**
214- `[increased 15%](ratio_value, assessment="positive")`
215- `[dropped 8%](ratio_value, assessment="negative")`
216- `[remained flat](trend_desc, assessment="equal")`
217
218**Why use it:** Enables visual indicators (colors, icons) for good/bad trends
219
220#### `unit` (string)
221
222The unit of measurement for the value.
223
224**Examples:**
225- `[¥1,500,000](metric_value, unit="元", origin=1500000)`
226- `[150](metric_value, unit="units")`
227
228#### `detail` (any)
229
230Additional context or breakdown data for chart rendering. Required for certain entity types.
231
232**Required for these entity types:**
233- `rank`: Array of numbers representing ranking data
234 - Example: `[top performer](rank, detail=[5, 8, 12, 15, 20])`
235- `difference`: Array of numbers showing comparative values
236 - Example: `[gap narrowing](difference, detail=[100, 80, 60, 40])`
237- `anomaly`: Array of numbers highlighting outliers
238 - Example: `[unusual spike](anomaly, detail=[10, 12, 11, 45, 13])`
239- `association`: Array of {x, y} objects for correlation data
240 - Example: `[strong correlation](association, detail=[{"x":1,"y":2},{"x":2,"y":4},{"x":3,"y":6}])`
241- `distribution`: Array of numbers showing data spread
242 - Example: `[uneven distribution](distribution, detail=[5, 15, 45, 25, 10])`
243- `seasonality`: Object with data array and optional range
244 - Example: `[Q4 peak](seasonality, detail={"data":[10,12,15,30],"range":[0,40]})`
245
246**Optional for other types:**
247- `[steady growth](trend_desc, detail=[100, 120, 145, 180, 210])`
248
249---
250
251## Data Requirements
252
253**Critical**: All data must be from publicly authentic sources:
254- Official announcements/financial reports
255- Authoritative media (Reuters, Bloomberg, TechCrunch, etc.)
256- Industry research institutions (IDC, Canalys, Counterpoint Research, etc.)
257- **Never use fictional, AI-guessed, or simulated data**
258- Use specific numbers (e.g., "146 million units", "7058 units"), not vague approximations
259
260---
261
262## Complete T8 Syntax Example
263
264```
265# 2024 Smartphone Market Analysis
266
267## Market Overview
268
269Global [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.
270
271The **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").
272
273## Key Findings
274
2751. [Asia-Pacific](dim_value) remains the __largest market__
2762. [Premium devices](dim_value) showed **strong growth**
2773. Budget segment faced *headwinds*
278
279## Regional Breakdown
280
281### Asia-Pacific
282
283[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.
284
285Key markets:
286- [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
287- [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])
288- [Southeast Asia](dim_value): [180M units](metric_value, origin=180000000) - [stable](trend_desc, assessment="equal")
289
290For detailed methodology, visit [our research page](https://example.com/methodology).
291```
292
293---
294
295## Using T8 in HTML, React, and Vue
296
297### Using in HTML (via CDN)
298
299```html
300<!DOCTYPE html>
301<html lang="en">
302<head>
303 <meta charset="UTF-8">
304 <meta name="viewport" content="width=device-width, initial-scale=1.0">
305 <title>T8 Narrative Text</title>
306</head>
307<body>
308 <div id="container"></div>
309
310 <!-- Import T8 from unpkg CDN -->
311 <script src="https://unpkg.com/@antv/t8/dist/t8.min.js"></script>
312
313 <script>
314 // T8 is available as a global variable
315 const { Text } = window.T8;
316
317 // Initialize T8 instance
318 const text = new Text(document.getElementById('container'));
319
320 // Render narrative text using T8 Syntax
321 const narrativeText = `
322# Sales Report
323
324This quarter, [bookings](metric_name) are higher than usual. They are [¥348k](metric_value, origin=348.12).
325
326[Bookings](metric_name) are up [¥180.3k](delta_value, assessment="positive") relative to the same time last quarter.
327 `;
328
329 text.theme('light').render(narrativeText);
330 </script>
331</body>
332</html>
333```
334
335**Installation:**
336```bash
337npm install @antv/t8
338# or
339yarn add @antv/t8
340```
341
342### Using in React
343
344```tsx
345import { Text } from '@antv/t8';
346import { useEffect, useRef } from 'react';
347
348function T8Component() {
349 const containerRef = useRef<HTMLDivElement>(null);
350
351 useEffect(() => {
352 if (!containerRef.current) return;
353
354 // Initialize T8 instance
355 const text = new Text(containerRef.current);
356
357 // Render narrative text using T8 Syntax
358 const narrativeText = `
359# Sales Report
360
361This quarter, [bookings](metric_name) are higher than usual. They are [¥348k](metric_value, origin=348.12).
362
363[Bookings](metric_name) are up [¥180.3k](delta_value, assessment="positive") relative to the same time last quarter.
364 `;
365
366 text.theme('light').render(narrativeText);
367
368 // Cleanup on unmount
369 return () => {
370 text.unmount();
371 };
372 }, []);
373
374 return <div ref={containerRef} />;
375}
376
377export default T8Component;
378```
379
380### Using in Vue 3
381
382```vue
383<template>
384 <div ref="containerRef"></div>
385</template>
386
387<script setup lang="ts">
388import { Text } from '@antv/t8';
389import { ref, onMounted, onBeforeUnmount } from 'vue';
390
391const containerRef = ref<HTMLDivElement>();
392let textInstance: Text | null = null;
393
394onMounted(() => {
395 if (!containerRef.value) return;
396
397 // Initialize T8 instance
398 textInstance = new Text(containerRef.value);
399
400 // Render narrative text using T8 Syntax
401 const narrativeText = `
402# Sales Report
403
404This quarter, [bookings](metric_name) are higher than usual. They are [¥348k](metric_value, origin=348.12).
405
406[Bookings](metric_name) are up [¥180.3k](delta_value, assessment="positive") relative to the same time last quarter.
407 `;
408
409 textInstance.theme('light').render(narrativeText);
410});
411
412onBeforeUnmount(() => {
413 if (textInstance) {
414 textInstance.unmount();
415 }
416});
417</script>
418```
419
420### Using in Vue 2
421
422```vue
423<template>
424 <div ref="container"></div>
425</template>
426
427<script>
428import { Text } from '@antv/t8';
429
430export default {
431 name: 'T8Component',
432 data() {
433 return {
434 textInstance: null,
435 };
436 },
437 mounted() {
438 // Initialize T8 instance
439 this.textInstance = new Text(this.$refs.container);
440
441 // Render narrative text using T8 Syntax
442 const narrativeText = `
443# Sales Report
444
445This quarter, [bookings](metric_name) are higher than usual. They are [¥348k](metric_value, origin=348.12).
446
447[Bookings](metric_name) are up [¥180.3k](delta_value, assessment="positive") relative to the same time last quarter.
448 `;
449
450 this.textInstance.theme('light').render(narrativeText);
451 },
452 beforeDestroy() {
453 if (this.textInstance) {
454 this.textInstance.unmount();
455 }
456 },
457};
458</script>
459```
460
461---
462
463## Writing Guidelines and Best Practices
464
465### Content Requirements
466
4671. **Minimum Length:** No less than 800 words (adjust based on data complexity)
4682. **Structure:** Clear hierarchy with logical flow between sections
4693. **Analysis:** Don't just list numbers - explain their significance and context
4704. **Tone:** Natural, fluent, objective, and professional
4715. **Entity Usage:** Annotate ALL meaningful data points - metrics, values, trends, times, changes, percentages
472
473### Entity Annotation Best Practices
474
4751. **Be Comprehensive:** Mark all quantitative data, not just major figures
4762. **Use Appropriate Types:** Choose the entity type that best describes the semantic meaning
4773. **Add Metadata:** Include `origin`, `assessment`, and other relevant fields when applicable
4784. **Natural Flow:** Entities should blend seamlessly into readable prose
479
480### What to Annotate
481
482✅ **DO annotate:**
483- All numeric values (revenue, counts, measurements)
484- All percentages (changes, contributions, proportions)
485- Metric names and KPIs
486- Time periods
487- Geographic regions and categories
488- Trend descriptions
489- Comparisons and changes
490
491❌ **DON'T annotate:**
492- Generic text without specific data meaning
493- Connecting phrases and transitions
494- Context that doesn't represent measurable concepts
495
496---
497
498## Output Format
499
500When generating T8 Syntax content for the user:
5011. Output the T8 Syntax content directly without wrapping in code blocks
5022. Provide the frontend code (HTML/React/Vue) based on user preference
5033. Ensure all entities are properly annotated with appropriate metadata
5044. Verify that content meets minimum length and quality requirements
505
506The rendered output provides:
507- Rich semantic markup for data entities
508- Interactive entity highlighting
509- Clear visual hierarchy
510- Professional report-style formatting
511- Responsive design for all devices
512
513---
514
515## Reference Links
516
517- T8 GitHub Repository: https://github.com/antvis/T8
518- T8 Documentation: https://github.com/antvis/T8/blob/main/site/en/tutorial/quick-start.md
519- T8 Syntax Reference: https://github.com/antvis/T8/blob/main/prompt.md