Skip to main content
A transform reshapes the data before it’s charted — pivoting columns into rows, filtering, sorting, aggregating, or adding a constant column. Transforms run before mappings are read, so a mapping can reference columns a transform produced.

Reshape: wide to long

The most common transform. Many datasets are wide — one column per series:
But a mapping wants a long shape — one row per series, with a category column to split on:
transform.reshape pivots wide to long so you can map the new category column to color:
reshape
string[]
The numeric columns to collapse into rows. Defaults to all numeric columns.
keep
string[]
Columns to carry through unchanged. Defaults to all categorical/temporal columns.
keyName
string
default:"key"
Name of the output column holding the original column names.
valueName
string
default:"value"
Name of the output column holding the values.

Other transforms

Spec-level vs layer-level

Piping a transform into the spec applies it to all layers. To reshape the data for a single geom — for example, a line overlay that needs a different shape than the bars beneath it — pass transforms on that geom:

Next