Skip to content

Commit 759d37b

Browse files
Changed order of arguments to shiftPosition
Also avoided using String.includes.
1 parent 35ab9da commit 759d37b

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/components/annotations/draw.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ function drawOne(gd, index) {
7878
// the plot.
7979
// axDomainRef: if true and axa defined, draws relative to axis domain,
8080
// otherwise draws relative to data (if axa defined) or paper (if not).
81-
function shiftPosition(axa, options, dAx, axLetter, gs) {
81+
function shiftPosition(axa, dAx, axLetter, gs, options) {
8282
var optAx = options[axLetter];
8383
var axRef = options[axLetter + 'ref'];
84-
var vertical = axLetter.includes('y');
84+
var vertical = axLetter.indexOf('y') !== -1;
8585
var axDomainRef = Axes.getRefType(axRef) === 'domain';
8686
var gsDim = vertical ? gs.h : gs.w;
8787
if(axa) {
@@ -615,19 +615,19 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
615615
annTextGroupInner.call(Drawing.setTranslate, xcenter, ycenter);
616616

617617
modifyItem('x',
618-
shiftPosition(xa, options, dx, 'x', gs));
618+
shiftPosition(xa, dx, 'x', gs, options));
619619
modifyItem('y',
620-
shiftPosition(ya, options, dy, 'y', gs));
620+
shiftPosition(ya, dy, 'y', gs, options));
621621

622622
// for these 2 calls to shiftPosition, it is assumed xa, ya are
623623
// defined, so gsDim will not be used, but we put it in
624624
// anyways for consistency
625625
if(options.axref === options.xref) {
626-
modifyItem('ax', shiftPosition(xa, options, dx, 'ax', gs));
626+
modifyItem('ax', shiftPosition(xa, dx, 'ax', gs, options));
627627
}
628628

629629
if(options.ayref === options.yref) {
630-
modifyItem('ay', shiftPosition(ya, options, dy, 'ay', gs));
630+
modifyItem('ay', shiftPosition(ya, dy, 'ay', gs, options));
631631
}
632632

633633
arrowGroup.attr('transform', 'translate(' + dx + ',' + dy + ')');
@@ -666,13 +666,13 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
666666
// defined, so gsDim will not be used, but we put it in
667667
// anyways for consistency
668668
if(options.axref === options.xref) {
669-
modifyItem('ax', shiftPosition(xa, options, dx, 'ax', gs));
669+
modifyItem('ax', shiftPosition(xa, dx, 'ax', gs, options));
670670
} else {
671671
modifyItem('ax', options.ax + dx);
672672
}
673673

674674
if(options.ayref === options.yref) {
675-
modifyItem('ay', shiftPosition(ya, options, dy, 'ay', gs.w));
675+
modifyItem('ay', shiftPosition(ya, dy, 'ay', gs.w, options));
676676
} else {
677677
modifyItem('ay', options.ay + dy);
678678
}
@@ -683,7 +683,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
683683
if(xa) {
684684
// shiftPosition will not execute code where xa was
685685
// undefined, so we use to calculate xUpdate too
686-
xUpdate = shiftPosition(xa, options, dx, 'x', gs);
686+
xUpdate = shiftPosition(xa, dx, 'x', gs, options);
687687
} else {
688688
var widthFraction = options._xsize / gs.w;
689689
var xLeft = options.x + (options._xshift - options.xshift) / gs.w - widthFraction / 2;
@@ -695,7 +695,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
695695
if(ya) {
696696
// shiftPosition will not execute code where ya was
697697
// undefined, so we use to calculate yUpdate too
698-
yUpdate = shiftPosition(ya, options, dy, 'y', gs);
698+
yUpdate = shiftPosition(ya, dy, 'y', gs, options);
699699
} else {
700700
var heightFraction = options._ysize / gs.h;
701701
var yBottom = options.y - (options._yshift + options.yshift) / gs.h - heightFraction / 2;

0 commit comments

Comments
 (0)