Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b703a9c

Browse files
committed
Consider subplot when determining traces for click-to-select [1852]
1 parent 0840100 commit b703a9c

File tree

1 file changed

+8
-20
lines changed

1 file changed

+8
-20
lines changed

src/plots/cartesian/select.js

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ function prepSelect(e, startX, startY, dragOptions, mode) {
108108
var throttleID = fullLayout._uid + constants.SELECTID;
109109

110110
// find the traces to search for selection points
111-
var searchTraces = determineSearchTraces(gd, dragOptions.xaxes, dragOptions.yaxes);
111+
var searchTraces = determineSearchTraces(gd, dragOptions.xaxes, dragOptions.yaxes, dragOptions.subplot);
112112

113113
function axValue(ax) {
114114
var index = (ax._id.charAt(0) === 'y') ? 1 : 0;
@@ -292,7 +292,7 @@ function prepSelect(e, startX, startY, dragOptions, mode) {
292292
}
293293
else {
294294
// TODO What to do with the code below because we now have behavior for a single click
295-
selectOnClick(gd, numClicks, evt, dragOptions.xaxes, dragOptions.yaxes, outlines);
295+
selectOnClick(gd, numClicks, evt, dragOptions.xaxes, dragOptions.yaxes, outlines, dragOptions.subplot);
296296

297297
// TODO: remove in v2 - this was probably never intended to work as it does,
298298
// but in case anyone depends on it we don't want to break it now.
@@ -327,7 +327,7 @@ function prepSelect(e, startX, startY, dragOptions, mode) {
327327
// ----------------
328328
// TODO handle clearing selection when no point is clicked (based on hoverData)
329329
// TODO remove console.log statements
330-
function selectOnClick(gd, numClicks, evt, xAxes, yAxes, outlines) {
330+
function selectOnClick(gd, numClicks, evt, xAxes, yAxes, outlines, subplot) {
331331
var hoverData = gd._hoverdata;
332332
var retainSelection = shouldRetainSelection(evt);
333333
var searchTraces;
@@ -346,7 +346,7 @@ function selectOnClick(gd, numClicks, evt, xAxes, yAxes, outlines) {
346346
if(numClicks === 1 && isHoverDataSet(hoverData)) {
347347
allSelectionItems = [];
348348

349-
searchTraces = determineSearchTraces(gd, xAxes, yAxes);
349+
searchTraces = determineSearchTraces(gd, xAxes, yAxes, subplot);
350350
clearEntireSelection = entireSelectionToBeCleared(searchTraces, hoverData);
351351

352352
for(i = 0; i < searchTraces.length; i++) {
@@ -450,7 +450,7 @@ function selectOnClick(gd, numClicks, evt, xAxes, yAxes, outlines) {
450450
}
451451
}
452452

453-
function determineSearchTraces(gd, xAxes, yAxes) {
453+
function determineSearchTraces(gd, xAxes, yAxes, subplot) {
454454
var searchTraces = [];
455455
var xAxisIds = xAxes.map(getAxId);
456456
var yAxisIds = yAxes.map(getAxId);
@@ -464,21 +464,9 @@ function determineSearchTraces(gd, xAxes, yAxes) {
464464

465465
if(trace.visible !== true || !trace._module || !trace._module.selectable) continue;
466466

467-
// TODO is dragOptions.subplot is ever set? If not, delete.
468-
// if(dragOptions.subplot) {
469-
// if(
470-
// trace.subplot === dragOptions.subplot ||
471-
// trace.geo === dragOptions.subplot
472-
// ) {
473-
// searchTraces.push({
474-
// _module: trace._module,
475-
// cd: cd,
476-
// xaxis: xAxes[0],
477-
// yaxis: yAxes[0]
478-
// });
479-
// }
480-
// } else if(
481-
if(
467+
if(subplot && (trace.subplot === subplot || trace.geo === subplot)) {
468+
searchTraces.push(createSearchInfo(trace._module, cd, xAxes[0], yAxes[0]));
469+
} else if(
482470
trace.type === 'splom' &&
483471
// FIXME: make sure we don't have more than single axis for splom
484472
trace._xaxes[xAxisIds[0]] && trace._yaxes[yAxisIds[0]]

0 commit comments

Comments
 (0)