@@ -78,8 +78,12 @@ function drawOne(gd, index) {
78
78
// the plot.
79
79
// axDomainRef: if true and axa defined, draws relative to axis domain,
80
80
// otherwise draws relative to data (if axa defined) or paper (if not).
81
- function shiftPosition ( axa , optAx , dAx , gsDim , vertical , axRef ) {
81
+ function shiftPosition ( axa , options , dAx , axLetter , gs ) {
82
+ var optAx = options [ axLetter ] ;
83
+ var axRef = options [ axLetter + 'ref' ] ;
84
+ var vertical = axLetter . includes ( 'y' ) ;
82
85
var axDomainRef = Axes . getRefType ( axRef ) === 'domain' ;
86
+ var gsDim = vertical ? gs . h : gs . w ;
83
87
if ( axa ) {
84
88
if ( axDomainRef ) {
85
89
// here optAx normalized to length of axis (e.g., normally in range
@@ -611,21 +615,19 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
611
615
annTextGroupInner . call ( Drawing . setTranslate , xcenter , ycenter ) ;
612
616
613
617
modifyItem ( 'x' ,
614
- shiftPosition ( xa , options . x , dx , gs . w , false , options . xref ) ) ;
618
+ shiftPosition ( xa , options , dx , 'x' , gs ) ) ;
615
619
modifyItem ( 'y' ,
616
- shiftPosition ( ya , options . y , dy , gs . h , true , options . yref ) ) ;
620
+ shiftPosition ( ya , options , dy , 'y' , gs ) ) ;
617
621
618
622
// for these 2 calls to shiftPosition, it is assumed xa, ya are
619
623
// defined, so gsDim will not be used, but we put it in
620
624
// anyways for consistency
621
625
if ( options . axref === options . xref ) {
622
- modifyItem ( 'ax' , shiftPosition ( xa , options . ax , dx , gs . w , false ,
623
- options . xref ) ) ;
626
+ modifyItem ( 'ax' , shiftPosition ( xa , options , dx , 'ax' , gs ) ) ;
624
627
}
625
628
626
629
if ( options . ayref === options . yref ) {
627
- modifyItem ( 'ay' , shiftPosition ( ya , options . ay , dy , gs . h , true ,
628
- options . yref ) ) ;
630
+ modifyItem ( 'ay' , shiftPosition ( ya , options , dy , 'ay' , gs ) ) ;
629
631
}
630
632
631
633
arrowGroup . attr ( 'transform' , 'translate(' + dx + ',' + dy + ')' ) ;
@@ -664,15 +666,13 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
664
666
// defined, so gsDim will not be used, but we put it in
665
667
// anyways for consistency
666
668
if ( options . axref === options . xref ) {
667
- modifyItem ( 'ax' , shiftPosition ( xa , options . ax , dx , gs . h , false ,
668
- options . xref ) ) ;
669
+ modifyItem ( 'ax' , shiftPosition ( xa , options , dx , 'ax' , gs ) ) ;
669
670
} else {
670
671
modifyItem ( 'ax' , options . ax + dx ) ;
671
672
}
672
673
673
674
if ( options . ayref === options . yref ) {
674
- modifyItem ( 'ay' , shiftPosition ( ya , options . ay , dy , gs . w , true ,
675
- options . yref ) ) ;
675
+ modifyItem ( 'ay' , shiftPosition ( ya , options , dy , 'ay' , gs . w ) ) ;
676
676
} else {
677
677
modifyItem ( 'ay' , options . ay + dy ) ;
678
678
}
@@ -683,8 +683,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
683
683
if ( xa ) {
684
684
// shiftPosition will not execute code where xa was
685
685
// undefined, so we use to calculate xUpdate too
686
- xUpdate = shiftPosition ( xa , options . x , dx , gs . h , false ,
687
- options . xref ) ;
686
+ xUpdate = shiftPosition ( xa , options , dx , 'x' , gs ) ;
688
687
} else {
689
688
var widthFraction = options . _xsize / gs . w ;
690
689
var xLeft = options . x + ( options . _xshift - options . xshift ) / gs . w - widthFraction / 2 ;
@@ -696,8 +695,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
696
695
if ( ya ) {
697
696
// shiftPosition will not execute code where ya was
698
697
// undefined, so we use to calculate yUpdate too
699
- yUpdate = shiftPosition ( ya , options . y , dy , gs . w , true ,
700
- options . yref ) ;
698
+ yUpdate = shiftPosition ( ya , options , dy , 'y' , gs ) ;
701
699
} else {
702
700
var heightFraction = options . _ysize / gs . h ;
703
701
var yBottom = options . y - ( options . _yshift + options . yshift ) / gs . h - heightFraction / 2 ;
0 commit comments