Chuyển tới nội dung chính

Visualize Skill Guide

Hướng dẫn cho dev viết skill prompt sử dụng hệ thống Visualize. Hệ thống hỗ trợ 3 loại: Native Components, SVG Diagrams, và HTML Widgets — mỗi loại phù hợp cho use case khác nhau.


Khi nào dùng loại nào

LoạiSức mạnhUse caseModule
NativeNhanh, theme-consistent, dark mode sẵnHiển thị data có cấu trúc (giá, list, chart đơn giản)native
SVGDiagram tùy chỉnh, flowchart, minh họa kiến trúcGiải thích quy trình, hệ thống, chuỗi giá trịdiagram, art
HTMLInteractive, Chart.js/D3, mọi thứ phức tạpDashboard, biểu đồ kỹ thuật, interactive calculatorchart, mockup, interactive

SVG — giải thích visual

Dùng khi cần vẽ diagram, flowchart, kiến trúc hệ thống, chuỗi giá trị, minh họa concept. LLM tự viết SVG code với pre-built classes (.c-blue, .box, .arr...) — tự động dark mode.

Ví dụ use cases:
- "Vẽ chuỗi giá trị HPG" → SVG flowchart
- "Kiến trúc hệ thống microservices" → SVG structural diagram
- "Giải thích cách hoạt động của margin trading" → SVG illustrative
- "So sánh mô hình kinh doanh A vs B" → SVG structural

HTML — interactive & charts phức tạp

Dùng khi cần Chart.js, D3 maps, interactive controls, calculator, dashboard layout. Render trong iframe sandboxed, hỗ trợ CDN libraries.

Ví dụ use cases:
- "Biểu đồ kỹ thuật RSI + MACD + Bollinger" → HTML + Chart.js
- "Dashboard tổng quan thị trường" → HTML + multiple charts
- "Bản đồ nhiệt ngành" → HTML + D3
- "Calculator lãi kép" → HTML interactive
- "So sánh timeline giá 5 cổ phiếu" → HTML + Chart.js multi-series

Native — data có cấu trúc

Dùng khi data khớp với 1 trong các component có sẵn. Không cần LLM viết code — chỉ truyền JSON.

Ví dụ use cases:
- "Giá HPG bao nhiêu?" → asset_card
- "Định giá HPG" → valuation_chart
- "So sánh P/E HPG với ngành" → peer_comparison
- "Tỷ trọng danh mục" → donut_chart
- "Kế hoạch giao dịch hôm nay" → list (grouped)

Workflow chung

Agent cần 2 bước:

  1. visualize_read_me(modules=[...], components=[...]) — load design system + schema
  2. visualize_show_chart(widget_code=..., title=..., loading_messages=[...], i_have_seen_read_me=true) — render

widget_code chấp nhận 3 loại content (auto-detect):

  • JSON có "component" key → Native
  • Bắt đầu <svg → SVG
  • Còn lại → HTML

Viết Skill Prompt

Bước 1: Xác định module cần load

Cần vẽ gìModules
Native componentmodules=['native']
SVG diagrammodules=['diagram']
SVG illustrationmodules=['diagram'] hoặc modules=['art']
Chart.js chartmodules=['chart']
Interactive widgetmodules=['interactive']
UI mockupmodules=['mockup']
Native + chart kết hợpmodules=['native', 'chart']

Bước 2: Viết reminder trong skill prompt

Dạng SVG diagram:

Visualize using SVG diagram.
Call visualize_read_me(modules=['diagram']) for design system.
Draw a flowchart/structural diagram showing the process.

Dạng HTML Chart.js:

Visualize using Chart.js.
Call visualize_read_me(modules=['chart']) for setup guide.
Create a bar/line/pie chart with the data.

Dạng Native component:

Visualize using native component 'valuation_chart'.
Call visualize_read_me(modules=['native'], components=['valuation_chart']) for schema.
Set context: "valuation".

Dạng kết hợp nhiều loại:

Visualize with multiple types:
- Native 'stat' for KPI summary
- Chart.js for price trend chart
- Native 'list' for trade recommendations
Call visualize_read_me(modules=['native', 'chart'], components=['stat', 'list']).

