This website is for Vega-Lite v3. Go to the main Vega-Lite homepage for the latest release.

Project a Selection

Edit this page

A selection’s type determines which data values fall within it by default:

  • For single and multi selections, only values that have been directly interacted with (i.e., those that have been clicked on) are considered to be “selected.”
  • For interval selections, values that fall within both the horizontal (x) and vertical (y) extents are considered to be “selected.”

These default inclusion criteria can be modified with the project selection transformation, which offers the following two properties:

Property Type Description
encodings String[]

An array of encoding channels. The corresponding data field values must match for a data tuple to fall within the selection.

See also: encodings documentation.

fields FieldName[]

An array of field names whose values must match for a data tuple to fall within the selection.

See also: fields documentation.

Examples

In the scatterplot example below, use the project transformation to highlight : .

With interval selections, the project transformation can be used to restrict the region to just the and/or dimensions.

Current Limitations

  • Selections projected over aggregated fields/encodings can only be used within the same view they are defined in.
  • Interval selections can only be projected using encodings.
  • Interval selections projected over binned or timeUnit fields remain continuous selections. Thus, if the visual encoding discretizes them, conditional encodings will no longer work. Instead, use a layered view as shown in the example below. The bar mark discretizes the binned Acceleration field. As a result, to highlight selected bars, we use a second layered view rather than a conditional color encoding within the same view.