首页/ AI 技能 / @skilllib/skill-2014279373543649282
Skill站外收录 @skilllib/skill-2014279373543649282

vega

生成基于数据的统计图表,支持柱状图、折线图、散点图、热力图等常见可视化类型,适用于数值型数据的分析展示。通过结构化数据与图形语法映射,实现高灵活性的图表渲染,复杂图形如雷达图和词云需使用高级模式。确保数据字段精确匹配并遵循标准格式规范。

0.0 (0) 575 次安装 原作者 编程导航
收录于 2026-01-22

Skills.MD

# Vega / Vega-Lite Visualizer **Quick Start:** Structure data as array of objects → Choose mark type (bar/line/point/area/arc/rect) → Map encodings (x, y, color, size) to fields → Set data types (quantitative/nominal/ordinal/temporal) → Wrap in ` ```vega-lite ` or ` ```vega ` fence. Always include `$schema`, use valid JSON with double quotes, field names are case-sensitive. **Use Vega-Lite for 90% of charts; Vega only for radar, word cloud, force-directed.** --- ## Critical Syntax Rules ### Rule 1: Always Include Schema ```json "$schema": "https://vega.github.io/schema/vega-lite/v5.json" ``` ### Rule 2: Valid JSON Only ``` ❌ {field: "x",} → Trailing comma, unquoted key ✅ {"field": "x"} → Proper JSON ``` ### Rule 3: Field Names Must Match Data ``` ❌ "field": "Category" when data has "category" ✅ "field": "category" → Case-sensitive match ``` ### Rule 4: Type Must Be Valid ``` ✅ quantitative | nominal | ordinal | temporal ❌ numeric | string | date ``` --- ## Common Pitfalls | Issue | Solution | |-------|----------| | Chart not rendering | Check JSON validity, verify `$schema` | | Data not showing | Field names must match exactly | | Wrong chart type | Match mark to data structure | | Colors not visible | Check color scale contrast | | Dual-axis issues | Add `resolve: {scale: {y: "independent"}}` | --- ## Output Format ````markdown ```vega-lite {...} ``` ```` Or for full Vega: ````markdown ```vega {...} ``` ```` --- ## Related Files > For advanced chart patterns and complex visualizations, refer to references below: - [examples.md](references/examples.md) — Stacked bar, grouped bar, multi-series line, area, heatmap, radar (Vega), word cloud (Vega), and interactive chart examples

评论 0

还没有评论,来抢沙发。