Skip to content

Commit ab92fd2

Browse files
committed
Fix review comments
1 parent 39a4dc4 commit ab92fd2

File tree

2 files changed

+13
-45
lines changed

2 files changed

+13
-45
lines changed

src/plots/cartesian/dragbox.js

-45
Original file line numberDiff line numberDiff line change
@@ -171,31 +171,13 @@ module.exports = function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {
171171
else if(isSelectOrLasso(dragModeNow)) {
172172
dragOptions.xaxes = xa;
173173
dragOptions.yaxes = ya;
174-
175-
// take over selection polygons from prev mode, if any
176-
if((e.shiftKey || e.altKey) && (plotinfo.selection && plotinfo.selection.polygons) && !dragOptions.polygons) {
177-
dragOptions.polygons = plotinfo.selection.polygons;
178-
dragOptions.mergedPolygons = plotinfo.selection.mergedPolygons;
179-
}
180-
// create new polygons, if shift mode
181-
else if((!e.shiftKey && !e.altKey) || ((e.shiftKey || e.altKey) && !plotinfo.selection)) {
182-
plotinfo.selection = {};
183-
plotinfo.selection.polygons = dragOptions.polygons = [];
184-
plotinfo.selection.mergedPolygons = dragOptions.mergedPolygons = [];
185-
}
186-
187174
prepSelect(e, startX, startY, dragOptions, dragModeNow);
188175
}
189176
}
190177
};
191178

192179
dragElement.init(dragOptions);
193180

194-
// FIXME: this hack highlights selection once we enter select/lasso mode
195-
if(isSelectOrLasso(gd._fullLayout.dragmode) && plotinfo.selection) {
196-
showSelect(zoomlayer, dragOptions);
197-
}
198-
199181
var x0,
200182
y0,
201183
box,
@@ -548,8 +530,6 @@ module.exports = function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {
548530

549531
updateSubplots([x0, y0, pw - dx, ph - dy]);
550532

551-
if(plotinfo.ondrag) plotinfo.ondrag.call([x0, y0, pw - dx, ph - dy]);
552-
553533
ticksAndAnnotations(yActive, xActive);
554534
}
555535

@@ -926,31 +906,6 @@ function clearSelect(zoomlayer) {
926906
zoomlayer.selectAll('.select-outline').remove();
927907
}
928908

929-
function showSelect(zoomlayer, dragOptions) {
930-
var outlines = zoomlayer.selectAll('path.select-outline').data([1, 2]),
931-
plotinfo = dragOptions.plotinfo,
932-
xaxis = plotinfo.xaxis,
933-
yaxis = plotinfo.yaxis,
934-
selection = plotinfo.selection,
935-
polygons = selection.mergedPolygons,
936-
xs = xaxis._offset,
937-
ys = yaxis._offset,
938-
paths = [];
939-
940-
for(var i = 0; i < polygons.length; i++) {
941-
var ppts = polygons[i];
942-
paths.push(ppts.join('L') + 'L' + ppts[0]);
943-
}
944-
945-
if(paths.length) {
946-
outlines.enter()
947-
.append('path')
948-
.attr('class', function(d) { return 'select-outline select-outline-' + d; })
949-
.attr('transform', 'translate(' + xs + ', ' + ys + ')')
950-
.attr('d', 'M' + paths.join('M') + 'Z');
951-
}
952-
}
953-
954909
function updateZoombox(zb, corners, box, path0, dimmed, lum) {
955910
zb.attr('d',
956911
path0 + 'M' + (box.l) + ',' + (box.t) + 'v' + (box.h) +

src/plots/cartesian/select.js

+13
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,19 @@ module.exports = function prepSelect(e, startX, startY, dragOptions, mode) {
4444
filterPoly, testPoly, mergedPolygons, currentPolygon,
4545
subtract = e.altKey;
4646

47+
48+
// take over selection polygons from prev mode, if any
49+
if((e.shiftKey || e.altKey) && (plotinfo.selection && plotinfo.selection.polygons) && !dragOptions.polygons) {
50+
dragOptions.polygons = plotinfo.selection.polygons;
51+
dragOptions.mergedPolygons = plotinfo.selection.mergedPolygons;
52+
}
53+
// create new polygons, if shift mode
54+
else if((!e.shiftKey && !e.altKey) || ((e.shiftKey || e.altKey) && !plotinfo.selection)) {
55+
plotinfo.selection = {};
56+
plotinfo.selection.polygons = dragOptions.polygons = [];
57+
plotinfo.selection.mergedPolygons = dragOptions.mergedPolygons = [];
58+
}
59+
4760
if(mode === 'lasso') {
4861
filterPoly = filteredPolygon([[x0, y0]], constants.BENDPX);
4962
}

0 commit comments

Comments
 (0)