Clearing a selectionEdit this page
clear property identifies which events must fire to empty a selection of all selected values (the
empty can be used to further determine the behavior of empty selections).
It can take one of the following values:
false– disables clear behavior; there will be no event trigger that empties a selection.
- A Vega event stream definition to indicate which events should trigger clearing the selection.
Vega-Lite automatically adds the clear property to all selections by default, with the following definition:
"clear": "dblclick". Thus, to empty a selection a user can double-click the mouse button.
The following visualization demonstrates the default clearing behavior: select a square on click and clear out the selection on double click.
The following example clears the brush when the mouse button is released.
Note, in the above example, clearing out the selection does not reset it to its initial value. Instead, when the mouse button is released, the selection is emptied of all values. This behavior is subtly different to when the selection is bound to scales – clearing the selection out now resets the view to use the initial scale domains. Try it out below: pan and zoom the plot, and then double click.