diff --git a/src/traces/scattergeo/defaults.js b/src/traces/scattergeo/defaults.js index 5e09810f39f..4d8380d48af 100644 --- a/src/traces/scattergeo/defaults.js +++ b/src/traces/scattergeo/defaults.js @@ -52,6 +52,8 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout if(traceOut.fill !== 'none') { handleFillColorDefaults(traceIn, traceOut, defaultColor, coerce); } + + Lib.coerceSelectionMarkerOpacity(traceOut, coerce); }; function handleLonLatLocDefaults(traceIn, traceOut, coerce) { diff --git a/src/traces/scattergeo/select.js b/src/traces/scattergeo/select.js index 6be13b21e5f..4c11e6c3196 100644 --- a/src/traces/scattergeo/select.js +++ b/src/traces/scattergeo/select.js @@ -9,6 +9,7 @@ 'use strict'; var subtypes = require('../scatter/subtypes'); +var BADNUM = require('../../constants/numerical').BADNUM; module.exports = function selectPoints(searchInfo, polygon) { var cd = searchInfo.cd; @@ -30,6 +31,10 @@ module.exports = function selectPoints(searchInfo, polygon) { for(i = 0; i < cd.length; i++) { di = cd[i]; lonlat = di.lonlat; + + // some projection types can't handle BADNUMs + if(lonlat[0] === BADNUM) continue; + x = xa.c2p(lonlat); y = ya.c2p(lonlat); diff --git a/test/image/baselines/geo_point-selection.png b/test/image/baselines/geo_point-selection.png index c74d0b67fae..d12cc613be6 100644 Binary files a/test/image/baselines/geo_point-selection.png and b/test/image/baselines/geo_point-selection.png differ diff --git a/test/jasmine/tests/select_test.js b/test/jasmine/tests/select_test.js index 7709e0fc0bd..a801c36ddf8 100644 --- a/test/jasmine/tests/select_test.js +++ b/test/jasmine/tests/select_test.js @@ -895,9 +895,9 @@ describe('@flaky Test select box and lasso per trace:', function() { keys.forEach(function(k, j) { var msgFull = msg + 'selected pt ' + i + ' - ' + k + ' val'; - if(typeof e[j] === 'number') { + if(typeof p[k] === 'number' && typeof e[j] === 'number') { expect(p[k]).toBeCloseTo(e[j], 1, msgFull); - } else if(Array.isArray(e[j])) { + } else if(Array.isArray(p[k]) && Array.isArray(e[j])) { expect(p[k]).toBeCloseToArray(e[j], 1, msgFull); } else { expect(p[k]).toBe(e[j], msgFull); @@ -1151,11 +1151,23 @@ describe('@flaky Test select box and lasso per trace:', function() { var assertRanges = makeAssertRanges('geo'); var assertLassoPoints = makeAssertLassoPoints('geo'); + function assertNodeOpacity(exp) { + var traces = d3.select(gd).selectAll('.scatterlayer > .trace'); + expect(traces.size()).toBe(Object.keys(exp).length, 'correct # of trace '); + + traces.each(function(_, i) { + d3.select(this).selectAll('path.point').each(function(_, j) { + expect(Number(this.style.opacity)) + .toBe(exp[i][j], 'node opacity - trace ' + i + ' pt ' + j); + }); + }); + } + var fig = { data: [{ type: 'scattergeo', - lon: [10, 20, 30], - lat: [10, 20, 30] + lon: [10, 20, 30, null], + lat: [10, 20, 30, null] }, { type: 'scattergeo', lon: [-10, -20, -30], @@ -1177,6 +1189,7 @@ describe('@flaky Test select box and lasso per trace:', function() { function() { assertPoints([[10, 10], [20, 20], [-10, 10], [-20, 20]]); assertSelectedPoints({0: [0, 1], 1: [0, 1]}); + assertNodeOpacity({0: [1, 1, 0.2], 1: [1, 1, 0.2]}); assertRanges([[-28.13, 61.88], [28.13, -50.64]]); }, null, BOXEVENTS, 'scattergeo select' @@ -1191,6 +1204,7 @@ describe('@flaky Test select box and lasso per trace:', function() { function() { assertPoints([[-10, 10], [-20, 20], [-30, 30]]); assertSelectedPoints({0: [], 1: [0, 1, 2]}); + assertNodeOpacity({0: [0.2, 0.2, 0.2], 1: [1, 1, 1]}); assertLassoPoints([ [-56.25, 61.88], [-56.24, 5.63], [0, 5.63], [0, 61.88], [-56.25, 61.88] ]); @@ -1198,6 +1212,25 @@ describe('@flaky Test select box and lasso per trace:', function() { null, LASSOEVENTS, 'scattergeo lasso' ); }) + .then(function() { + // some projection types can't handle BADNUM during c2p, + // make they are skipped here + return Plotly.relayout(gd, 'geo.projection.type', 'robinson'); + }) + .then(function() { + return _run( + [[300, 200], [300, 300], [400, 300], [400, 200], [300, 200]], + function() { + assertPoints([[-10, 10], [-20, 20], [-30, 30]]); + assertSelectedPoints({0: [], 1: [0, 1, 2]}); + assertNodeOpacity({0: [0.2, 0.2, 0.2], 1: [1, 1, 1]}); + assertLassoPoints([ + [-67.40, 55.07], [-56.33, 4.968], [0, 4.968], [0, 55.07], [-67.40, 55.07] + ]); + }, + null, LASSOEVENTS, 'scattergeo lasso (on robinson projection)' + ); + }) .then(function() { // make sure selection handlers don't get called in 'pan' dragmode return Plotly.relayout(gd, 'dragmode', 'pan');