-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Persistent, stateful hover, click, and selection properties #1848
Comments
So, Plotly.newPlot('graph', {
data: [{
mode: 'markers',
x: [1, 2, 3],
y: [2, 1, 2]
}],
hoverdata: {
points: [{x: 1, y: 2}]
}) would render the graphs and one hover label at |
See also #257 |
An issue from an R / Shiny user on this subject: |
Here's somewhat of a breakdown of how I'm thinking this can exist:
|
The below would be a bit of a rabbit hole to follow now, but maybe worth bringing up now as it might be input to what names and structures you end up with for the new things. There are names that suggest gesture level events such as hover, click etc. Then there are ones that express some basic intent in the sample space, like filter a contiguous subset (maybe initiated via the lasso or box select) or do some action on a specific element (maybe initiated with a double click). It's hard to refactor for it and doesn't immediately bring new functionality, but there are some benefits when the layers are uncoupled. Examples (don't necessarily apply to current
================================= Other topic: how would subplots work, given current information in the JSON? For example, if (non-overlaid) subplot 1 is on variables A and B, and subplot 2 is on variablea C and D, then there's no solid information for linking the two. Conventions such as 'sample[i] is characterized by a tuple {A[i], B[i}, C[i], D[i]' would be implicit, possibly unexpected and fragile (eg. differing row count). Other conventions, eg. using the same dataset but with different Even if axes among subplots are shared, e.g. subplot 1 has A and B, and subplot 2 has A and C, lassoing in one subplot couldn't be reflected in the other (unless you assume the above index based samples). The only thing it'd allow is, if you retain all values such that In case of an identical variable set (either separate location ie. small multiples, or overlaid subplot), any shape would of course work fine, but do we want something to work with a special case only? (No idea, just asking the question.) Also, while it'd technically work in the case of small multiples, would it necessarily make sense for the user? For example, when filtering in one specific panel of a small multiple arrangement, I'd expect only those points to be highlighted, or reflected in a table. On the contrary, in a SPLOM-like arrangement, I'd indeed expect that a selection be reflected in all subplots but it can't be done with current information because the axes are all different. Also, doing things like this looks like crossfiltering. Currently |
Thanks @rreusser for the write-up 📝
I'd vote for either hoveredpoints / selectedpoint or hoverpoints / selectionpoints (I think I prefer the latter actually).
Yeah, let's put them in their corresponding data traces. That way
We should declare
I prefer {
x: [1, 2, 3],
marker: {color: 'red'},
selected: {
marker: {color: red}
}
}
Absolutely. arrayOk ftw!
Yes, I was thinking the same.
Hmm. I'm not 100% sure of what you're referring too here. I might be unaware of some requirements. As far as I know, brushing is already doable by using |
I was thinking of where you have two linked subplots with points representing the same data but on two different sets of axes. You lasso one set, and the selection is reflected on both subplots. I don't see a way to get that for free short of feeding selection data back into all subplots. |
Ha I see. Sounds to me we might need (down the road) some sort of shared data structure across traces: {
__DATA__: [{
name: 'DATA',
columns: [{
name: 'a',
values: [1, 2, 3]
}, {
name: 'b',
values: [1, 2, 1]
}, {
name: 'c',
values: [2, 1, 2]
}],
selection: [1, 2]
}],
// but really, data here should be 'traces'
data: [{
x: 'DATA.a',
y: 'DATA.b'
}, {
x: 'DATA.a',
y: 'DATA.c',
xaxis: 'x2',
yaxis: 'y2'
}]
} |
Yeah, this works. The API in dash will probably do things a little bit differently to keep
and that way dash users can continue to listen to changes in the
but, I can just do this de-nesting in the background with something like:
and for backwards compatibility, Dash's
But again, I'm pretty sure that I can handle the conversion from |
What is |
And finally, just be clear, this API will look something like:
where the |
Would it be too much to ask to swap To clarify the a few about @chriddyp 's last #1848 (comment), the API will more like: {
x: [10, 20, 30, 40, 50],
// get rid of customdata, ids is what you want to use here
ids: ['id-1', 'id-2', 'id-3', 'id-4', 'id-5'],
marker: {size: 10},
selected: {
marker: {color: 'blue'}
},
unselected: {
marker: {opacity: 0.5}
},
// selectedpoints is an array of indices
selectedpoints: [2, 4],
hovered: {
marker: {line: {color: 'lightgrey'}}
}
// here too, an array of indices
hoveredpoints: [0, 3]
} Now to do something like @chriddyp 's selectedpoints: {
x: [30, 50],
ids: ['id-3', 'id-5'],
customdata: ['id-3', 'id-5'],
mode: 'markers+text'
} would be a little trickier, but not impossible as |
PR #2135 is now merged, but I'll leave this issue open for future development. In brief #2135, the new attribute |
Another community request for "Selection by click": https://community.plot.ly/t/highlight-clicked-marker-in-scattermapbox-graph/8315 (actually #1852 is better for this one) |
Another one for future reference: https://community.plot.ly/t/is-there-a-way-to-clear-clickdata/8708. actually #1852 is better for this one. |
Would be great to see this feature - I'd like to set selected objects from other UI components and have them update the Plot. Thanks! |
This issue has been tagged with A community PR for this feature would certainly be welcome, but our experience is deeper features like this are difficult to complete without the Plotly maintainers leading the effort. Sponsorship range: $45k-$50k What Sponsorship includes:
Please include the link to this issue when contacting us to discuss. |
Hi - this issue has been sitting for a while, so as part of our effort to tidy up our public repositories I'm going to close it. If it's still a concern, we'd be grateful if you could open a new issue (with a short reproducible example if appropriate) so that we can add it to our stack. Cheers - @gvwilson |
In Dash, the
Graph
component stores the data from hover, click, and selection events as part of the component's state and passes that to the user ashoverData
,clickData
,selectionData
.In some cases, the user may want to initialize their app with a point already "clicked", a region "preselected", or a point "hovered".
This is related to "Customized Click, Hover, and Selection Styles". The viewer will know that the graph has been pre-selected, clicked, or hovered through whatever custom styles the developer added.
Ideally, this API would match the same event data. For example, when hovering over a point, the event data might be:
Ideally, the user would be able to pass that in as part of the figure to trigger those styles themselves. That's how the Dash API currently works although styles are not applied:
cc @alexcjohnson @etpinard @monfera @jackparmer @charleyferrari
The text was updated successfully, but these errors were encountered: