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

Skip to content

Commit 40fbca9

Browse files
committed
Avoid overcalculation
1 parent 05b0dca commit 40fbca9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/plots/cartesian/select.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@ module.exports = function prepSelect(e, startX, startY, dragOptions, mode) {
158158
currentPolygon.ymin = Math.min(0, ph);
159159
currentPolygon.ymax = Math.max(0, ph);
160160
// extras to guide users in keeping a straight selection
161-
corners.attr('d', 'M' + Math.min(x0, x1) + ',' + (y0 - MINSELECT) +
161+
corners.attr('d', 'M' + currentPolygon.xmin + ',' + (y0 - MINSELECT) +
162162
'h-4v' + (2 * MINSELECT) + 'h4Z' +
163-
'M' + (Math.max(x0, x1) - 1) + ',' + (y0 - MINSELECT) +
163+
'M' + (currentPolygon.xmax - 1) + ',' + (y0 - MINSELECT) +
164164
'h4v' + (2 * MINSELECT) + 'h-4Z');
165165

166166
}
@@ -171,9 +171,9 @@ module.exports = function prepSelect(e, startX, startY, dragOptions, mode) {
171171
currentPolygon.xmax = Math.max(0, pw);
172172
currentPolygon.ymin = Math.min(y0, y1);
173173
currentPolygon.ymax = Math.max(y0, y1);
174-
corners.attr('d', 'M' + (x0 - MINSELECT) + ',' + Math.min(y0, y1) +
174+
corners.attr('d', 'M' + (x0 - MINSELECT) + ',' + currentPolygon.ymin +
175175
'v-4h' + (2 * MINSELECT) + 'v4Z' +
176-
'M' + (x0 - MINSELECT) + ',' + (Math.max(y0, y1) - 1) +
176+
'M' + (x0 - MINSELECT) + ',' + (currentPolygon.ymax - 1) +
177177
'v4h' + (2 * MINSELECT) + 'v-4Z');
178178
}
179179
else {

0 commit comments

Comments
 (0)