-
-
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
Changes from 1 commit
d6f983e
e536a91
5cad4ff
ca60e63
76926d7
78d2867
f0e6cfb
c0a94f7
12b43c6
07e5cef
b1a1c24
1958475
3c40c41
188a0db
8d0afb5
1c5f325
d0203c8
5be72de
057e4ac
556cb83
7b07a25
2a970fc
d7abd18
7addcec
d02d612
698376e
89c1655
d8ed7a7
7d897a4
96e01b6
bc04a15
710791d
342f991
b5c090f
1d7745f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,10 +99,19 @@ 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) { | ||
dragModeGroup.push('select2d'); | ||
dragModeGroup.push('lasso2d'); | ||
} | ||
if(dragModeGroup.length) addGroup(dragModeGroup); | ||
|
||
if((hasCartesian || hasGL2D) && !allAxesFixed) { | ||
addGroup(['zoom2d', 'pan2d', 'select2d', 'lasso2d']); | ||
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 |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -161,7 +161,7 @@ describe('ModeBar', function() { | |
it('creates mode bar (cartesian version)', function() { | ||
var buttons = getButtons([ | ||
['toImage', 'sendDataToCloud'], | ||
['zoom2d', 'pan2d'], | ||
['zoom2d', 'pan2d', 'select2d', 'lasso2d'], | ||
['zoomIn2d', 'zoomOut2d', 'autoScale2d', 'resetScale2d'], | ||
['hoverClosestCartesian', 'hoverCompareCartesian'] | ||
]); | ||
|
@@ -175,13 +175,14 @@ describe('ModeBar', function() { | |
|
||
expect(modeBar.hasButtons(buttons)).toBe(true); | ||
expect(countGroups(modeBar)).toEqual(5); | ||
expect(countButtons(modeBar)).toEqual(11); | ||
expect(countButtons(modeBar)).toEqual(13); | ||
expect(countLogo(modeBar)).toEqual(1); | ||
}); | ||
|
||
it('creates mode bar (cartesian fixed-axes version)', function() { | ||
var buttons = getButtons([ | ||
['toImage', 'sendDataToCloud'], | ||
['select2d', 'lasso2d'], | ||
['hoverClosestCartesian', 'hoverCompareCartesian'] | ||
]); | ||
|
||
|
@@ -192,8 +193,8 @@ describe('ModeBar', function() { | |
var modeBar = gd._fullLayout._modeBar; | ||
|
||
expect(modeBar.hasButtons(buttons)).toBe(true); | ||
expect(countGroups(modeBar)).toEqual(3); | ||
expect(countButtons(modeBar)).toEqual(5); | ||
expect(countGroups(modeBar)).toEqual(4); | ||
expect(countButtons(modeBar)).toEqual(7); | ||
expect(countLogo(modeBar)).toEqual(1); | ||
}); | ||
|
||
|
@@ -339,25 +340,32 @@ describe('ModeBar', function() { | |
it('updates mode bar buttons if modeBarButtonsToRemove changes', function() { | ||
var gd = setupGraphInfo(); | ||
manageModeBar(gd); | ||
var initialButtonCount = countButtons(gd._fullLayout._modeBar); | ||
|
||
gd._context.modeBarButtonsToRemove = ['toImage', 'sendDataToCloud']; | ||
manageModeBar(gd); | ||
|
||
expect(countButtons(gd._fullLayout._modeBar)).toEqual(9); | ||
expect(countButtons(gd._fullLayout._modeBar)) | ||
.toEqual(initialButtonCount - 2); | ||
}); | ||
|
||
it('updates mode bar buttons if modeBarButtonsToAdd changes', function() { | ||
var gd = setupGraphInfo(); | ||
manageModeBar(gd); | ||
|
||
var initialGroupCount = countGroups(gd._fullLayout._modeBar), | ||
initialButtonCount = countButtons(gd._fullLayout._modeBar); | ||
|
||
gd._context.modeBarButtonsToAdd = [{ | ||
name: 'some button', | ||
click: noop | ||
}]; | ||
manageModeBar(gd); | ||
|
||
expect(countGroups(gd._fullLayout._modeBar)).toEqual(6); | ||
expect(countButtons(gd._fullLayout._modeBar)).toEqual(12); | ||
expect(countGroups(gd._fullLayout._modeBar)) | ||
.toEqual(initialGroupCount + 1); | ||
expect(countButtons(gd._fullLayout._modeBar)) | ||
.toEqual(initialButtonCount + 1); | ||
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. I started trying to make these tests more robust against changes... but was only convenient to do for this change test. 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. 👍 |
||
}); | ||
|
||
it('sets up buttons with modeBarButtonsToAdd and modeBarButtonToRemove', function() { | ||
|
@@ -374,7 +382,7 @@ describe('ModeBar', function() { | |
|
||
var modeBar = gd._fullLayout._modeBar; | ||
expect(countGroups(modeBar)).toEqual(6); | ||
expect(countButtons(modeBar)).toEqual(10); | ||
expect(countButtons(modeBar)).toEqual(12); | ||
}); | ||
|
||
it('sets up buttons with modeBarButtonsToAdd and modeBarButtonToRemove (2)', function() { | ||
|
@@ -394,7 +402,7 @@ describe('ModeBar', function() { | |
|
||
var modeBar = gd._fullLayout._modeBar; | ||
expect(countGroups(modeBar)).toEqual(7); | ||
expect(countButtons(modeBar)).toEqual(12); | ||
expect(countButtons(modeBar)).toEqual(14); | ||
}); | ||
|
||
it('sets up buttons with fully custom modeBarButtons', function() { | ||
|
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 (cc @chriddyp @jackparmer )
Should we show the select-box and lasso by default on all cartesian graphs and leave it up to plotly.js users or widget devs to add them using
config.modeBarButtons
?It seems strange to add two buttons that are useless for all but one trace type + mode combination on all cartesian graphs.
Alternatively, we could make
getButtonsGroups
in the mode bar manager look into fullData for scatter with marker traces and only show the buttons when present.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.
Selection does have a use even without events or linking, for highlighting data while discussing or presenting it. And just because it's cool to play with 😎 So I wouldn't leave it entirely to developers to enable.
Then re: diving into fullData, I guess it depends how fast you think we'll add other trace types. (not sure if I'll be able to do it myself, but now it's just a matter of adding
selectPoints
methods to other modules) It seems pretty clear what select means for heatmaps and contour maps, and (at least for 1D as @chriddyp suggests, and I'm sure we can agree on 2D as well) what it means for bars, histograms, and boxes.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.
It doesn't look like it will be hard to add
selectPoints
for the other trace types, but I doubt that it will be a priority for the next few months.I'd vote for a check on fullData.
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.
fullData check: 7d897a4
Seems to update icons correctly when I
restyle
mode or type.