@@ -78,7 +78,8 @@ 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 , optAx , dAx , gsDim , vertical , axDomainRef ) {
81+ function shiftPosition ( axa , optAx , dAx , gsDim , vertical , axRef ) {
82+ var axDomainRef = Axes . getRefType ( axRef ) === 'domain' ;
8283 if ( axa ) {
8384 if ( axDomainRef ) {
8485 // here optAx normalized to length of axis (e.g., normally in range
@@ -339,20 +340,17 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
339340 basePx = ax . _offset + ax . r2p ( options [ axLetter ] ) ;
340341 autoAlignFraction = 0.5 ;
341342 } else {
343+ var axRefTypeEqDomain = axRefType === 'domain' ;
342344 if ( axLetter === 'x' ) {
343345 alignPosition = options [ axLetter ] ;
344- if ( axRefType === 'domain' ) {
345- basePx = ax . _offset + ax . _length * alignPosition ;
346- } else {
346+ basePx = axRefTypeEqDomain ?
347+ ax . _offset + ax . _length * alignPosition :
347348 basePx = gs . l + gs . w * alignPosition ;
348- }
349349 } else {
350350 alignPosition = 1 - options [ axLetter ] ;
351- if ( axRefType === 'domain' ) {
352- basePx = ax . _offset + ax . _length * alignPosition ;
353- } else {
351+ basePx = axRefTypeEqDomain ?
352+ ax . _offset + ax . _length * alignPosition :
354353 basePx = gs . t + gs . h * alignPosition ;
355- }
356354 }
357355 autoAlignFraction = options . showarrow ? 0.5 : alignPosition ;
358356 }
@@ -612,24 +610,22 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
612610 var ycenter = annxy0 [ 1 ] + dy ;
613611 annTextGroupInner . call ( Drawing . setTranslate , xcenter , ycenter ) ;
614612
615- var xRefType = Axes . getRefType ( options . xref ) ;
616- var yRefType = Axes . getRefType ( options . yref ) ;
617613 modifyItem ( 'x' ,
618- shiftPosition ( xa , options . x , dx , gs . w , false , xRefType === 'domain' ) ) ;
614+ shiftPosition ( xa , options . x , dx , gs . w , false , options . xref ) ) ;
619615 modifyItem ( 'y' ,
620- shiftPosition ( ya , options . y , dy , gs . h , true , yRefType === 'domain' ) ) ;
616+ shiftPosition ( ya , options . y , dy , gs . h , true , options . yref ) ) ;
621617
622618 // for these 2 calls to shiftPosition, it is assumed xa, ya are
623619 // defined, so gsDim will not be used, but we put it in
624620 // anyways for consistency
625621 if ( options . axref === options . xref ) {
626622 modifyItem ( 'ax' , shiftPosition ( xa , options . ax , dx , gs . w , false ,
627- xRefType === 'domain' ) ) ;
623+ options . xref ) ) ;
628624 }
629625
630626 if ( options . ayref === options . yref ) {
631627 modifyItem ( 'ay' , shiftPosition ( ya , options . ay , dy , gs . h , true ,
632- yRefType === 'domain' ) ) ;
628+ options . yref ) ) ;
633629 }
634630
635631 arrowGroup . attr ( 'transform' , 'translate(' + dx + ',' + dy + ')' ) ;
@@ -663,22 +659,20 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
663659 } ,
664660 moveFn : function ( dx , dy ) {
665661 var csr = 'pointer' ;
666- var xRefType = Axes . getRefType ( options . xref ) ;
667- var yRefType = Axes . getRefType ( options . yref ) ;
668662 if ( options . showarrow ) {
669663 // for these 2 calls to shiftPosition, it is assumed xa, ya are
670664 // defined, so gsDim will not be used, but we put it in
671665 // anyways for consistency
672666 if ( options . axref === options . xref ) {
673667 modifyItem ( 'ax' , shiftPosition ( xa , options . ax , dx , gs . h , false ,
674- xRefType === 'domain' ) ) ;
668+ options . xref ) ) ;
675669 } else {
676670 modifyItem ( 'ax' , options . ax + dx ) ;
677671 }
678672
679673 if ( options . ayref === options . yref ) {
680674 modifyItem ( 'ay' , shiftPosition ( ya , options . ay , dy , gs . w , true ,
681- yRefType === 'domain' ) ) ;
675+ options . yref ) ) ;
682676 } else {
683677 modifyItem ( 'ay' , options . ay + dy ) ;
684678 }
@@ -690,7 +684,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
690684 // shiftPosition will not execute code where xa was
691685 // undefined, so we use to calculate xUpdate too
692686 xUpdate = shiftPosition ( xa , options . x , dx , gs . h , false ,
693- xRefType === 'domain' ) ;
687+ options . xref ) ;
694688 } else {
695689 var widthFraction = options . _xsize / gs . w ;
696690 var xLeft = options . x + ( options . _xshift - options . xshift ) / gs . w - widthFraction / 2 ;
@@ -703,7 +697,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
703697 // shiftPosition will not execute code where ya was
704698 // undefined, so we use to calculate yUpdate too
705699 yUpdate = shiftPosition ( ya , options . y , dy , gs . w , true ,
706- yRefType === 'domain' ) ;
700+ options . yref ) ;
707701 } else {
708702 var heightFraction = options . _ysize / gs . h ;
709703 var yBottom = options . y - ( options . _yshift + options . yshift ) / gs . h - heightFraction / 2 ;
0 commit comments