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

Toggling a Multi Selection

Edit this page

The toggle selection transformation inserts or removes data values from a multi selection if they, respectively, are or are not already members of it.

It can take one of the following values:

  • false – disables toggling behaviour; as the user interacts, data values are only inserted into the multi selection and never removed.
  • A Vega expression which is re-evaluated as the user interacts. If the expression evaluates to true, the data value is toggled into or out of the multi selection. If the expression evaluates to false, the multi selection is first clear, and the data value is then inserted.

Vega-Lite automatically adds a toggle transformation to all multi selections by default, with the following definition: "toggle": "event.shiftKey". As a result, data values are toggled when the user interacts with the shift-key pressed.

Examples

Highlight points in the scatterplot below by into the paintbrush selection when clicking with:
.