@@ -59,7 +59,8 @@ function handleAnnotationDefaults(annIn, fullLayout) {
5959 coerce ( 'arrowwidth' , ( ( borderOpacity && borderWidth ) || 1 ) * 2 ) ;
6060 coerce ( 'ax' ) ;
6161 coerce ( 'ay' ) ;
62- coerce ( 'absolutetail' ) ;
62+ coerce ( 'axref' ) ;
63+ coerce ( 'ayref' ) ;
6364
6465 // if you have one part of arrow length you should have both
6566 Lib . noneOrAll ( annIn , annOut , [ 'ax' , 'ay' ] ) ;
@@ -91,7 +92,7 @@ function handleAnnotationDefaults(annIn, fullLayout) {
9192 newval = Lib . dateTime2ms ( annIn [ axLetter ] ) ;
9293 if ( newval !== false ) annIn [ axLetter ] = newval ;
9394
94- if ( annIn . absolutetail ) {
95+ if ( annIn [ 'a' + axLetter + 'ref' ] === axRef ) {
9596 var newvalB = Lib . dateTime2ms ( annIn [ 'a' + axLetter ] ) ;
9697 if ( newvalB !== false ) annIn [ 'a' + axLetter ] = newvalB ;
9798 }
@@ -425,8 +426,8 @@ annotations.draw = function(gd, index, opt, value) {
425426
426427 var annotationIsOffscreen = false ;
427428 [ 'x' , 'y' ] . forEach ( function ( axLetter ) {
428- var ax = Axes . getFromId ( gd ,
429- options [ axLetter + 'ref' ] || axLetter ) ,
429+ var axRef = options [ axLetter + 'ref' ] || axLetter ,
430+ ax = Axes . getFromId ( gd , axRef ) ,
430431 dimAngle = ( textangle + ( axLetter === 'x' ? 0 : 90 ) ) * Math . PI / 180 ,
431432 annSize = outerwidth * Math . abs ( Math . cos ( dimAngle ) ) +
432433 outerheight * Math . abs ( Math . sin ( dimAngle ) ) ,
@@ -456,7 +457,7 @@ annotations.draw = function(gd, index, opt, value) {
456457 }
457458
458459 var alignShift = 0 ;
459- if ( options . absolutetail ) {
460+ if ( options [ 'a' + axLetter + 'ref' ] === axRef ) {
460461 annPosPx [ 'aa' + axLetter ] = ax . _offset + ax . l2p ( options [ 'a' + axLetter ] ) ;
461462 } else {
462463 if ( options . showarrow ) {
@@ -486,13 +487,15 @@ annotations.draw = function(gd, index, opt, value) {
486487 // make sure the arrowhead (if there is one)
487488 // and the annotation center are visible
488489 if ( options . showarrow ) {
489- if ( options . absolutetail ) {
490+ if ( options . axref === options . xref )
490491 arrowX = Lib . constrain ( annPosPx . x , 1 , fullLayout . width - 1 ) ;
491- arrowY = Lib . constrain ( annPosPx . y , 1 , fullLayout . height - 1 ) ;
492- } else {
492+ else
493493 arrowX = Lib . constrain ( annPosPx . x - options . ax , 1 , fullLayout . width - 1 ) ;
494+
495+ if ( options . ayref === options . yref )
496+ arrowY = Lib . constrain ( annPosPx . y , 1 , fullLayout . height - 1 ) ;
497+ else
494498 arrowY = Lib . constrain ( annPosPx . y - options . ay , 1 , fullLayout . height - 1 ) ;
495- }
496499 }
497500 annPosPx . x = Lib . constrain ( annPosPx . x , 1 , fullLayout . width - 1 ) ;
498501 annPosPx . y = Lib . constrain ( annPosPx . y , 1 , fullLayout . height - 1 ) ;
@@ -512,13 +515,15 @@ annotations.draw = function(gd, index, opt, value) {
512515 outerwidth - borderwidth , outerheight - borderwidth ) ;
513516
514517 var annX = 0 , annY = 0 ;
515- if ( options . absolutetail ) {
518+ if ( options . axref === options . xref )
516519 annX = Math . round ( annPosPx . aax - outerwidth / 2 ) ;
517- annY = Math . round ( annPosPx . aay - outerheight / 2 ) ;
518- } else {
520+ else
519521 annX = Math . round ( annPosPx . x - outerwidth / 2 ) ;
522+
523+ if ( options . ayref === options . yref )
524+ annY = Math . round ( annPosPx . aay - outerheight / 2 ) ;
525+ else
520526 annY = Math . round ( annPosPx . y - outerheight / 2 ) ;
521- }
522527
523528 ann . call ( Lib . setTranslate , annX , annY ) ;
524529
@@ -539,13 +544,15 @@ annotations.draw = function(gd, index, opt, value) {
539544 // how-to-get-the-width-of-an-svg-tspan-element
540545 var arrowX0 , arrowY0 ;
541546
542- if ( options . absolutetail ) {
547+ if ( options . axref === options . xref )
543548 arrowX0 = annPosPx . aax + dx ;
544- arrowY0 = annPosPx . aay + dy ;
545- } else {
549+ else
546550 arrowX0 = annPosPx . x + dx ;
551+
552+ if ( options . ayref === options . yref )
553+ arrowY0 = annPosPx . aay + dy ;
554+ else
547555 arrowY0 = annPosPx . y + dy ;
548- }
549556
550557 // create transform matrix and related functions
551558 var transform =
@@ -648,14 +655,15 @@ annotations.draw = function(gd, index, opt, value) {
648655 ( options . y + dy / ya . _m ) :
649656 ( 1 - ( ( arrowY + dy - gs . t ) / gs . h ) ) ;
650657
651- if ( options . absolutetail ) {
658+ if ( options . axref === options . xref )
652659 update [ annbase + '.ax' ] = xa ?
653660 ( options . ax + dx / xa . _m ) :
654661 ( ( arrowX + dx - gs . l ) / gs . w ) ;
662+
663+ if ( options . ayref === options . yref )
655664 update [ annbase + '.ay' ] = ya ?
656665 ( options . ay + dy / ya . _m ) :
657666 ( 1 - ( ( arrowY + dy - gs . t ) / gs . h ) ) ;
658- }
659667
660668 anng . attr ( {
661669 transform : 'rotate(' + textangle + ',' +
@@ -698,13 +706,16 @@ annotations.draw = function(gd, index, opt, value) {
698706 ann . call ( Lib . setTranslate , x0 + dx , y0 + dy ) ;
699707 var csr = 'pointer' ;
700708 if ( options . showarrow ) {
701- if ( options . absolutetail ) {
709+ if ( options . axref === options . xref )
702710 update [ annbase + '.ax' ] = xa . p2l ( xa . l2p ( options . ax ) + dx ) ;
703- update [ annbase + '.ay' ] = ya . p2l ( ya . l2p ( options . ay ) + dy ) ;
704- } else {
711+ else
705712 update [ annbase + '.ax' ] = options . ax + dx ;
713+
714+ if ( options . ayref === options . yref )
715+ update [ annbase + '.ay' ] = ya . p2l ( ya . l2p ( options . ay ) + dy ) ;
716+ else
706717 update [ annbase + '.ay' ] = options . ay + dy ;
707- }
718+
708719 drawArrow ( dx , dy ) ;
709720 }
710721 else {
0 commit comments