Skip to content

Fix scattergl selection #2267

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

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@
"polybooljs": "^1.2.0",
"regl": "^1.3.1",
"regl-error2d": "^2.0.3",
"regl-line2d": "^2.1.0",
"regl-scatter2d": "^2.1.9",
"regl-line2d": "^2.1.2",
"regl-scatter2d": "^2.1.11",
"right-now": "^1.0.0",
"robust-orientation": "^1.1.3",
"sane-topojson": "^2.0.0",
Expand Down
52 changes: 50 additions & 2 deletions test/jasmine/tests/gl_plot_interact_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1446,7 +1446,7 @@ describe('Test gl2d plots', function() {
var mock = require('@mocks/gl2d_10.json');

beforeEach(function() {
jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 3000;
gd = createGraphDiv();
});

Expand All @@ -1462,6 +1462,26 @@ describe('Test gl2d plots', function() {
return drag(node, dx, dy, null, p0[0], p0[1]);
}

function select(path) {
return new Promise(function(resolve) {
gd.once('plotly_selected', resolve);

var len = path.length;

// do selection
Lib.clearThrottle();
mouseEvent('mousemove', path[0][0], path[0][1]);
mouseEvent('mousedown', path[0][0], path[0][1]);

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

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

it('should respond to drag interactions', function(done) {
var _mock = Lib.extendDeep({}, mock);

Expand Down Expand Up @@ -1562,7 +1582,7 @@ describe('Test gl2d plots', function() {
.then(done);
});

it('@noCI should be able to toggle visibility', function(done) {
it('should be able to toggle visibility', function(done) {
var _mock = Lib.extendDeep({}, mock);

Plotly.plot(gd, _mock)
Expand Down Expand Up @@ -1592,6 +1612,34 @@ describe('Test gl2d plots', function() {
.then(done);
});

it('should display selection of big number of points', function(done) {
// generate large number of points
var x = [], y = [];
for(var i = 0; i < 2e4; i++) {
x.push(Math.random());
y.push(Math.random());
Copy link
Collaborator

Choose a reason for hiding this comment

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

there's probably an infinitesimal chance that this will cause any problems, but I still don't like having random calls in a test suite. If you really want something random-looking, as opposed to some simple formula, consider appropriating something reproducible like we used for box plot jitter

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you @alexcjohnson! Fixed in 39be256

}

var mock = {
data: [{
x: x, y: y, type: 'scattergl', mode: 'markers'
}],
layout: {
dragmode: 'select'
}
};

Plotly.plot(gd, mock)
.then(select([[160, 100], [180, 100]]))
.then(function() {
expect(readPixel(gd.querySelector('.gl-canvas-context'), 168, 100)[3]).toBe(0);
expect(readPixel(gd.querySelector('.gl-canvas-context'), 158, 100)[3]).not.toBe(0);
expect(readPixel(gd.querySelector('.gl-canvas-focus'), 168, 100)[3]).not.toBe(0);
})
.catch(fail)
.then(done);
});

it('should be able to toggle from svg to gl', function(done) {
Plotly.plot(gd, [{
y: [1, 2, 1],
Expand Down