Skip to content
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

Scattergl lasso #1657

Merged
merged 66 commits into from
Jun 19, 2017
Merged
Changes from 1 commit
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
8fe669b
Update gl3d camera
dy Mar 21, 2017
c1a4c0c
Add dep
dy Mar 21, 2017
08f0738
Merge branch 'master' of github.com:plotly/plotly.js
dy Apr 18, 2017
97b827e
Add scattergl box/lasso icons
dy Apr 18, 2017
3d0b325
Fix status
dy Apr 21, 2017
e7e4843
Make rezooming work
dy Apr 21, 2017
6c29193
Get closer to creating scatter for selection
dy Apr 27, 2017
6d4f9a5
Fix progress
dy Apr 27, 2017
cf73fbe
Fix intermediate progress
dy Apr 28, 2017
d3427c0
first working thing
etpinard Apr 28, 2017
190d3c7
Add proper points limits
dy Apr 28, 2017
9921fb9
Add scattergl selection
dy May 3, 2017
4bff013
Fix MVP implementation
dy May 3, 2017
ab07db3
Fix proper points filtering
dy May 8, 2017
1a3ce6d
Add selection to scattergl-fancy
dy May 8, 2017
eb4654d
Make fancy scatter properly select points
dy May 8, 2017
920127d
Lintify
dy May 10, 2017
fb84a06
Resurrect hoveron
dy May 25, 2017
82c71eb
Normalize selected zoom behaviour
dy May 25, 2017
7085146
Fix losing trace reference
dy May 25, 2017
6de41e6
Merge branch 'master' into scattergl-lasso
dy May 25, 2017
86d7d65
Fix fancy scatter
dy May 26, 2017
d21176b
Capitalize cartesian
dy May 26, 2017
8a1c8b8
Recycle cartesian drawFramework
dy May 26, 2017
82610d1
Remove cartesian remnants
dy May 26, 2017
74028eb
Rename glTrace
dy May 26, 2017
e1da55b
Remove extra check
dy May 26, 2017
4c0d822
Lintify
dy May 26, 2017
5d35300
Resurrect gl hover
dy May 26, 2017
7a952b1
Outline the way to implement camera-based selection
dy May 26, 2017
b3bc7cb
Get back cartesian hover mode
dy May 26, 2017
c293529
Lintify
dy May 26, 2017
4e6bff1
comment out mouseContainer removal in scene2d toImage
etpinard May 30, 2017
5d07d99
Fix selection state
dy Jun 6, 2017
6fb7c57
Rearrange scatter run
dy Jun 6, 2017
3cb6ab1
Reduce calc time
dy Jun 6, 2017
b0f0ed3
Reduce calc time more
dy Jun 6, 2017
a74b301
Remove arrays to calcdata
dy Jun 6, 2017
73ab98d
Clean up
dy Jun 6, 2017
8b8d2e3
Use proper gl-scatter2d dep
dy Jun 6, 2017
1451802
bring back scene2d mouseContainer + add updateFx to toggle dragmode
etpinard Jun 6, 2017
de115d3
do not try to recurse into gl-vis object in Lib.minExtend
etpinard Jun 6, 2017
3a30ae1
don't try to remove selection elements when zoomlayer does not exist
etpinard Jun 6, 2017
1c61a47
fixup 'scatter' -> addTraces 'scattergl' test
etpinard Jun 6, 2017
9f57eff
Ignore overcalculating snap-points
dy Jun 6, 2017
c60fb1d
bring back scattergl marker colorscale
etpinard Jun 6, 2017
3921fdd
:hocho: hoveron in scattergl
etpinard Jun 6, 2017
07b4c7c
Fix scatter-fancy lasso
dy Jun 7, 2017
6ac722d
fill scattergl calcdata only when dragmode is set to select/lasso
etpinard Jun 7, 2017
2ceede1
don't try to style plot bg in gl2d case
etpinard Jun 7, 2017
33dda89
don't try to style grid lines either
etpinard Jun 7, 2017
baabafe
don't draw cartesian framework on top of gl2d subplots in staticPlot
etpinard Jun 7, 2017
0b7a924
fixup gl2d dramode logic (:lock: it with tests)
etpinard Jun 9, 2017
d76d64d
call updateFx on doModeBar restyle calls
etpinard Jun 9, 2017
58b3654
rm useless PR diffs
etpinard Jun 9, 2017
bbda3e7
Merge branch 'master' into scattergl-lasso
etpinard Jun 9, 2017
6bfbd83
Ignore resnapping for scatter-fancy
dy Jun 12, 2017
6c08dc3
Lintify
dy Jun 12, 2017
1e4e25d
Merge branch 'master' into scattergl-lasso
etpinard Jun 14, 2017
b92059a
add isDimmed option to fillColor util
etpinard Jun 14, 2017
d4aad3f
add gl2d select/lasso tests
etpinard Jun 14, 2017
c7b551c
try adding delay after first Plotly.plot before gl2d select/lasso tests
etpinard Jun 14, 2017
27811d6
bump gl-scatter2d-sdf to ^1.3.11
etpinard Jun 15, 2017
ab30f93
Merge branch 'master' into scattergl-lasso
etpinard Jun 15, 2017
debdd46
swap 'id' for 'pointNumber' in scattergl selection data
etpinard Jun 15, 2017
9d5d411
skip gl2d lasso/select for now
etpinard Jun 15, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 146 additions & 0 deletions test/jasmine/tests/gl2d_click_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,3 +444,149 @@ describe('Test hover and click interactions', function() {
.then(done);
});
});

