Draft
Conversation
this might be a bit controversial, but it feels much easier to do the right thing by default than to have to teach it
rationale: I thought it would help a bit with the problem of the RHS points not being selectable when they define the extent. However, the points on the rhs of the domain will still be brushable since we added a small padding to the brush extent.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A brush mark that renders a 2D rectangular brush, enabling selection and filtering. The brush mark has
aria-label="brush". The mark does not take data; instead, it offers a mechanism to filter other marks while brushing, as well as any dataset.The brush dispatches input events with the selection bounds
{x1, x2, y1, y2}in data space and afilterfunction to test whether a point falls within the selection.Brushes support faceted plots: each facet gets its own brush, starting one clears the others, and the value includes fx/fy as relevant (with support in the filter function).
Three reactive mark options transforms —
brush.inactive,brush.context,brush.focus— allow marks to respond to state by showing/hiding points inside or outside the selection. Reactive marks re-render as the brush moves, withpointerEventsset to "none" by default so they don't obstruct interaction if they are above the brush (which achieves better contrast in general).The brush supports geographic projections: in that case, though, the {x1, x2, y1, y2} coordinates are returned in pixel space; but the filter projects lon/lat automatically for hit-testing.
A
pendingflag distinguishes brushing events (user gesture) from committed selections when the brush gesture ends and the user releases the pointer. This is to allow workflows where we don't want to rerender continuously during brushing (e.g. to avoid costly calls to a database backend).The brush has a
moveproperty that allows the selection to be modified programmatically.Alternatives considered:
brush.movewe could imagine supporting aplot.value = {}setter. I've investigated this, and the code I came up with felt brittle. Furthermore, it seems more discoverable to usebrush.move, and for advanced applications people will want to create the brush outside of Plot anyway. Another thing that this makes unclear, is what happens when the brush mark is reused. (But we can still add this later if necessary.).doneinstead of the.pendingflag (with opposite logic); it feels equivalent, no preference.Ideas for future PRs:
(options)and(data, options?)signatures; when data is passed, return filtered data asvalue.data.AI disclosure: I used @claude to help me generate the unit tests and maintain an action plan.
closes #5
supersedes #71
supersedes #1653
needs #2038