Skip to content

Commit 1783631

Browse files
committed
fix selection on geo projs that don't handle BADNUMs during c2p
1 parent 16f9fd2 commit 1783631

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

src/traces/scattergeo/select.js

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

1111
var subtypes = require('../scatter/subtypes');
12+
var BADNUM = require('../../constants/numerical').BADNUM;
1213

1314
module.exports = function selectPoints(searchInfo, polygon) {
1415
var cd = searchInfo.cd;
@@ -30,6 +31,10 @@ module.exports = function selectPoints(searchInfo, polygon) {
3031
for(i = 0; i < cd.length; i++) {
3132
di = cd[i];
3233
lonlat = di.lonlat;
34+
35+
// some projection types can't handle BADNUMs
36+
if(lonlat[0] === BADNUM) continue;
37+
3338
x = xa.c2p(lonlat);
3439
y = ya.c2p(lonlat);
3540

test/jasmine/tests/select_test.js

+23-4
Original file line numberDiff line numberDiff line change
@@ -895,9 +895,9 @@ describe('@flaky Test select box and lasso per trace:', function() {
895895
keys.forEach(function(k, j) {
896896
var msgFull = msg + 'selected pt ' + i + ' - ' + k + ' val';
897897

898-
if(typeof e[j] === 'number') {
898+
if(typeof p[k] === 'number' && typeof e[j] === 'number') {
899899
expect(p[k]).toBeCloseTo(e[j], 1, msgFull);
900-
} else if(Array.isArray(e[j])) {
900+
} else if(Array.isArray(p[k]) && Array.isArray(e[j])) {
901901
expect(p[k]).toBeCloseToArray(e[j], 1, msgFull);
902902
} else {
903903
expect(p[k]).toBe(e[j], msgFull);
@@ -1166,8 +1166,8 @@ describe('@flaky Test select box and lasso per trace:', function() {
11661166
var fig = {
11671167
data: [{
11681168
type: 'scattergeo',
1169-
lon: [10, 20, 30],
1170-
lat: [10, 20, 30]
1169+
lon: [10, 20, 30, null],
1170+
lat: [10, 20, 30, null]
11711171
}, {
11721172
type: 'scattergeo',
11731173
lon: [-10, -20, -30],
@@ -1212,6 +1212,25 @@ describe('@flaky Test select box and lasso per trace:', function() {
12121212
null, LASSOEVENTS, 'scattergeo lasso'
12131213
);
12141214
})
1215+
.then(function() {
1216+
// some projection types can't handle BADNUM during c2p,
1217+
// make they are skipped here
1218+
return Plotly.relayout(gd, 'geo.projection.type', 'robinson');
1219+
})
1220+
.then(function() {
1221+
return _run(
1222+
[[300, 200], [300, 300], [400, 300], [400, 200], [300, 200]],
1223+
function() {
1224+
assertPoints([[-10, 10], [-20, 20], [-30, 30]]);
1225+
assertSelectedPoints({0: [], 1: [0, 1, 2]});
1226+
assertNodeOpacity({0: [0.2, 0.2, 0.2], 1: [1, 1, 1]});
1227+
assertLassoPoints([
1228+
[-67.40, 55.07], [-56.33, 4.968], [0, 4.968], [0, 55.07], [-67.40, 55.07]
1229+
]);
1230+
},
1231+
null, LASSOEVENTS, 'scattergeo lasso (on robinson projection)'
1232+
);
1233+
})
12151234
.then(function() {
12161235
// make sure selection handlers don't get called in 'pan' dragmode
12171236
return Plotly.relayout(gd, 'dragmode', 'pan');

0 commit comments

Comments
 (0)