-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Refactor scattergl selection #2311
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
+136
−56
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c331266
Unify selection mode
dy c30e3f3
Decompatibilitize
dy a9d387a
Force plot opacity change
dy 53c548f
Add opacity change test
dy 1da7796
Add selected points test
dy 4e66ff5
Add #2298 test
dy ab5f6f0
Make selection per-trace instead of per-plot
dy 98cddf3
Make scattergl selection persistent with scatter
dy 0ad735c
Unsingle test
dy 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ var Plotly = require('@lib/index'); | |
var Plots = require('@src/plots/plots'); | ||
var Lib = require('@src/lib'); | ||
var Drawing = require('@src/components/drawing'); | ||
var ScatterGl = require('@src/traces/scattergl'); | ||
|
||
var createGraphDiv = require('../assets/create_graph_div'); | ||
var destroyGraphDiv = require('../assets/destroy_graph_div'); | ||
|
@@ -14,6 +15,7 @@ var selectButton = require('../assets/modebar_button'); | |
var delay = require('../assets/delay'); | ||
var readPixel = require('../assets/read_pixel'); | ||
|
||
|
||
function countCanvases() { | ||
return d3.selectAll('canvas').size(); | ||
} | ||
|
@@ -406,7 +408,6 @@ describe('Test gl2d plots', function() { | |
.then(done); | ||
}); | ||
|
||
|
||
it('@noCI should display selection of big number of miscellaneous points', function(done) { | ||
var colorList = [ | ||
'#006385', '#F06E75', '#90ed7d', '#f7a35c', '#8085e9', | ||
|
@@ -645,4 +646,75 @@ describe('Test gl2d plots', function() { | |
.catch(fail) | ||
.then(done); | ||
}); | ||
|
||
it('should restyle opacity', function(done) { | ||
// #2299 | ||
spyOn(ScatterGl, 'calc'); | ||
|
||
var dat = [{ | ||
'x': [1, 2, 3], | ||
'y': [1, 2, 3], | ||
'type': 'scattergl', | ||
'mode': 'markers' | ||
}]; | ||
|
||
Plotly.plot(gd, dat, {width: 500, height: 500}) | ||
.then(function() { | ||
expect(ScatterGl.calc).toHaveBeenCalledTimes(1); | ||
|
||
return Plotly.restyle(gd, {'opacity': 0.1}); | ||
}) | ||
.then(function() { | ||
expect(ScatterGl.calc).toHaveBeenCalledTimes(2); | ||
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. Brilliant test ✨ |
||
}) | ||
.catch(fail) | ||
.then(done); | ||
}); | ||
|
||
it('should update selected points', function(done) { | ||
// #2298 | ||
var dat = [{ | ||
'x': [1], | ||
'y': [1], | ||
'type': 'scattergl', | ||
'mode': 'markers', | ||
'selectedpoints': [0] | ||
}]; | ||
|
||
Plotly.plot(gd, dat, { | ||
width: 500, | ||
height: 500, | ||
dragmode: 'select' | ||
}) | ||
.then(function() { | ||
var scene = gd._fullLayout._plots.xy._scene; | ||
|
||
expect(scene.count).toBe(1); | ||
expect(scene.selectBatch).toEqual([[0]]); | ||
expect(scene.unselectBatch).toEqual([[]]); | ||
spyOn(scene.scatter2d, 'draw'); | ||
|
||
var trace = { | ||
x: [2], | ||
y: [1], | ||
type: 'scattergl', | ||
mode: 'markers', | ||
marker: {color: 'red'} | ||
}; | ||
|
||
return Plotly.addTraces(gd, trace); | ||
}) | ||
.then(function() { | ||
var scene = gd._fullLayout._plots.xy._scene; | ||
|
||
expect(scene.count).toBe(2); | ||
expect(scene.selectBatch).toBeDefined(); | ||
expect(scene.unselectBatch).toBeDefined(); | ||
expect(scene.markerOptions.length).toBe(2); | ||
expect(scene.markerOptions[1].color).toEqual(new Uint8Array([255, 0, 0, 255])); | ||
expect(scene.scatter2d.draw).toHaveBeenCalled(); | ||
}) | ||
.catch(fail) | ||
.then(done); | ||
}); | ||
}); |
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.
Looks good. Thanks!
I think the best way to test this would be to spy on
ScatterGl.calc
checking thatPlotly.relayout(gd, 'opacity', /**/)
does invoke it - similar to this suite.