Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4c48ec6

Browse filesBrowse files
committed
skip over BADNUM in scatter select routine
- so that BADNUM items are not included in the 'plotly_selected' event data.
1 parent 6c07e2e commit 4c48ec6
Copy full SHA for 4c48ec6

File tree

2 files changed

+33
-0
lines changed
Filter options

2 files changed

+33
-0
lines changed

‎src/traces/scatter/select.js

Copy file name to clipboardExpand all lines: src/traces/scatter/select.js
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
'use strict';
1111

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

1415
var DESELECTDIM = 0.2;
1516

@@ -40,6 +41,11 @@ module.exports = function selectPoints(searchInfo, polygon) {
4041
di = cd[i];
4142
x = xa.c2p(di.x);
4243
y = ya.c2p(di.y);
44+
45+
if(x === BADNUM || y === BADNUM) {
46+
continue;
47+
}
48+
4349
if(polygon.contains([x, y])) {
4450
selection.push({
4551
curveNumber: curveNumber,

‎test/jasmine/tests/select_test.js

Copy file name to clipboardExpand all lines: test/jasmine/tests/select_test.js
+27Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,4 +322,31 @@ describe('select box and lasso', function() {
322322
done();
323323
});
324324
});
325+
326+
it('should skip over BADNUM items', function(done) {
327+
var data = [{
328+
mode: 'markers',
329+
x: [null, undefined, NaN, 0, 'NA'],
330+
y: [NaN, null, undefined, 0, 'NA']
331+
}];
332+
var layout = {
333+
dragmode: 'select',
334+
width: 400,
335+
heigth: 400,
336+
};
337+
var gd = createGraphDiv();
338+
var pts;
339+
340+
Plotly.plot(gd, data, layout).then(function() {
341+
gd.on('plotly_selected', function(data) {
342+
pts = data.points;
343+
});
344+
345+
drag([[100, 100], [300, 300]]);
346+
expect(pts.length).toEqual(1);
347+
expect(pts[0].x).toEqual(0);
348+
expect(pts[0].y).toEqual(0);
349+
})
350+
.then(done);
351+
});
325352
});

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.