Nearest Value to a Discrete Selection
Edit this pageThe nearest selection transform is a simple boolean operator that can be applied to discrete selection types (single and 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.
Examples
In the scatterplot below, points the mouse cursor are highlighted as it moves.
The 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 date value.
Current Limitations
- The
nearesttransform is not supported for continuous mark types (i.e.,lineandarea). For these mark types, consider layering a discrete mark type (e.g.,point) with a 0-valueopacityas in the last example above.