Skip to content

Selection on choropleth to work even if an invisible trace is present #2099

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/plots/cartesian/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ module.exports = function prepSelect(e, startX, startY, dragOptions, mode) {
for(i = 0; i < gd.calcdata.length; i++) {
cd = gd.calcdata[i];
trace = cd[0].trace;
if(!trace._module || !trace._module.selectPoints) continue;
if(trace.visible !== true || !trace._module || !trace._module.selectPoints) continue;

if(dragOptions.subplot) {
if(
Expand Down
3 changes: 0 additions & 3 deletions src/traces/bar/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,9 @@ var DESELECTDIM = require('../../constants/interactions').DESELECTDIM;
module.exports = function selectPoints(searchInfo, polygon) {
var cd = searchInfo.cd;
var selection = [];
var trace = cd[0].trace;
var node3 = cd[0].node3;
var i;

if(trace.visible !== true) return [];

if(polygon === false) {
// clear selection
for(i = 0; i < cd.length; i++) {
Expand Down
2 changes: 1 addition & 1 deletion src/traces/scatter/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = function selectPoints(searchInfo, polygon) {

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

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

Expand Down
2 changes: 1 addition & 1 deletion src/traces/scattergeo/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = function selectPoints(searchInfo, polygon) {
var di, lonlat, x, y, i;

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

var marker = trace.marker;
var opacity = Array.isArray(marker.opacity) ? 1 : marker.opacity;
Expand Down
2 changes: 1 addition & 1 deletion src/traces/scattergl/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = function selectPoints(searchInfo, polygon) {
var scene = glTrace.scene;

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

// filter out points by visible scatter ones
if(polygon === false) {
Expand Down
2 changes: 1 addition & 1 deletion src/traces/scattermapbox/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module.exports = function selectPoints(searchInfo, polygon) {
// to not insert data-driven 'circle-opacity' when we don't need to
trace._hasDimmedPts = false;

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

if(polygon === false) {
for(i = 0; i < cd.length; i++) {
Expand Down
6 changes: 6 additions & 0 deletions test/jasmine/tests/select_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,12 @@ describe('Test select box and lasso per trace:', function() {
fig.layout.dragmode = 'select';
fig.layout.geo.scope = 'europe';

// add a trace with no locations which will then make trace invisible, lacking DOM elements
fig.data.push(Lib.extendDeep({}, fig.data[0]));
fig.data[1].text = [];
fig.data[1].locations = [];
fig.data[1].z = [];

Plotly.plot(gd, fig)
.then(function() {
return _run(
Expand Down