You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enable programmatic selection of points using polygons in data space, complementing the existing interactive lasso tool.
Use Cases
Annotation replay: load an existing session and re-apply the saved lasso region so the same points get selected again.
Predefined regions: select a known ROI polygon (e.g., “this cluster boundary”) as part of a workflow.
Reproducible selections: store the polygon vertices and get consistent results across runs.
Current Limitation
scatterplot.select() only accepts point indices, requiring users to manually implement point-in-polygon algorithms:
scatterplot.select([0,5,12,47]);// Requires pre-computing which points are in region
Proposed Solution
Extend select() to accept polygon vertices in data space:
// Select points within a triangle (data coordinates)scatterplot.select([[10,20],[50,80],[90,30]]);// Works with merge/remove modesscatterplot.select(rectanglePolygon,{merge: true});
Backward Compatible: Automatically detects polygon vs indices based on input type.
Implementation Details
Reuses existing findPointsInLasso()
constisPolygon=(arg)=>Array.isArray(arg)&&arg.length>=3&&Array.isArray(arg[0])&&arg[0].length===2;constselect=(pointIdxsOrPolygon,options={})=>{if(isPolygon(pointIdxsOrPolygon)){constpolygonGl=transformDataToGl(pointIdxsOrPolygon);constpoints=findPointsInLasso(polygonGl);select(points,options);// Recurse with indicesreturn;}// Existing logic...};
I'm not sure we should overload the select function. I think it'd cleaner to add a new method called scatterplot.lasso() This public function could just call lassoEnd I think. I'll take a look at your PR.
Activity
glebmoisseyev commentedon Jan 6, 2026
I went ahead and put together a draft PR implementing this here:
#236
flekschas commentedon Jan 6, 2026
I'm not sure we should overload the
selectfunction. I think it'd cleaner to add a new method calledscatterplot.lasso()This public function could just calllassoEndI think. I'll take a look at your PR.flekschas commentedon Jan 13, 2026
Closed via #236 and released in v1.15.0! 🎉