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
Copy file name to clipboardExpand all lines: README.md
+75-32Lines changed: 75 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -498,59 +498,102 @@ Select some points, such that they get visually highlighted. This will trigger a
498
498
499
499
**Arguments:**
500
500
501
-
-`points` is either:
502
-
- An array of point indices referencing the points that you want to select, OR
503
-
- An array of `[x, y]` coordinate pairs defining a polygon in **data space** (requires `xScale` and `yScale` to be defined). All points within the polygon will be selected using the same lasso selection algorithm as the interactive lasso tool.
501
+
-`points` is an array of point indices referencing the points that you want to select.
504
502
-`options`[optional] is an object with the following properties:
505
-
-`preventEvent`: if `true` the `select` event will not be published.
506
-
-`merge`: if `true` the selected points will be added to the current selection.
507
-
-`remove`: if `true` the selected points will be removed from the current selection.
503
+
-`preventEvent`: if `true` the `select` will not be published.
508
504
509
505
**Examples:**
510
506
511
507
```javascript
512
-
// Selection by point indices
513
508
// Let's say we have three points
514
509
scatterplot.draw([
515
510
[0.1, 0.1],
516
511
[0.2, 0.2],
517
512
[0.3, 0.3],
518
513
]);
519
514
520
-
// To select the first and second point
515
+
// To select the first and second point we have to do
Programmatically select points within a polygon region. This enables automated point selection without manual lasso interaction. This will trigger a `select` event (and `lassoEnd` event) unless `options.preventEvent === true`.
522
+
523
+
**Arguments:**
524
+
525
+
-`vertices` is an array of `[x, y]` coordinate pairs defining the polygon (minimum 3 vertices required). Coordinates are in **data space** by default (requires `xScale` and `yScale`), or **GL space** if `options.isGl === true`.
526
+
-`options`[optional] is an object with the following properties:
527
+
-`merge`: if `true`, add the selected points to the current selection instead of replacing it.
528
+
-`remove`: if `true`, remove the selected points from the current selection.
529
+
-`isGl`: if `true`, interpret vertices as GL space coordinates (NDC). If `false` (default), interpret vertices as data space coordinates.
530
+
-`preventEvent`: if `true` the `select` and `lassoEnd` events will not be published.
531
+
532
+
**Notes:**
533
+
534
+
- Polygons are automatically closed if the first and last vertices differ.
535
+
- Data space coordinates require `xScale` and `yScale` to be defined during scatterplot initialization.
536
+
- GL space coordinates work without scales and are useful for direct NDC coordinate selection.
537
+
538
+
**Examples:**
539
+
540
+
```javascript
541
+
import { scaleLinear } from'd3-scale';
542
+
543
+
// Create scatterplot with scales for data space coordinates
544
+
constscatterplot=createScatterplot({
545
+
canvas,
546
+
xScale:scaleLinear().domain([0, 100]),
547
+
yScale:scaleLinear().domain([0, 100]),
548
+
});
522
549
523
-
// Programmatic lasso selection (polygon in data space)
0 commit comments