Skip to content

cross-facet brushing#2369

Draft
Fil wants to merge 8 commits intofil/brush-datalessfrom
fil/brush-across-facets
Draft

cross-facet brushing#2369
Fil wants to merge 8 commits intofil/brush-datalessfrom
fil/brush-across-facets

Conversation

@Fil
Copy link
Contributor

@Fil Fil commented Feb 20, 2026

Plot.brush({sync: true}) synchronizes the brush selection across all facets — when the user brushes in one facet, the same rectangle appears in all panes and reactive marks update across all facets.

The filter function's facet arguments are now optional: omitting fx or fy (or passing undefined) skips the facet check, selecting points across all values of that facet.

This resolves @allisonhorst 's suggestions #2364 (comment) and #2364 (comment).

I'm keeping this as a separate PR for now (against #2360) to make the logic more apparent. Ideally if we merge this I would migrate the tests and examples to brushX on parallel time series, rather a 2D brush on penguins.

Disclaimer: I used @claude to generate the tests.

@Fil Fil requested a review from allisonhorst February 20, 2026 10:53
@Fil Fil mentioned this pull request Feb 20, 2026
@Fil Fil mentioned this pull request Feb 20, 2026
@Fil Fil force-pushed the fil/brush-across-facets branch from de3e623 to 6701a3d Compare February 20, 2026 11:22
# Conflicts:
#	src/interactions/brush.d.ts
#	src/interactions/brush.js
#	test/plots/brush.ts
@Fil Fil mentioned this pull request Feb 24, 2026
@Fil Fil requested a review from mbostock February 24, 2026 17:23
@Fil Fil marked this pull request as draft February 25, 2026 15:07
@Fil
Copy link
Contributor Author

Fil commented Feb 25, 2026

An issue: what if a facet's value is undefined? I might need to revise this PR so that the facet filter happens with an explicit object {fx: undefined}, which would mean "filter on the undefined facet", vs. {} or null which would mean “ignore facet when filtering”.

@allisonhorst
Copy link

Nice! This works as expected for me. One thought I had was what happens here if we add an option for free x/y scales in faceted charts.

@allisonhorst
Copy link

Not specific to the cross-facet brushing: one thing I noticed is that the opaque brush border is a bit distracting with the line mark. I think it'd be rare that a person would want to brush in the x and y direction on a line chart (instead of just brushing over time in the x direction, for example), but sharing in any case.

brush-border.mp4

@Fil
Copy link
Contributor Author

Fil commented Feb 27, 2026

It's not an opaque border: the discontinuities you're seeing on the edges of the brush are because the line is segmented between elements that are outside (context), and elements that are inside (focus) — and they're not connected. A way to avoid this is to draw a ghost line (complete), with the focus line on top (and no "context" line). I don't think we can do better by default.

@Fil
Copy link
Contributor Author

Fil commented Feb 27, 2026

what happens here if we add an option for free x/y scales in faceted charts

Yes, it will be tricky. Most probably it just doesn't make sense to support syncing in that case?

Ref. #8

@allisonhorst
Copy link

the discontinuities you're seeing on the edges of the brush are because the line is segmented between elements that are outside (context), and elements that are inside (focus)

Ah this makes sense!

@Fil
Copy link
Contributor Author

Fil commented Feb 27, 2026

For a line chart I wouldn't recommend using context like we do for individual dots, but instead would draw a (complete, greyed out) "ghost" line, and the selected line on top.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants