-
-
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 selections for cartesian subplots #6243
Conversation
src/components/selections/select.js
Outdated
@@ -377,6 +377,8 @@ function prepSelect(evt, startX, startY, dragOptions, mode) { | |||
throttle.done(throttleID).then(function() { | |||
throttle.clear(throttleID); | |||
|
|||
// Only points selected by the new selection are presented in eventData here | |||
// Should we provide all the selected points instead? |
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.
Yes, I think so 😄 (this is basically #4095, right?)
As it stands when you edit one of the selections later, the points from all selections are included; we should do that when you create a new selection as well.
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.
No, this plotly_selected
one returns points similar to the plotly_selecting
but it fires after a new selection not during the process of selecting. The shift/alt missing part is actually addressed in b9d2db8.
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.
Addressed in 8776d49.
Alright, getting close 🙂 Aside from my latest comment (yes, always include all points in the event data) I only see two things: (1) Currently when you’re in a selection mode and you click somewhere on the plot, whether you have a selection or not you get a selected event with no data. Can we just drop that event? ie if between mousedown and mouseup you didn't move the mouse enough to get a selecting event, don't emit a selected event. (2) When you double click to deselect a region we don’t emit a |
Addressed in 8b959ea. |
It looks to be related to this part: plotly.js/src/components/selections/select.js Lines 385 to 389 in 78f3700
@alexcjohnson While I am out please feel free if you wanted to push commits here :) |
I see - I had forgotten about that. I can't really see how someone would depend on that undefined event, but having made that choice before let's not change it now. I had also forgotten that we already have a After talking to @chriddyp just now, I think we should revisit the decision to have multiple selections be the default result when you drag multiple times, and instead go back to how it was before this PR: dragging a second time clears the first selection before creating a new one; if you want to add a second selection you need to shift-drag. His main argument is that since this is how it worked before, most people probably never found the shift-drag functionality, so there's probably a lot of code out there that only supports a single selection region, and will appear broken if used with multiple regions. In addition, double-click to clear a selection might not be obvious to everyone, but getting stuck with one selection until you figure it out is a lot nicer than winding up with a dozen. I think in the interest of time, in this PR we should simply change back to "you need to shift-drag to get a second selection." Down the line though we could add configurability, to either (a) keep that behavior, (b) disallow multiple selections entirely, or (c) the behavior you have right now, with no shift needed. Another idea Chris had to make this easier is adding a delete button to each selection, that appears in the corner when you're hovering on the selection. But again, not needed for this PR, we can do this later. |
…e without shiftKey
Addressed in feb4657. |
@@ -1,27 +1,40 @@ | |||
'use strict'; | |||
|
|||
var polybool = require('polybooljs'); | |||
var pointInPolygon = require('point-in-polygon/nested'); |
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.
FYI we already have an "is this point inside this polygon" in polygon.tester
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.
Good call. I tried to reuse it here: f28576e.
But it seems it require extra work.
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.
yeah it's old and undocumented... maybe I'll give it a shot myself at some point. Or maybe we drop that code entirely and just use point-in-polygon
😏
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.
Excellent work! Let's do it 😄 💃
Great feature - cheers 🍻 |
…ut attributes to have persistent and editable selections over cartesian subplots (plotly/plotly.js#6243)
Demo
Please find new
layout
attributes in b952125 which are quite similar toshapes
.More description: coming soon
Some TODOs:
x0
,x1
,y0
,y1
defaultssplom
@plotly/plotly_js
cc: @chriddyp