Skip to content

Commit 2b3cb25

Browse files
committed
Document filter functions
1 parent c73ba2b commit 2b3cb25

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,36 @@ scatterplot.select([0, 1]);
390390

391391
Deselect all selected points. This will trigger a `deselect` event unless `options.preventEvent === true`.
392392

393+
<a name="scatterplot.filter" href="#scatterplot.filter">#</a> scatterplot.<b>filter</b>(<i>points</i>, <i>options = {}</i>)
394+
395+
Filter down the currently drawn points, such that all points that are not included in the filter are visually and interactivelly hidden. This will trigger a `filter` event unless `options.preventEvent === true`.
396+
397+
Note: filtering down points can affect previously selected points. Selected points that are filtered out are also deselected.
398+
399+
**Arguments:**
400+
401+
- `points` is an array of indices referencing the points that you want to filter down to.
402+
- `options` [optional] is an object with the following properties:
403+
- `preventEvent`: if `true` the `select` will not be published.
404+
405+
**Examples:**
406+
407+
```javascript
408+
// Let's say we have three points
409+
scatterplot.draw([
410+
[0.1, 0.1],
411+
[0.2, 0.2],
412+
[0.3, 0.3],
413+
]);
414+
415+
// To only show the first and second point we have to do
416+
scatterplot.filter([0, 1]);
417+
```
418+
419+
<a name="scatterplot.unfilter" href="#scatterplot.unfilter">#</a> scatterplot.<b>unfilter</b>(<i>options = {}</i>)
420+
421+
Reset previously filtered out points. This will trigger an `unfilter` event unless `options.preventEvent === true`.
422+
393423
<a name="scatterplot.hover" href="#scatterplot.hover">#</a> scatterplot.<b>hover</b>(<i>point</i>, <i>options = {}</i>)
394424

395425
Programmatically hover a point, such that it gets visually highlighted. This will trigger a `pointover` or `pointout` event unless `options.preventEvent === true`.
@@ -844,6 +874,8 @@ Render Regl draw instructions into a target canvas using the renderer.
844874
| pointOut | when the mouse cursor moves out of a point | pointIndex |
845875
| select | when points are selected | `{ points }` |
846876
| deselect | when points are deselected | `undefined` |
877+
| filter | when points are filtered | `{ points }` |
878+
| unfilter | when the point filter is reset | `undefined` |
847879
| view | when the view has changes | `{ camera, view, xScale, yScale }` |
848880
| draw | when the plot was drawn | `{ camera, view, xScale, yScale }` |
849881
| lassoStart | when the lasso selection has started | `undefined` |

0 commit comments

Comments
 (0)