-
Notifications
You must be signed in to change notification settings - Fork 185
Interactions: brush #71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
rebased |
Plot.brush should probably not set the scales’ domains, just take them as they are given. (There is no meaningful way we would brush something we don't see, so setting the scales is going to be done by another mark.) |
By not setting x and y we make sure than this mark does not reserve space for something invisible. So for example if we don't show all the data as dots, we can still use Plot.brush(data) to brush the space. viewof selection = Plot.plot({marks: [
Plot.dot(data.filter(d => d[0] > 0), { fill: "2", r: 2.5, stroke: "black", strokeWidth: 0.5 }),
Plot.brush(data, { selection: [[-2, 2], [0, 0]] })
]}) |
- this initial version works on rects - default picker is d => d (each rect will send its value to the viewof), one can set picker: d => d.x - picker: null will not set onclick - bin transforms set picker = group => groupData (aka "the right thing") - not fully tested with faceting, though it seems to work - added a general mechanism to send the value as an Input event (not sure it's the right thing to do though), better than the async method of #71 - q: should we always send the initial value, and if so what data? a solution to this problem would be to opt in with a global {picker: data} and the picking would only apply to marks that have the same data. test https://observablehq.com/d/f4e32e31ec214e38
(This is already covered by #5 in the project board and milestone, so I don’t want to list it twice.) |
- this initial version works on rects - default picker is d => d (each rect will send its value to the viewof), one can set picker: d => d.x - picker: null will not set onclick - bin transforms set picker = group => groupData (aka "the right thing") - not fully tested with faceting, though it seems to work - added a general mechanism to send the value as an Input event (not sure it's the right thing to do though), better than the async method of #71 - q: should we always send the initial value, and if so what data? a solution to this problem would be to opt in with a global {picker: data} and the picking would only apply to marks that have the same data. test https://observablehq.com/d/f4e32e31ec214e38
- this initial version works on rects - default picker is d => d (each rect will send its value to the viewof), one can set picker: d => d.x - picker: null will not set onclick - bin transforms set picker = group => groupData (aka "the right thing") - not fully tested with faceting, though it seems to work - added a general mechanism to send the value as an Input event (not sure it's the right thing to do though), better than the async method of #71 - q: should we always send the initial value, and if so what data? a solution to this problem would be to opt in with a global {picker: data} and the picking would only apply to marks that have the same data. test https://observablehq.com/d/f4e32e31ec214e38
We can also brush on ordinal scales. |
@Fil My demo report error |
@nami868 are you using a build that includes this code? Plot.brush is not part of the official distribution, it only lives on this development branch. See https://observablehq.com/@fil/plot-early-bird |
thanks |
* internal selection boolean channel & dataflow * internal dispatch * clickable option on dots and rules * merge #71 * onchange handler * marks always have a nodes property and share a default select function which hides/shows the children * facets: when using faceted brushes, clicking on a brush cancels the others; and a programmatic selection cancels all the brushes
I think this is close. I want to try resurrecting this branch, making a few tweaks, and thinking about the ownerSVGElement problem. We can keep thinking about the selection channel in #669 but we may be able to land brushing (and perhaps pointing? or lasso?) ahead of that. |
Idle musing: I wonder if marks could emit events? Also: When brushing with faceting, I could imagine a mode where you can have multiple brushes active, and the selection is the union across facets. |
bf140b8
to
3c12b39
Compare
Co-authored-by: Mike Bostock <[email protected]>
Okay, I think this is ready to go @Fil. It’s missing the ability to set the initial selection, but I think this is still a fine starting point. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LG! Fil, since you opened this, can you just comment on whether you approve?
Yes! 🚀 |
Regarding faceting, how about supporting an option which synchronises the brush area across all facets? Why is this useful? For example lets say we have plot.line faceted and we use brush.x to select points of comparison between the right-most point in the brush area vs the left most point let's say these are dates in a time-series |
rebooting this with https://observablehq.com/@observablehq/plot-brush-interaction-1653 |
Fixes #5.
TODO
Disable the standard mark channels (e.g., href, title)?No, just don’t do that.Support scale insets (use scale ranges rather than chart dimensions)?No, it’s fine as is.Set the plot’s initial value when there is an initial selection (what about faceting)?Not yet.Previous tests of brush, brushX and brushY: https://observablehq.com/d/2044e02a89cc688a