-
Notifications
You must be signed in to change notification settings - Fork 28
Closed
Labels
new featureNew feature or functionalityNew feature or functionality
Description
name: 'Enhancement'
about: 'Add programmatic lasso selection API'
labels: 'Enhancement 🎉'
Goal
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 regionProposed 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 modes
scatterplot.select(rectanglePolygon, { merge: true });Backward Compatible: Automatically detects polygon vs indices based on input type.
Implementation Details
Reuses existing findPointsInLasso()
const isPolygon = (arg) =>
Array.isArray(arg) && arg.length >= 3 &&
Array.isArray(arg[0]) && arg[0].length === 2;
const select = (pointIdxsOrPolygon, options = {}) => {
if (isPolygon(pointIdxsOrPolygon)) {
const polygonGl = transformDataToGl(pointIdxsOrPolygon);
const points = findPointsInLasso(polygonGl);
select(points, options); // Recurse with indices
return;
}
// Existing logic...
};Checklist
- No duplicate issues
- Use cases described
- Backward compatible
- Working demo included
- Implementation prototyped
Metadata
Metadata
Assignees
Labels
new featureNew feature or functionalityNew feature or functionality