Nearest Value to a Discrete SelectionEdit this page
nearest selection transform is a simple boolean operator that can be applied to discrete selection types (
multi). It is
false by default which means that data values must be interacted with directly (e.g., clicked on) to be added to the selection. When
nearest is set to
true, an invisible Voronoi diagram is computed and used to accelerate the selection – the value nearest the mouse cursor will be added to the selection.
In the scatterplot below, points the mouse cursor are highlighted as it moves.
nearest transform also respects any position encoding projections applied to the selection. For instance, in the example below, moving the mouse cursor back-and-forth snaps the vertical rule and label to the nearest
nearesttransform is not supported for continuous mark types (i.e.,
area). For these mark types, consider layering a discrete mark type (e.g.,
point) with a 0-value
opacityas in the last example above.