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

Skip to content

Commit c47d4f9

Browse files
committed
fix select on ternaryscatter
1 parent 381de10 commit c47d4f9

File tree

2 files changed

+30
-15
lines changed

2 files changed

+30
-15
lines changed

src/plots/cartesian/select.js

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,27 @@ module.exports = function prepSelect(e, startX, startY, dragOptions, mode) {
7171
trace = cd[0].trace;
7272
if(!trace._module || !trace._module.selectPoints) continue;
7373

74-
if(xAxisIds.indexOf(trace.xaxis) === -1) continue;
75-
if(yAxisIds.indexOf(trace.yaxis) === -1) continue;
76-
77-
searchTraces.push({
78-
selectPoints: trace._module.selectPoints,
79-
cd: cd,
80-
xaxis: axes.getFromId(gd, trace.xaxis),
81-
yaxis: axes.getFromId(gd, trace.yaxis)
82-
});
74+
if(dragOptions.subplot) {
75+
if(trace.subplot !== dragOptions.subplot) continue;
76+
77+
searchTraces.push({
78+
selectPoints: trace._module.selectPoints,
79+
cd: cd,
80+
xaxis: dragOptions.xaxes[0],
81+
yaxis: dragOptions.yaxes[0]
82+
});
83+
}
84+
else {
85+
if(xAxisIds.indexOf(trace.xaxis) === -1) continue;
86+
if(yAxisIds.indexOf(trace.yaxis) === -1) continue;
87+
88+
searchTraces.push({
89+
selectPoints: trace._module.selectPoints,
90+
cd: cd,
91+
xaxis: axes.getFromId(gd, trace.xaxis),
92+
yaxis: axes.getFromId(gd, trace.yaxis)
93+
});
94+
}
8395
}
8496

8597
function axValue(ax) {

src/plots/ternary/ternary.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -371,17 +371,20 @@ proto.init_interactions = function() {
371371
var _this = this,
372372
dragger = _this.layers.plotbg.select('path').node(),
373373
gd = _this.graphDiv,
374-
plot = _this.layers.frontplot;
374+
zoomContainer = _this.layers.zoom;
375375

376376
// use plotbg for the main interactions
377377
var dragOptions = {
378378
element: dragger,
379379
gd: gd,
380-
plotinfo: {plot: plot},
381-
xaxes: _this.xaxis,
382-
yaxes: _this.yaxis,
380+
plotinfo: {plot: zoomContainer},
383381
doubleclick: doubleClick,
382+
subplot: _this.id,
384383
prepFn: function(e, startX, startY) {
384+
// these aren't available yet when init_interactions
385+
// is called
386+
dragOptions.xaxes = [_this.xaxis];
387+
dragOptions.yaxes = [_this.yaxis];
385388
var dragModeNow = gd._fullLayout.dragmode;
386389
if(e.shiftKey) {
387390
if(dragModeNow === 'pan') dragModeNow = 'zoom';
@@ -425,15 +428,15 @@ proto.init_interactions = function() {
425428
path0 = 'M0,' + _this.h + 'L' + (_this.w / 2) +', 0L' + _this.w + ',' + _this.h + 'Z';
426429
dimmed = false;
427430

428-
zb = _this.layers.zoom.append('path')
431+
zb = zoomContainer.append('path')
429432
.attr('class', 'zoombox')
430433
.style({
431434
'fill': lum>0.2 ? 'rgba(0,0,0,0)' : 'rgba(255,255,255,0)',
432435
'stroke-width': 0
433436
})
434437
.attr('d', path0);
435438

436-
corners = _this.layers.zoom.append('path')
439+
corners = zoomContainer.append('path')
437440
.attr('class', 'zoombox-corners')
438441
.style({
439442
fill: Plotly.Color.background,

0 commit comments

Comments
 (0)