Component & Module Reference

Native Components (modules=['native'])

ComponentMô tảFilter
statGrid KPI cards (2-4 metrics)components=['stat']
listList simple hoặc grouped (MUA/BÁN)components=['list']
valuation_chartBiểu đồ định giá (green/yellow/red)components=['valuation_chart']
asset_cardTicker info + mini chartcomponents=['asset_card']
peer_comparisonBar chart so sánh ngànhcomponents=['peer_comparison']
donut_chartPie/donut tỷ trọngcomponents=['donut_chart']
line_chartLine chart + markerscomponents=['line_chart']
card_listCards slider (media/report/default)components=['card_list']

SVG Modules

ModuleKhi nào dùngCó gì trong read_me
diagramFlowchart, structural, illustrativeViewBox setup, pre-built classes, arrow markers, font calibration, diagram types
artIllustration, generative artCanvas filling, organic shapes, color freestyle

HTML Modules

ModuleKhi nào dùngCó gì trong read_me
chartChart.js, D3 choropleth mapsCanvas sizing, UMD loading, legend patterns, number formatting
mockupUI components, forms, cardsTokens, metric cards, layout patterns
interactiveSliders, steppers, calculatorsStreaming rules, sendPrompt, stepper pattern

Context (CTA button)

ContextCTA LabelURL
stockXem phân tích 360 trên Simplize/co-phieu/{ticker}/phan-tich
valuationXem phân tích 360 trên Simplize/co-phieu/{ticker}/phan-tich
portfolioXem danh mục trên Simplize/portfolio/{id}
nebulaXem chi tiết Nebula/nebula
watchlistXem danh sách quan sát/watchlist
marketXem thị trường/market
peerXem so sánh ngành/co-phieu/{ticker}/phan-tich

Decision Tree cho dev

Dữ liệu cần hiển thị là gì?

├─ Giải thích quy trình / kiến trúc / concept?
│ └─ SVG → modules=['diagram']

├─ Biểu đồ kỹ thuật phức tạp (multi-axis, indicators)?
│ └─ HTML + Chart.js → modules=['chart']

├─ Dashboard / interactive calculator?
│ └─ HTML → modules=['interactive'] hoặc modules=['chart', 'mockup']

├─ Bản đồ địa lý?
│ └─ HTML + D3 → modules=['chart']

├─ Data khớp native component?
│ ├─ Giá + chart → asset_card
│ ├─ Định giá → valuation_chart
│ ├─ So sánh ngành → peer_comparison
│ ├─ Tỷ trọng → donut_chart
│ ├─ Performance → line_chart
│ ├─ News / reports → card_list
│ ├─ List items → list
│ ├─ KPI numbers → stat
│ └─ modules=['native'], components=[...]

└─ Bảng dữ liệu?
└─ Markdown table (không cần visualize)

Ví dụ mapping skill → visualize

SkillLoạiModuleComponent/Approach
Định giá cổ phiếuNativenativevaluation_chart
Phân tích kỹ thuậtHTMLchartChart.js multi-panel (RSI, MACD, BB)
Chuỗi giá trị doanh nghiệpSVGdiagramFlowchart structural
So sánh cổ phiếu cùng ngànhNativenativepeer_comparison
Xây dựng danh mục NebulaNativenativelist + donut_chart
Dashboard thị trườngHTMLchart, mockupChart.js + metric cards
Giải thích margin tradingSVGdiagramIllustrative diagram
Hiệu suất portfolioNativenativeline_chart + stat
Tin tức cổ phiếuNativenativecard_list (media)
Báo cáo phân tíchNativenativecard_list (report)
Bản đồ nhiệt ngànhHTMLchartD3 heatmap
Calculator lãi képHTMLinteractiveHTML + JS interactive
Best practices
  • Không cần repeat schema trong skill prompt — agent đọc từ visualize_read_me
  • Chỉ nhắc module + component name + context — đủ cho agent
  • SVG/HTML mạnh hơn native cho custom visualization — đừng ép native cho mọi thứ
  • Thêm data mapping hint nếu field names giữa tool result và component props khác nhau
  • Agent có thể kết hợp nhiều loại trong 1 response (text → SVG → text → native → text)