Vega-Lite 6.4.3
Overview
Vega-Lite is a high-level grammar for interactive graphics. It provides a concise JSON syntax for rapidly generating interactive multi-view visualizations. A Vega-Lite specification declares the data, mark type, and encoding channels; the compiler then produces a full Vega specification that renders the chart.
Spec Structure
Every Vega-Lite spec is a JSON object. The simplest form is a single-view specification:
{
"$schema": "https://vega.github.io/schema/vega-lite/v6.json",
"description": "A simple bar chart",
"data": { "url": "data/cars.json" },
"mark": "bar",
"encoding": {
"x": { "field": "Origin", "type": "nominal" },
"y": { "aggregate": "count", "type": "quantitative" }
}
}
Top-Level Properties
| Property |
Description |
$schema |
Schema URL (e.g., https://vega.github.io/schema/vega-lite/v6.json) |
background |
Canvas background color |
padding |
View padding in pixels or object {top, right, bottom, left} |
autosize |
Auto-sizing behavior: "pad", "fit", or "none" |
config |
Global configuration overrides (marks, axes, legends, etc.) |
usermeta |
Arbitrary metadata passed through to Vega |
Common Properties (all spec types)
| Property |
Description |
name |
Unique name for the view (used in composition) |
description |
Human-readable description of the visualization |
title |
Title text, or object with text, anchor, orient, etc. |
data |
Data source(s) — inline values, URL, named, or generators |
transform |
Array of data transformation operations |
params |
Named parameters for interactivity (selections, expressions) |
Single-View Properties
| Property |
Description |
mark |
Mark type string ("bar", "line", etc.) or mark definition object |
encoding |
Mapping of data fields to visual channels |
width / height |
View dimensions in pixels, "container", or step-based |
view |
View background styling (fill, stroke, cornerRadius, cursor) |
projection |
Geographic projection settings for map views |
Composition Types
Beyond single-view specs, Vega-Lite supports four composition operators:
layer — overlay multiple marks on the same view
facet — split a chart into a grid of small multiples
concat (hconcat, vconcat, concat) — arrange views side-by-side or stacked
repeat — repeat a spec across fields, rows, or columns
Composition specs add layout properties (align, bounds, center, spacing) and a resolve property for independent scales/axes/legends.
Data Sources
Vega-Lite supports four ways to provide data:
Inline Values
Embed data directly in the spec as an array of objects:
{
"data": {
"values": [
{"category": "A", "value": 28},
{"category": "B", "value": 55}
]
}
}
Primitive arrays ([5, 3, 8]) are auto-mapped to {"data": value} objects.
URL
Load external data (JSON by default, CSV/TSV with format):
{
"data": {
"url": "data/cars.json",
"format": { "type": "json" }
}
}
Format types: json, csv, tsv, dsv (custom delimiter), topojson.
Named
Declare a named data source to be populated at runtime via Vega's View API:
{ "data": { "name": "myData" } }
Datasets
Top-level datasets mapping for shared inline data across multiple references:
{
"datasets": { "shared": [1, 2, 3] },
"data": { "name": "shared" }
}
Data Generators
sequence — generate numeric sequences (start, stop, step)
graticule — GeoJSON latitude/longitude grid for maps
sphere — GeoJSON sphere object for globe backgrounds
Encoding Channels
The encoding object maps data to visual properties. Each channel definition is one of:
- Field definition —
{field, type} with optional scale/axis/sort settings
- Value definition —
{value: ...} for constant visual values
- Datum definition —
{datum: ...} for constant data values through a scale
Channel Groups
| Group |
Channels |
Purpose |
| Position |
x, y, x2, y2 |
Mark position or bar/area width/height |
| Polar Position |
theta, radius, theta2, radius2 |
Arc mark angles and radii |
| Geo Position |
longitude, latitude, longitude2, latitude2 |
Geographic coordinates |
| Mark Property |
color, opacity, size, shape, angle, strokeWidth, strokeDash, fillOpacity, strokeOpacity |
Visual properties of marks |
| Text/Tooltip |
text, tooltip |
Labels and hover tooltips |
| Hyperlink |
href |
Clickable links |
| Description |
description |
ARIA accessibility text |
| Level of Detail |
detail |
Grouping without visual encoding |
| Key |
key |
Object constancy for transitions |
| Order |
order |
Stacking/drawing order |
| Facet |
facet, row, column |
Small multiples |
Data Types
Every field definition requires a type:
| Type |
Description |
Example |
quantitative |
Continuous numeric data (ratio/interval) |
42.0, 7.3 |
temporal |
Date/time values |
"2015-03-07", timestamps |
ordinal |
Ranked order without magnitude |
"small", "medium", "large" |
nominal |
Categorical names with no order |
"USA", "Japan", "Germany" |
geojson |
GeoJSON geographic shapes |
Feature collections |
Channel Definition Properties
Beyond field and type, field definitions support:
- Inline transforms:
aggregate, bin, timeUnit
- Scale config:
scale object with type, domain, range, zero, nice, clamp
- Axis config:
axis object with title, format, labelAngle, orient, etc.
- Legend config:
legend object with title, orient, symbolType, etc.
- Sort order:
sort — "ascending", "descending", "x", array, or field
- Conditional encoding:
condition for parameter-driven visual changes
- Format:
format string for text/tooltip display
Mark Types
The mark property declares the visual primitive. It can be a simple string ("bar") or a mark definition object ({type: "bar", filled: true}).
Primitive Marks (11)
| Mark |
Visual Role |
Key Encodings |
area |
Filled region under a line |
x, y, y2 (ranged) |
bar |
Rectangular bars |
x, y, stacking |
circle |
Circular points |
x, y, size, color |
line |
Connected segments |
x, y, interpolation |
point |
Point markers (various shapes) |
x, y, shape, filled |
rect |
Rectangles/heatmaps |
x, y, x2, y2 |
rule |
Lines at a single position |
x or y, x2/y2 (ranged) |
square |
Square points |
x, y, size |
text |
Text labels/annotations |
x, y, text, align |
tick |
Tick marks/dot plots |
x or y, thickness |
geoshape |
GeoJSON polygons/lines |
longitude, latitude or geoshape data |
Composite Marks (3)
| Mark |
Composed Of |
Purpose |
boxplot |
rule + rect + point |
Statistical box-and-whisker display |
errorbar |
rule + tick |
Error range visualization |
errorband |
area |
Confidence/shaded error region |
Mark Definition Object
{
"mark": {
"type": "point",
"filled": true,
"size": 100,
"strokeWidth": 1.5
}
}
Mark properties are organized into groups:
- General:
cursor, style, tooltip, clip, invalid, order, aria
- Position/Offset:
x, y, width, height, xOffset, yOffset
- Color:
filled, color, fill, stroke, opacity, fillOpacity, strokeOpacity, blend
- Stroke Style:
strokeCap, strokeDash, strokeJoin, strokeWidth
- Hyperlink:
href
Mark properties in the definition are overridden by encoding channels. Global defaults can be set via config.mark or mark-specific configs like config.bar.
When to Use
Use this skill when you need to:
- Generate a Vega-Lite spec from a description of the desired chart (bar, line, scatterplot, heatmap, map, etc.)
- Build interactive visualizations with selection parameters, brushes, crossfiltering, or hover effects
- Compose multi-view layouts using layer, facet, concat, or repeat operators
- Transform data within the spec using aggregate, bin, calculate, filter, window, joinaggregate, or other transforms
- Embed Vega-Lite in web applications — compile to Vega, use the embed API, configure TypeScript usage
- Debug or optimize existing specs — fix encoding errors, adjust scales/axes/legends, handle invalid data
- Explore data visually — generate histograms, QQ plots, parallel coordinates, ternary diagrams, and other analytical chart types
Advanced Topics
Foundation
- Spec Structure & Data Sources — full spec patterns, all data source types, view sizing
- Encoding Channels — complete channel reference, scales, axes, legends, conditionals
- Mark Basics — mark definition properties, config, styles
Mark Types
- Bar Charts — simple, grouped, stacked, binned, temporal, labeled, Gantt, bullet
- Line Charts — time series, multi-line, imputed, slope, bump, interpolation
- Trail Charts — connected trails, comet charts
- Area Charts — stacked, density, gradient, horizon
- Scatterplots (Circle) — 2D scatter, bubble, binned, dot plots
- Point Marks — 1D/2D points, shapes, color/opacity encodings
- Rect Charts — heatmaps, mosaics, lasagna
- Arc Charts — pie, donut, radial histograms
- Rule Marks — color mean, extent rules
- Tick Marks — dot plots, strips, histogram ticks
- Text Marks — labels, annotations, format strings
- Square & Image — square points, embedded images
Composite Marks
- Boxplots — 1D/2D, grouped, pre-aggregated, custom marks
- Error Marks — errorbars and errorbands
Geographic
- Geographic Charts — choropleths, geo points/lines, projections
Composition
- Histograms — bin patterns, log/nonlinear bins
- Layer Composition — overlaying marks, dual-axis, annotations
- Facet & Trellis — row/column faceting, small multiples
- Concat & Repeat — hconcat/vconcat, repeat operators, resolve
Cross-Cutting
- Transforms — all 19 data transforms as reference catalog
- Parameters & Selection — interactivity, selections, bindings
- Advanced Patterns — waterfall, parallel coordinates, ternary, isotype
- Usage & Embedding — web embedding, compilation, TypeScript, debugging
1---2name: vega-lite-6-4-33description: Vega-Lite 6.4.3 — high-level grammar of interactive graphics. Generate, author, and debug Vega-Lite specifications for bar charts, line charts, scatterplots, area charts, maps, heatmaps, boxplots, faceted/layered/concatenated multi-view visualizations, and interactive selections. Compiles to Vega (lower-level visualization grammar). Use when generating interactive data visualizations or authoring Vega-Lite JSON specs.4---56# Vega-Lite 6.4.378## Overview910Vega-Lite is a high-level grammar for interactive graphics. It provides a concise JSON syntax for rapidly generating interactive multi-view visualizations. A Vega-Lite specification declares the data, mark type, and encoding channels; the compiler then produces a full [Vega](https://vega.github.io/vega) specification that renders the chart.1112## Spec Structure1314Every Vega-Lite spec is a JSON object. The simplest form is a **single-view** specification:1516```json17{18 "$schema": "https://vega.github.io/schema/vega-lite/v6.json",19 "description": "A simple bar chart",20 "data": { "url": "data/cars.json" },21 "mark": "bar",22 "encoding": {23 "x": { "field": "Origin", "type": "nominal" },24 "y": { "aggregate": "count", "type": "quantitative" }25 }26}27```2829### Top-Level Properties3031| Property | Description |32|----------|-------------|33| `$schema` | Schema URL (e.g., `https://vega.github.io/schema/vega-lite/v6.json`) |34| `background` | Canvas background color |35| `padding` | View padding in pixels or object `{top, right, bottom, left}` |36| `autosize` | Auto-sizing behavior: `"pad"`, `"fit"`, or `"none"` |37| `config` | Global configuration overrides (marks, axes, legends, etc.) |38| `usermeta` | Arbitrary metadata passed through to Vega |3940### Common Properties (all spec types)4142| Property | Description |43|----------|-------------|44| `name` | Unique name for the view (used in composition) |45| `description` | Human-readable description of the visualization |46| `title` | Title text, or object with `text`, `anchor`, `orient`, etc. |47| `data` | Data source(s) — inline values, URL, named, or generators |48| `transform` | Array of data transformation operations |49| `params` | Named parameters for interactivity (selections, expressions) |5051### Single-View Properties5253| Property | Description |54|----------|-------------|55| `mark` | Mark type string (`"bar"`, `"line"`, etc.) or mark definition object |56| `encoding` | Mapping of data fields to visual channels |57| `width` / `height` | View dimensions in pixels, `"container"`, or step-based |58| `view` | View background styling (fill, stroke, cornerRadius, cursor) |59| `projection` | Geographic projection settings for map views |6061### Composition Types6263Beyond single-view specs, Vega-Lite supports four composition operators:6465- **`layer`** — overlay multiple marks on the same view66- **`facet`** — split a chart into a grid of small multiples67- **`concat`** (`hconcat`, `vconcat`, `concat`) — arrange views side-by-side or stacked68- **`repeat`** — repeat a spec across fields, rows, or columns6970Composition specs add layout properties (`align`, `bounds`, `center`, `spacing`) and a `resolve` property for independent scales/axes/legends.7172## Data Sources7374Vega-Lite supports four ways to provide data:7576### Inline Values7778Embed data directly in the spec as an array of objects:7980```json81{82 "data": {83 "values": [84 {"category": "A", "value": 28},85 {"category": "B", "value": 55}86 ]87 }88}89```9091Primitive arrays (`[5, 3, 8]`) are auto-mapped to `{"data": value}` objects.9293### URL9495Load external data (JSON by default, CSV/TSV with format):9697```json98{99 "data": {100 "url": "data/cars.json",101 "format": { "type": "json" }102 }103}104```105106Format types: `json`, `csv`, `tsv`, `dsv` (custom delimiter), `topojson`.107108### Named109110Declare a named data source to be populated at runtime via Vega's View API:111112```json113{ "data": { "name": "myData" } }114```115116### Datasets117118Top-level `datasets` mapping for shared inline data across multiple references:119120```json121{122 "datasets": { "shared": [1, 2, 3] },123 "data": { "name": "shared" }124}125```126127### Data Generators128129- **`sequence`** — generate numeric sequences (`start`, `stop`, `step`)130- **`graticule`** — GeoJSON latitude/longitude grid for maps131- **`sphere`** — GeoJSON sphere object for globe backgrounds132133## Encoding Channels134135The `encoding` object maps data to visual properties. Each channel definition is one of:136137- **Field definition** — `{field, type}` with optional scale/axis/sort settings138- **Value definition** — `{value: ...}` for constant visual values139- **Datum definition** — `{datum: ...}` for constant data values through a scale140141### Channel Groups142143| Group | Channels | Purpose |144|-------|----------|---------|145| Position | `x`, `y`, `x2`, `y2` | Mark position or bar/area width/height |146| Polar Position | `theta`, `radius`, `theta2`, `radius2` | Arc mark angles and radii |147| Geo Position | `longitude`, `latitude`, `longitude2`, `latitude2` | Geographic coordinates |148| Mark Property | `color`, `opacity`, `size`, `shape`, `angle`, `strokeWidth`, `strokeDash`, `fillOpacity`, `strokeOpacity` | Visual properties of marks |149| Text/Tooltip | `text`, `tooltip` | Labels and hover tooltips |150| Hyperlink | `href` | Clickable links |151| Description | `description` | ARIA accessibility text |152| Level of Detail | `detail` | Grouping without visual encoding |153| Key | `key` | Object constancy for transitions |154| Order | `order` | Stacking/drawing order |155| Facet | `facet`, `row`, `column` | Small multiples |156157### Data Types158159Every field definition requires a `type`:160161| Type | Description | Example |162|------|-------------|---------|163| `quantitative` | Continuous numeric data (ratio/interval) | `42.0`, `7.3` |164| `temporal` | Date/time values | `"2015-03-07"`, timestamps |165| `ordinal` | Ranked order without magnitude | `"small"`, `"medium"`, `"large"` |166| `nominal` | Categorical names with no order | `"USA"`, `"Japan"`, `"Germany"` |167| `geojson` | GeoJSON geographic shapes | Feature collections |168169### Channel Definition Properties170171Beyond `field` and `type`, field definitions support:172173- **Inline transforms**: `aggregate`, `bin`, `timeUnit`174- **Scale config**: `scale` object with `type`, `domain`, `range`, `zero`, `nice`, `clamp`175- **Axis config**: `axis` object with `title`, `format`, `labelAngle`, `orient`, etc.176- **Legend config**: `legend` object with `title`, `orient`, `symbolType`, etc.177- **Sort order**: `sort` — `"ascending"`, `"descending"`, `"x"`, array, or field178- **Conditional encoding**: `condition` for parameter-driven visual changes179- **Format**: `format` string for text/tooltip display180181## Mark Types182183The `mark` property declares the visual primitive. It can be a simple string (`"bar"`) or a mark definition object (`{type: "bar", filled: true}`).184185### Primitive Marks (11)186187| Mark | Visual Role | Key Encodings |188|------|-------------|---------------|189| `area` | Filled region under a line | `x`, `y`, `y2` (ranged) |190| `bar` | Rectangular bars | `x`, `y`, stacking |191| `circle` | Circular points | `x`, `y`, `size`, `color` |192| `line` | Connected segments | `x`, `y`, interpolation |193| `point` | Point markers (various shapes) | `x`, `y`, `shape`, `filled` |194| `rect` | Rectangles/heatmaps | `x`, `y`, `x2`, `y2` |195| `rule` | Lines at a single position | `x` or `y`, `x2`/`y2` (ranged) |196| `square` | Square points | `x`, `y`, `size` |197| `text` | Text labels/annotations | `x`, `y`, `text`, `align` |198| `tick` | Tick marks/dot plots | `x` or `y`, `thickness` |199| `geoshape` | GeoJSON polygons/lines | `longitude`, `latitude` or geoshape data |200201### Composite Marks (3)202203| Mark | Composed Of | Purpose |204|------|-------------|---------|205| `boxplot` | rule + rect + point | Statistical box-and-whisker display |206| `errorbar` | rule + tick | Error range visualization |207| `errorband` | area | Confidence/shaded error region |208209### Mark Definition Object210211```json212{213 "mark": {214 "type": "point",215 "filled": true,216 "size": 100,217 "strokeWidth": 1.5218 }219}220```221222Mark properties are organized into groups:223224- **General**: `cursor`, `style`, `tooltip`, `clip`, `invalid`, `order`, `aria`225- **Position/Offset**: `x`, `y`, `width`, `height`, `xOffset`, `yOffset`226- **Color**: `filled`, `color`, `fill`, `stroke`, `opacity`, `fillOpacity`, `strokeOpacity`, `blend`227- **Stroke Style**: `strokeCap`, `strokeDash`, `strokeJoin`, `strokeWidth`228- **Hyperlink**: `href`229230Mark properties in the definition are overridden by encoding channels. Global defaults can be set via `config.mark` or mark-specific configs like `config.bar`.231232## When to Use233234Use this skill when you need to:235236- **Generate a Vega-Lite spec** from a description of the desired chart (bar, line, scatterplot, heatmap, map, etc.)237- **Build interactive visualizations** with selection parameters, brushes, crossfiltering, or hover effects238- **Compose multi-view layouts** using layer, facet, concat, or repeat operators239- **Transform data within the spec** using aggregate, bin, calculate, filter, window, joinaggregate, or other transforms240- **Embed Vega-Lite in web applications** — compile to Vega, use the embed API, configure TypeScript usage241- **Debug or optimize existing specs** — fix encoding errors, adjust scales/axes/legends, handle invalid data242- **Explore data visually** — generate histograms, QQ plots, parallel coordinates, ternary diagrams, and other analytical chart types243244## Advanced Topics245246### Foundation247248- [Spec Structure & Data Sources](reference/01-spec-and-data.md) — full spec patterns, all data source types, view sizing249- [Encoding Channels](reference/02-encoding-channels.md) — complete channel reference, scales, axes, legends, conditionals250- [Mark Basics](reference/03-mark-basics.md) — mark definition properties, config, styles251252### Mark Types253254- [Bar Charts](reference/04-bar-charts.md) — simple, grouped, stacked, binned, temporal, labeled, Gantt, bullet255- [Line Charts](reference/05-line-charts.md) — time series, multi-line, imputed, slope, bump, interpolation256- [Trail Charts](reference/06-trail-charts.md) — connected trails, comet charts257- [Area Charts](reference/07-area-charts.md) — stacked, density, gradient, horizon258- [Scatterplots (Circle)](reference/08-scatterplots.md) — 2D scatter, bubble, binned, dot plots259- [Point Marks](reference/09-point-marks.md) — 1D/2D points, shapes, color/opacity encodings260- [Rect Charts](reference/10-rect-charts.md) — heatmaps, mosaics, lasagna261- [Arc Charts](reference/11-arc-charts.md) — pie, donut, radial histograms262- [Rule Marks](reference/12-rule-marks.md) — color mean, extent rules263- [Tick Marks](reference/13-tick-marks.md) — dot plots, strips, histogram ticks264- [Text Marks](reference/14-text-marks.md) — labels, annotations, format strings265- [Square & Image](reference/15-square-and-image.md) — square points, embedded images266267### Composite Marks268269- [Boxplots](reference/16-boxplots.md) — 1D/2D, grouped, pre-aggregated, custom marks270- [Error Marks](reference/17-error-marks.md) — errorbars and errorbands271272### Geographic273274- [Geographic Charts](reference/18-geographic-charts.md) — choropleths, geo points/lines, projections275276### Composition277278- [Histograms](reference/19-histograms.md) — bin patterns, log/nonlinear bins279- [Layer Composition](reference/20-layer-composition.md) — overlaying marks, dual-axis, annotations280- [Facet & Trellis](reference/21-facet-and-trellis.md) — row/column faceting, small multiples281- [Concat & Repeat](reference/22-concat-and-repeat.md) — hconcat/vconcat, repeat operators, resolve282283### Cross-Cutting284285- [Transforms](reference/23-transforms.md) — all 19 data transforms as reference catalog286- [Parameters & Selection](reference/24-params-and-selection.md) — interactivity, selections, bindings287- [Advanced Patterns](reference/25-advanced-patterns.md) — waterfall, parallel coordinates, ternary, isotype288- [Usage & Embedding](reference/26-usage-and-embedding.md) — web embedding, compilation, TypeScript, debugging