Skip to content

Commit aa58118

Browse files
committed
replace forEach with for-loop over ['x', 'y']
1 parent 082bfc1 commit aa58118

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/components/annotations/draw.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,13 @@ function drawOne(gd, index) {
225225
}
226226

227227
var annotationIsOffscreen = false;
228-
['x', 'y'].forEach(function(axLetter) {
229-
var axRef = options[axLetter + 'ref'] || axLetter,
228+
var letters = ['x', 'y'];
229+
230+
for(var i = 0; i < letters.length; i++) {
231+
var axLetter = letters[i],
232+
axRef = options[axLetter + 'ref'] || axLetter,
230233
tailRef = options['a' + axLetter + 'ref'],
231-
ax = Axes.getFromId(gd, axRef),
234+
ax = {x: xa, y: ya}[axLetter],
232235
dimAngle = (textangle + (axLetter === 'x' ? 0 : -90)) * Math.PI / 180,
233236
// note that these two can be either positive or negative
234237
annSizeFromWidth = outerWidth * Math.cos(dimAngle),
@@ -350,7 +353,7 @@ function drawOne(gd, index) {
350353
// size/shift are used during dragging
351354
options['_' + axLetter + 'size'] = annSize;
352355
options['_' + axLetter + 'shift'] = textShift;
353-
});
356+
}
354357

355358
if(annotationIsOffscreen) {
356359
annTextGroupInner.remove();

0 commit comments

Comments
 (0)