Vega-Lite Docs
Overview
Use this skill to turn datasets and chart requirements into accurate Vega-Lite specs, then embed them in web apps. Lean on the reference files for precise property names, defaults, and examples.
Workflow
1) Clarify the chart intent and data
- Identify fields, data types (quantitative, temporal, ordinal, nominal), and grain.
- Confirm whether aggregations, bins, or time units are needed.
- Decide if a single view, layered chart, or faceted grid fits best.
2) Draft the spec skeleton
- Start with top-level fields:
data, mark, encoding, optional transform, config.
- Prefer the simplest spec that matches the goal, then add detail.
- Use inline
values for small data or url + format for external data.
Example skeleton:
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {"url": "data.csv"},
"mark": "bar",
"encoding": {
"x": {"field": "category", "type": "nominal"},
"y": {"field": "value", "type": "quantitative"}
}
}
3) Refine encodings and transforms
- Add
aggregate, bin, timeUnit, and stack only when required.
- Use
transform for calculated fields, filtering, and reshaping.
- Validate channel compatibility with mark type and data types.
4) Compose and present
- Use
layer, facet, concat, or repeat for multi-view layouts.
- Control scales, axes, and legends for readability and consistent design.
- Add
tooltip, title, and formatting for clarity.
5) Add interaction and embed
- Use
params/selection for hover/brush/filter interactions.
- Embed with
vega-embed and pass the spec directly in JS/TS.
Reference Map
Use these files as needed (only load the ones relevant to the request):
references/intro-and-embed.md - getting started, ecosystem, and embed usage.
references/spec-core.md - top-level spec, data, mark, config, invalid data.
references/encoding-and-fields.md - channels, field defs, types, sort/stack/bandposition, constants, datetime.
references/presentation.md - axis, legend, scale, format, header, title, tooltip, gradients.
references/marks.md - mark types and mark-specific properties.
references/transforms.md - transform pipeline and all transform types.
references/composition.md - layer/concat/facet/repeat and resolve rules.
references/interaction-params.md - parameters, selections, bindings, predicates.
references/geo.md - projections for geospatial charts.
Script
scripts/fetch_vega_lite_docs.py refreshes the reference files from the official docs (requires network access).
1---2name: vega-lite-docs3description: Author and debug Vega-Lite specifications for web data visualizations, including embedding with vega-embed. Use when a task needs Vega-Lite chart specs, encoding/channel choices, transforms, compositions (layer/facet/concat/repeat), interactions (params/selection), or axis/scale/legend configuration.4---56# Vega-Lite Docs78## Overview910Use this skill to turn datasets and chart requirements into accurate Vega-Lite specs, then embed them in web apps. Lean on the reference files for precise property names, defaults, and examples.1112## Workflow1314### 1) Clarify the chart intent and data15- Identify fields, data types (quantitative, temporal, ordinal, nominal), and grain.16- Confirm whether aggregations, bins, or time units are needed.17- Decide if a single view, layered chart, or faceted grid fits best.1819### 2) Draft the spec skeleton20- Start with top-level fields: `data`, `mark`, `encoding`, optional `transform`, `config`.21- Prefer the simplest spec that matches the goal, then add detail.22- Use inline `values` for small data or `url` + `format` for external data.2324Example skeleton:2526```json27{28 "$schema": "https://vega.github.io/schema/vega-lite/v5.json",29 "data": {"url": "data.csv"},30 "mark": "bar",31 "encoding": {32 "x": {"field": "category", "type": "nominal"},33 "y": {"field": "value", "type": "quantitative"}34 }35}36```3738### 3) Refine encodings and transforms39- Add `aggregate`, `bin`, `timeUnit`, and `stack` only when required.40- Use `transform` for calculated fields, filtering, and reshaping.41- Validate channel compatibility with mark type and data types.4243### 4) Compose and present44- Use `layer`, `facet`, `concat`, or `repeat` for multi-view layouts.45- Control scales, axes, and legends for readability and consistent design.46- Add `tooltip`, `title`, and formatting for clarity.4748### 5) Add interaction and embed49- Use `params`/`selection` for hover/brush/filter interactions.50- Embed with `vega-embed` and pass the spec directly in JS/TS.5152## Reference Map5354Use these files as needed (only load the ones relevant to the request):55- `references/intro-and-embed.md` - getting started, ecosystem, and embed usage.56- `references/spec-core.md` - top-level spec, data, mark, config, invalid data.57- `references/encoding-and-fields.md` - channels, field defs, types, sort/stack/bandposition, constants, datetime.58- `references/presentation.md` - axis, legend, scale, format, header, title, tooltip, gradients.59- `references/marks.md` - mark types and mark-specific properties.60- `references/transforms.md` - transform pipeline and all transform types.61- `references/composition.md` - layer/concat/facet/repeat and resolve rules.62- `references/interaction-params.md` - parameters, selections, bindings, predicates.63- `references/geo.md` - projections for geospatial charts.6465## Script6667- `scripts/fetch_vega_lite_docs.py` refreshes the reference files from the official docs (requires network access).