Skip to content

Type Alias: PickMode

ts
type PickMode = "x" | "y" | "xy";

Defined in: layers/pick.ts:20

Shared hover-picking used by point/series layers (line, scatter, stem).

The mode decides which pixel-space distance is minimized:

  • "x" — nearest by horizontal distance (classic crosshair-along-x)
  • "y" — nearest by vertical distance
  • "xy" — nearest by true 2D distance (checks both axes; right for point clouds / maps, where an x-only match would highlight the wrong point)

Distances are computed in pixels via PickProjection, so x and y are compared on the same footing regardless of each axis's data range.

When the series' x is sorted — which the line and stem layers already know, since decimation needs it — the cursor is located by binary search and only the handful of points that can still win are measured. That is what keeps hover interactive on a multi-million-point series; the linear scan it replaces cost ~185ms per frame at 6M points, roughly 200x the draw itself.

MIT licensed. WebGL2 required.