describe('Test gl2d lasso/select:', function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Painful! For some reason, these tests doesn't work on CI. Looks like the cases below can't even draw the scene:

image

https://circleci.com/gh/plotly/plotly.js/4535#tests/containers/1

Can anyone try to pull down this branch and try this out locally?

Copy link
Contributor Author

@dy dy Jun 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works fine for me:
image
Although couple of times 'should output correct event data for scattergl' failed due to delay - in some reason karma runs chrome with blank tab, I have to manually switch to tests tab, but this is irrelevant.

var mockFancy = require('@mocks/gl2d_14.json');
var mockFast = Lib.extendDeep({}, mockFancy, {
data: [{mode: 'markers'}],
layout: {
xaxis: {type: 'linear'},
yaxis: {type: 'linear'}
}
});

var gd;
var selectPath = [[93, 193], [143, 193]];
var lassoPath = [[316, 171], [318, 239], [335, 243], [328, 169]];
var lassoPath2 = [[93, 193], [143, 193], [143, 500], [93, 500], [93, 193]];

afterEach(function() {
Plotly.purge(gd);
destroyGraphDiv();
});

function drag(path) {
var len = path.length;

mouseEvent('mousemove', path[0][0], path[0][1]);
mouseEvent('mousedown', path[0][0], path[0][1]);

path.slice(1, len).forEach(function(pt) {
mouseEvent('mousemove', pt[0], pt[1]);
});

mouseEvent('mouseup', path[len - 1][0], path[len - 1][1]);
}

function select(path) {
return new Promise(function(resolve, reject) {
gd.once('plotly_selected', resolve);
setTimeout(function() { reject('did not trigger *plotly_selected*');}, 100);
drag(path);
});
}

function assertEventData(actual, expected) {
expect(actual.points.length).toBe(expected.points.length);

expected.points.forEach(function(e, i) {
var a = actual.points[i];
if(a) {
expect(a.x).toBe(e.x, 'x');
expect(a.y).toBe(e.y, 'y');
}
});
}

function countGlObjects() {
return gd._fullLayout._plots.xy._scene2d.glplot.objects.length;
}

it('should work under fast mode with *select* dragmode', function(done) {
var _mock = Lib.extendDeep({}, mockFast);
_mock.layout.dragmode = 'select';
gd = createGraphDiv();

Plotly.plot(gd, _mock).then(function() {
expect(countGlObjects()).toBe(1, 'has on gl-scatter2d object');

return select(selectPath);
})
.then(function(eventData) {
assertEventData(eventData, {
points: [
{x: 3.911, y: 0.401},
{x: 5.34, y: 0.403},
{x: 6.915, y: 0.411}
]
});
expect(countGlObjects()).toBe(2, 'adds a dimmed gl-scatter2d objects');
})
.catch(fail)
.then(done);
});

it('should work under fast mode with *lasso* dragmode', function(done) {
var _mock = Lib.extendDeep({}, mockFast);
_mock.layout.dragmode = 'lasso';
gd = createGraphDiv();

Plotly.plot(gd, _mock).then(function() {
expect(countGlObjects()).toBe(1);

return select(lassoPath2);
})
.then(function(eventData) {
assertEventData(eventData, {
points: [
{x: 3.911, y: 0.401},
{x: 5.34, y: 0.403},
{x: 6.915, y: 0.411}
]
});
expect(countGlObjects()).toBe(2);
})
.catch(fail)
.then(done);
});

it('should work under fancy mode with *select* dragmode', function(done) {
var _mock = Lib.extendDeep({}, mockFancy);
_mock.layout.dragmode = 'select';
gd = createGraphDiv();

Plotly.plot(gd, _mock).then(function() {
expect(countGlObjects()).toBe(2, 'has a gl-line2d and a gl-scatter2d-sdf');

return select(selectPath);
})
.then(function(eventData) {
assertEventData(eventData, {
points: [{x: 0.004, y: 12.5}]
});
expect(countGlObjects()).toBe(2, 'only changes colors of gl-scatter2d-sdf object');
})
.catch(fail)
.then(done);
});

it('should work under fancy mode with *lasso* dragmode', function(done) {
var _mock = Lib.extendDeep({}, mockFancy);
_mock.layout.dragmode = 'lasso';
gd = createGraphDiv();

Plotly.plot(gd, _mock).then(function() {
expect(countGlObjects()).toBe(2, 'has a gl-line2d and a gl-scatter2d-sdf');

return select(lassoPath);
})
.then(function(eventData) {
assertEventData(eventData, {
points: [{ x: 0.099, y: 2.75 }]
});
expect(countGlObjects()).toBe(2, 'only changes colors of gl-scatter2d-sdf object');
})
.catch(fail)
.then(done);
});
});