-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Lasso & rectangular selections #154
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
Merged
Merged
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
d6f983e
agignore dist
alexcjohnson e536a91
point in polygon routine, with tests
alexcjohnson 5cad4ff
lasso and selectbox skeleton
alexcjohnson ca60e63
propagate dragbox cursor to coverSlip while dragging
alexcjohnson 76926d7
fix modebar logic and tests for select dragmodes
alexcjohnson 78d2867
change polygon and its tests to multi-exports form
alexcjohnson f0e6cfb
polygon filtering algorithm
alexcjohnson c0a94f7
polygon filtering test
alexcjohnson 12b43c6
special case of polygon for rectangles
alexcjohnson 07e5cef
selection on scatter points
alexcjohnson b1a1c24
clear hover when drag starts
alexcjohnson 1958475
didn't end up using a separate lasso handler
alexcjohnson 3c40c41
crosshair it is
alexcjohnson 188a0db
inline rectFirstEdgeTest
alexcjohnson 8d0afb5
Merge branch 'master' into lasso
alexcjohnson 1c5f325
lasso like it's 2016 baby!
alexcjohnson d0203c8
scatter.selectPoints uses scatter.hasMarkers
alexcjohnson 5be72de
:cow2:
alexcjohnson 057e4ac
prep for adding selection bounds to event data
alexcjohnson 556cb83
split out scatter.selectPoints to a new file
alexcjohnson 7b07a25
support selecting scatter text
alexcjohnson 2a970fc
fx constants file
alexcjohnson d7abd18
more fx constants
alexcjohnson 7addcec
BENDPX into constants
alexcjohnson d02d612
horizontal and vertical select boxes
alexcjohnson 698376e
off-by-one error in select outline
alexcjohnson 89c1655
clear selection on zoom/pan
alexcjohnson d8ed7a7
selection range event data
alexcjohnson 7d897a4
show select icons only when they apply
alexcjohnson 96e01b6
update modebar tests for new select icon logic
alexcjohnson bc04a15
desciption attribute value delimiters
alexcjohnson 710791d
fix nonlinear axes in select
alexcjohnson 342f991
:cow2:
alexcjohnson b5c090f
MINSELECT bigger than MINDRAG
alexcjohnson 1d7745f
add lasso and selectbox icon
etpinard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dist | ||
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
'use strict'; | ||
|
||
var Plotly = require('../../plotly'); | ||
var scatterSubTypes = require('../../traces/scatter/subtypes'); | ||
|
||
var createModeBar = require('./'); | ||
var modeBarButtons = require('./buttons'); | ||
|
@@ -57,7 +58,7 @@ module.exports = function manageModeBar(gd) { | |
} | ||
else { | ||
buttonGroups = getButtonGroups( | ||
fullLayout, | ||
gd, | ||
context.modeBarButtonsToRemove, | ||
context.modeBarButtonsToAdd | ||
); | ||
|
@@ -68,8 +69,12 @@ module.exports = function manageModeBar(gd) { | |
}; | ||
|
||
// logic behind which buttons are displayed by default | ||
function getButtonGroups(fullLayout, buttonsToRemove, buttonsToAdd) { | ||
var groups = []; | ||
function getButtonGroups(gd, buttonsToRemove, buttonsToAdd) { | ||
var fullLayout = gd._fullLayout, | ||
fullData = gd._fullData, | ||
groups = [], | ||
i, | ||
trace; | ||
|
||
function addGroup(newGroup) { | ||
var out = []; | ||
|
@@ -99,10 +104,40 @@ function getButtonGroups(fullLayout, buttonsToRemove, buttonsToAdd) { | |
|
||
var hasCartesian = fullLayout._hasCartesian, | ||
hasGL2D = fullLayout._hasGL2D, | ||
allAxesFixed = areAllAxesFixed(fullLayout); | ||
allAxesFixed = areAllAxesFixed(fullLayout), | ||
dragModeGroup = []; | ||
|
||
if((hasCartesian || hasGL2D) && !allAxesFixed) { | ||
dragModeGroup = ['zoom2d', 'pan2d']; | ||
} | ||
if(hasCartesian) { | ||
// look for traces that support selection | ||
// to be updated as we add more selectPoints handlers | ||
var selectable = false; | ||
for(i = 0; i < fullData.length; i++) { | ||
if(selectable) break; | ||
trace = fullData[i]; | ||
if(!trace._module || !trace._module.selectPoints) continue; | ||
|
||
if(trace.type === 'scatter') { | ||
if(scatterSubTypes.hasMarkers(trace) || scatterSubTypes.hasText(trace)) { | ||
selectable = true; | ||
} | ||
} | ||
// assume that in general if the trace module has selectPoints, | ||
// then it's selectable. Scatter is an exception to this because it must | ||
// have markers or text, not just be a scatter type. | ||
else selectable = true; | ||
} | ||
|
||
if(selectable) { | ||
dragModeGroup.push('select2d'); | ||
dragModeGroup.push('lasso2d'); | ||
} | ||
} | ||
if(dragModeGroup.length) addGroup(dragModeGroup); | ||
|
||
if((hasCartesian || hasGL2D) && !allAxesFixed) { | ||
addGroup(['zoom2d', 'pan2d']); | ||
addGroup(['zoomIn2d', 'zoomOut2d', 'autoScale2d', 'resetScale2d']); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this if statement could be moved up here, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cpsievert that would change the order which the buttons are displayed |
||
|
@@ -119,7 +154,7 @@ function getButtonGroups(fullLayout, buttonsToRemove, buttonsToAdd) { | |
// append buttonsToAdd to the groups | ||
if(buttonsToAdd.length) { | ||
if(Array.isArray(buttonsToAdd[0])) { | ||
for(var i = 0; i < buttonsToAdd.length; i++) { | ||
for(i = 0; i < buttonsToAdd.length; i++) { | ||
groups.push(buttonsToAdd[i]); | ||
} | ||
} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.select-outline { | ||
fill: none; | ||
stroke-width: 1; | ||
shape-rendering: crispEdges; | ||
} | ||
.select-outline-1 { | ||
stroke: white; | ||
} | ||
.select-outline-2 { | ||
stroke: black; | ||
stroke-dasharray: 2px 2px; | ||
} |
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
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
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
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.
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.
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.
@alexcjohnson your
ack
days are over? Can I ask why?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.
I think ack disappeared from my system in an OS upgrade or something... and I tried
ag
after remembering I think @theengineear mentioned it a while back. I was never really bothered byack
butag
does seem to live up to its claim of speed. Otherwise it seems pretty similar but I'm pretty basic in how I use these tools.