Skip to content

Commit 80cee01

Browse files
committed
move BADNUM checks in polygon contains
- also make sure that 'lasso' dragmode is tested
1 parent 4c48ec6 commit 80cee01

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

src/lib/polygon.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
'use strict';
1111

1212
var dot = require('./matrix').dot;
13+
var BADNUM = require('../constants/numerical').BADNUM;
1314

1415
var polygon = module.exports = {};
1516

@@ -73,7 +74,7 @@ polygon.tester = function tester(ptsIn) {
7374
var x = pt[0],
7475
y = pt[1];
7576

76-
if(x < xmin || x > xmax || y < ymin || y > ymax) {
77+
if(x === BADNUM || x < xmin || x > xmax || y === BADNUM || y < ymin || y > ymax) {
7778
// pt is outside the bounding box of polygon
7879
return false;
7980
}
@@ -86,7 +87,7 @@ polygon.tester = function tester(ptsIn) {
8687
var x = pt[0],
8788
y = pt[1];
8889

89-
if(x < xmin || x > xmax || y < ymin || y > ymax) {
90+
if(x === BADNUM || x < xmin || x > xmax || y === BADNUM || y < ymin || y > ymax) {
9091
// pt is outside the bounding box of polygon
9192
return false;
9293
}

src/traces/scatter/select.js

-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
'use strict';
1111

1212
var subtypes = require('./subtypes');
13-
var BADNUM = require('../../constants/numerical').BADNUM;
1413

1514
var DESELECTDIM = 0.2;
1615

@@ -42,10 +41,6 @@ module.exports = function selectPoints(searchInfo, polygon) {
4241
x = xa.c2p(di.x);
4342
y = ya.c2p(di.y);
4443

45-
if(x === BADNUM || y === BADNUM) {
46-
continue;
47-
}
48-
4944
if(polygon.contains([x, y])) {
5045
selection.push({
5146
curveNumber: curveNumber,

test/jasmine/tests/select_test.js

+8
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,14 @@ describe('select box and lasso', function() {
346346
expect(pts.length).toEqual(1);
347347
expect(pts[0].x).toEqual(0);
348348
expect(pts[0].y).toEqual(0);
349+
350+
return Plotly.relayout(gd, 'dragmode', 'lasso');
351+
})
352+
.then(function() {
353+
drag([[100, 100], [100, 300], [300, 300], [300, 100], [100, 100]]);
354+
expect(pts.length).toEqual(1);
355+
expect(pts[0].x).toEqual(0);
356+
expect(pts[0].y).toEqual(0);
349357
})
350358
.then(done);
351359
});

0 commit comments

Comments
 (0)