|
| 1 | +--- |
| 2 | +name: narrative-text-visualization |
| 3 | +description: Generate structured narrative text visualizations from data using T8 (Text) schema. Use when users want to create data interpretation reports, summaries, or structured articles with entity labeling and semantic markup. |
| 4 | +--- |
| 5 | + |
| 6 | +# Narrative Text Visualization Skill |
| 7 | + |
| 8 | +This skill provides a workflow for transforming data into structured narrative text visualizations using the AntV T8 (Text) schema. T8 is designed for unstructured data visualization where `T` stands for Text, and `8` represents a byte of 8 bits, symbolizing deep insights hidden beneath the text. |
| 9 | + |
| 10 | +## Overview |
| 11 | + |
| 12 | +`T8` is a declarative JSON Schema syntax used to describe data interpretation reports with semantic entity labeling. It's designed to be: |
| 13 | +- **LLM-friendly**: Easy to generate with AI prompts |
| 14 | +- **Technology stack agnostic**: Works with React, Vue, and other frameworks |
| 15 | +- **Extensible**: Supports custom entity phrases |
| 16 | +- **Lightweight**: Less than 20KB before gzip |
| 17 | + |
| 18 | +## Workflow |
| 19 | + |
| 20 | +To generate narrative text visualizations, follow these steps: |
| 21 | + |
| 22 | +### 1. Understand the Requirements |
| 23 | + |
| 24 | +Analyze the user's request to determine: |
| 25 | +- The topic or data to be analyzed |
| 26 | +- The type of narrative needed (report, summary, article) |
| 27 | +- The key insights to highlight |
| 28 | +- Any specific data sources or metrics |
| 29 | + |
| 30 | +### 2. Review the JSON Schema |
| 31 | + |
| 32 | +Consult the `references/schema.json` file to understand the T8 structure: |
| 33 | +- **Top Structure**: Contains `headline` and `sections` array |
| 34 | +- **Sections**: Main chapters containing `paragraphs` |
| 35 | +- **Paragraphs**: Text blocks containing `phrases`, can be: |
| 36 | + - `normal`: Regular text paragraphs |
| 37 | + - `heading1-6`: Heading levels |
| 38 | + - `bullets`: Bulleted/ordered lists |
| 39 | +- **Phrases**: Text elements that can be: |
| 40 | + - `text`: Plain text |
| 41 | + - `entity`: Semantically labeled data with metadata |
| 42 | + |
| 43 | +### 3. Entity Labeling |
| 44 | + |
| 45 | +Use entity types to mark key information (see `references/prompt.md` for details): |
| 46 | + |
| 47 | +| Entity Type | Description | Example | |
| 48 | +| -------------------- | ----------------------- | ------------------------------------ | |
| 49 | +| `metric_name` | Indicator name | "Shipment", "Growth Rate" | |
| 50 | +| `metric_value` | Main indicator value | "146 million units", "120 factories" | |
| 51 | +| `other_metric_value` | Other metric values | "$19.2 billion" | |
| 52 | +| `delta_value` | Difference | "+120" | |
| 53 | +| `ratio_value` | Rate | "+8.4%", "9%" | |
| 54 | +| `contribute_ratio` | Contribution | "40%" | |
| 55 | +| `trend_desc` | Trend Description | "Continuously Rising", "Stable" | |
| 56 | +| `dim_value` | Dimensional identifier | "India", "Jiangsu", "Overseas" | |
| 57 | +| `time_desc` | Time stamp | "Q3 2024", "all year" | |
| 58 | +| `proportion` | Proportion description | "30%" | |
| 59 | + |
| 60 | +### 4. Data Requirements |
| 61 | + |
| 62 | +**Critical**: All data must be from publicly authentic sources: |
| 63 | +- Official announcements/financial reports |
| 64 | +- Authoritative media (Reuters, Bloomberg, TechCrunch, etc.) |
| 65 | +- Industry research institutions (IDC, Canalys, Counterpoint Research, etc.) |
| 66 | +- **Never use fictional, AI-guessed, or simulated data** |
| 67 | +- Use specific numbers (e.g., "146 million units", "7058 units"), not vague approximations |
| 68 | + |
| 69 | +### 5. Generate JSON Schema |
| 70 | + |
| 71 | +Create a JSON object following the T8 schema structure: |
| 72 | + |
| 73 | +```json |
| 74 | +{ |
| 75 | + "headline": { |
| 76 | + "type": "headline", |
| 77 | + "phrases": [ |
| 78 | + { |
| 79 | + "type": "text", |
| 80 | + "value": "Article Title" |
| 81 | + } |
| 82 | + ] |
| 83 | + }, |
| 84 | + "sections": [ |
| 85 | + { |
| 86 | + "paragraphs": [ |
| 87 | + { |
| 88 | + "type": "normal", |
| 89 | + "phrases": [ |
| 90 | + { |
| 91 | + "type": "text", |
| 92 | + "value": "In Q3 2024, " |
| 93 | + }, |
| 94 | + { |
| 95 | + "type": "entity", |
| 96 | + "value": "smartphone shipments", |
| 97 | + "metadata": { |
| 98 | + "entityType": "metric_name" |
| 99 | + } |
| 100 | + }, |
| 101 | + { |
| 102 | + "type": "text", |
| 103 | + "value": " reached " |
| 104 | + }, |
| 105 | + { |
| 106 | + "type": "entity", |
| 107 | + "value": "146 million units", |
| 108 | + "metadata": { |
| 109 | + "entityType": "metric_value", |
| 110 | + "origin": 146000000, |
| 111 | + "assessment": "positive" |
| 112 | + } |
| 113 | + }, |
| 114 | + { |
| 115 | + "type": "text", |
| 116 | + "value": ", showing a year-over-year increase of " |
| 117 | + }, |
| 118 | + { |
| 119 | + "type": "entity", |
| 120 | + "value": "+8.4%", |
| 121 | + "metadata": { |
| 122 | + "entityType": "ratio_value", |
| 123 | + "origin": 0.084, |
| 124 | + "assessment": "positive" |
| 125 | + } |
| 126 | + }, |
| 127 | + { |
| 128 | + "type": "text", |
| 129 | + "value": "." |
| 130 | + } |
| 131 | + ] |
| 132 | + } |
| 133 | + ] |
| 134 | + } |
| 135 | + ] |
| 136 | +} |
| 137 | +``` |
| 138 | + |
| 139 | +### 6. Render the Visualization |
| 140 | + |
| 141 | +Once you have the JSON schema, create an HTML file that uses the T8 library to render the narrative text: |
| 142 | + |
| 143 | +```html |
| 144 | +<!DOCTYPE html> |
| 145 | +<html lang="en"> |
| 146 | +<head> |
| 147 | + <meta charset="UTF-8"> |
| 148 | + <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 149 | + <title>Narrative Text Visualization</title> |
| 150 | + <script src="https://unpkg.com/@antv/t8/dist/t8.min.js"></script> |
| 151 | + <style> |
| 152 | + #container { |
| 153 | + max-width: 800px; |
| 154 | + margin: 40px auto; |
| 155 | + padding: 20px; |
| 156 | + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif; |
| 157 | + } |
| 158 | + </style> |
| 159 | +</head> |
| 160 | +<body> |
| 161 | + <div id="container"></div> |
| 162 | + <script> |
| 163 | + // The T8 schema generated above |
| 164 | + const schema = { |
| 165 | + // ... your schema here |
| 166 | + }; |
| 167 | +
|
| 168 | + // Instantiate T8 |
| 169 | + const text = new T8.Text({ |
| 170 | + container: 'container', |
| 171 | + }); |
| 172 | +
|
| 173 | + // Specify schema and theme |
| 174 | + text.schema(schema).theme('light'); |
| 175 | +
|
| 176 | + // Render visualization |
| 177 | + text.render(); |
| 178 | + </script> |
| 179 | +</body> |
| 180 | +</html> |
| 181 | +``` |
| 182 | + |
| 183 | +### 7. Output Guidelines |
| 184 | + |
| 185 | +- The article should be at least 800 Chinese characters or equivalent in other languages |
| 186 | +- Structure should be clear with natural paragraph transitions |
| 187 | +- Provide meaningful data interpretation, not just numbers |
| 188 | +- Use professional, objective language |
| 189 | +- Output only the JSON schema in plain text (no markdown code blocks) |
| 190 | +- Omit the `definitions` section in final output |
| 191 | + |
| 192 | +## Best Practices |
| 193 | + |
| 194 | +1. **Entity Metadata**: Always add these optional fields when possible: |
| 195 | + - `origin`: The exact numerical value (e.g., for "146 million units", origin is `146000000`) |
| 196 | + - `assessment`: Growth trend (`'positive'` | `'negative'` | `'equal'`) |
| 197 | + - `detail`: Supplementary data array for trends (e.g., `[2,3,4,1,7]`) |
| 198 | + |
| 199 | +2. **Entity Usage**: Maximize entity labeling for: |
| 200 | + - Metrics and values |
| 201 | + - Time references |
| 202 | + - Dimensional identifiers |
| 203 | + - Trends and changes |
| 204 | + - Proportions and ratios |
| 205 | + |
| 206 | +3. **Structure**: |
| 207 | + - Use headings to organize content |
| 208 | + - Group related information in sections |
| 209 | + - Use bullets for lists and key points |
| 210 | + - Maintain logical flow between paragraphs |
| 211 | + |
| 212 | +4. **Data Quality**: |
| 213 | + - Always cite authentic sources |
| 214 | + - Use specific, verifiable numbers |
| 215 | + - Provide context for metrics |
| 216 | + - Include time references |
| 217 | + - Note data sources where appropriate |
| 218 | + |
| 219 | +## Example Output |
| 220 | + |
| 221 | +A complete example of T8 schema can be found in the T8 repository. The rendered output provides: |
| 222 | +- Rich semantic markup for data entities |
| 223 | +- Interactive entity highlighting |
| 224 | +- Clear visual hierarchy |
| 225 | +- Professional report-style formatting |
| 226 | +- Responsive design for all devices |
| 227 | + |
| 228 | +## Reference Material |
| 229 | + |
| 230 | +Detailed specifications are located in the `references/` directory: |
| 231 | +- `prompt.md`: Complete prompt template for LLM generation |
| 232 | +- `schema.json`: Full JSON Schema definition with all types |
| 233 | + |
| 234 | +These references are based on the official AntV T8 repository and should be consulted for accurate implementation details. |
0 commit comments