Skip to content

Data transformation

With transforms, you can build a pipeline that modifies the data before the objects are mapped to marks. For example, they may filter or derive data, adding or removing fields or data objects.

Departure from Vega-Lite

The notation of transforms is different from Vega-Lite to enable more straghtforward addition of new operations. Each transform has to be specified using an explicit type property like in the lower-level Vega visualization grammar. Thus, the transform type is not inferred from the presence of transform-specific properties.

Example

The following example uses the "filter" transform to retain only the rows that match the predicate expression.

{
  ...,
  "data": { ... },
  "transform": [
    {
      "type": "filter",
      "expr": "datum.end - datum.start < 5000"
    }
  ],
  ...
}