Skip to content

Commit fff9c6e

Browse files
authored
Merge pull request #2099 from plotly/invisible-select
Selection on `choropleth` to work even if an invisible trace is present
2 parents 86e7135 + fc0ad56 commit fff9c6e

File tree

7 files changed

+11
-8
lines changed

7 files changed

+11
-8
lines changed

src/plots/cartesian/select.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ module.exports = function prepSelect(e, startX, startY, dragOptions, mode) {
7474
for(i = 0; i < gd.calcdata.length; i++) {
7575
cd = gd.calcdata[i];
7676
trace = cd[0].trace;
77-
if(!trace._module || !trace._module.selectPoints) continue;
77+
if(trace.visible !== true || !trace._module || !trace._module.selectPoints) continue;
7878

7979
if(dragOptions.subplot) {
8080
if(

src/traces/bar/select.js

-3
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,9 @@ var DESELECTDIM = require('../../constants/interactions').DESELECTDIM;
1313
module.exports = function selectPoints(searchInfo, polygon) {
1414
var cd = searchInfo.cd;
1515
var selection = [];
16-
var trace = cd[0].trace;
1716
var node3 = cd[0].node3;
1817
var i;
1918

20-
if(trace.visible !== true) return [];
21-
2219
if(polygon === false) {
2320
// clear selection
2421
for(i = 0; i < cd.length; i++) {

src/traces/scatter/select.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module.exports = function selectPoints(searchInfo, polygon) {
2626

2727
// TODO: include lines? that would require per-segment line properties
2828
var hasOnlyLines = (!subtypes.hasMarkers(trace) && !subtypes.hasText(trace));
29-
if(trace.visible !== true || hasOnlyLines) return [];
29+
if(hasOnlyLines) return [];
3030

3131
var opacity = Array.isArray(marker.opacity) ? 1 : marker.opacity;
3232

src/traces/scattergeo/select.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module.exports = function selectPoints(searchInfo, polygon) {
2222
var di, lonlat, x, y, i;
2323

2424
var hasOnlyLines = (!subtypes.hasMarkers(trace) && !subtypes.hasText(trace));
25-
if(trace.visible !== true || hasOnlyLines) return [];
25+
if(hasOnlyLines) return [];
2626

2727
var marker = trace.marker;
2828
var opacity = Array.isArray(marker.opacity) ? 1 : marker.opacity;

src/traces/scattergl/select.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module.exports = function selectPoints(searchInfo, polygon) {
2626
var scene = glTrace.scene;
2727

2828
var hasOnlyLines = (!subtypes.hasMarkers(trace) && !subtypes.hasText(trace));
29-
if(trace.visible !== true || hasOnlyLines) return [];
29+
if(hasOnlyLines) return [];
3030

3131
// filter out points by visible scatter ones
3232
if(polygon === false) {

src/traces/scattermapbox/select.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module.exports = function selectPoints(searchInfo, polygon) {
2424
// to not insert data-driven 'circle-opacity' when we don't need to
2525
trace._hasDimmedPts = false;
2626

27-
if(trace.visible !== true || !subtypes.hasMarkers(trace)) return [];
27+
if(!subtypes.hasMarkers(trace)) return [];
2828

2929
if(polygon === false) {
3030
for(i = 0; i < cd.length; i++) {

test/jasmine/tests/select_test.js

+6
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,12 @@ describe('Test select box and lasso per trace:', function() {
716716
fig.layout.geo.scope = 'europe';
717717
addInvisible(fig, false);
718718

719+
// add a trace with no locations which will then make trace invisible, lacking DOM elements
720+
fig.data.push(Lib.extendDeep({}, fig.data[0]));
721+
fig.data[1].text = [];
722+
fig.data[1].locations = [];
723+
fig.data[1].z = [];
724+
719725
Plotly.plot(gd, fig)
720726
.then(function() {
721727
return _run(

0 commit comments

Comments
 (0)