@@ -59,7 +59,8 @@ function handleAnnotationDefaults(annIn, fullLayout) {
59
59
coerce ( 'arrowwidth' , ( ( borderOpacity && borderWidth ) || 1 ) * 2 ) ;
60
60
coerce ( 'ax' ) ;
61
61
coerce ( 'ay' ) ;
62
- coerce ( 'absolutetail' ) ;
62
+ coerce ( 'axref' ) ;
63
+ coerce ( 'ayref' ) ;
63
64
64
65
// if you have one part of arrow length you should have both
65
66
Lib . noneOrAll ( annIn , annOut , [ 'ax' , 'ay' ] ) ;
@@ -91,7 +92,7 @@ function handleAnnotationDefaults(annIn, fullLayout) {
91
92
newval = Lib . dateTime2ms ( annIn [ axLetter ] ) ;
92
93
if ( newval !== false ) annIn [ axLetter ] = newval ;
93
94
94
- if ( annIn . absolutetail ) {
95
+ if ( annIn [ 'a' + axLetter + 'ref' ] === axRef ) {
95
96
var newvalB = Lib . dateTime2ms ( annIn [ 'a' + axLetter ] ) ;
96
97
if ( newvalB !== false ) annIn [ 'a' + axLetter ] = newvalB ;
97
98
}
@@ -425,8 +426,8 @@ annotations.draw = function(gd, index, opt, value) {
425
426
426
427
var annotationIsOffscreen = false ;
427
428
[ '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 ) ,
430
431
dimAngle = ( textangle + ( axLetter === 'x' ? 0 : 90 ) ) * Math . PI / 180 ,
431
432
annSize = outerwidth * Math . abs ( Math . cos ( dimAngle ) ) +
432
433
outerheight * Math . abs ( Math . sin ( dimAngle ) ) ,
@@ -456,7 +457,7 @@ annotations.draw = function(gd, index, opt, value) {
456
457
}
457
458
458
459
var alignShift = 0 ;
459
- if ( options . absolutetail ) {
460
+ if ( options [ 'a' + axLetter + 'ref' ] === axRef ) {
460
461
annPosPx [ 'aa' + axLetter ] = ax . _offset + ax . l2p ( options [ 'a' + axLetter ] ) ;
461
462
} else {
462
463
if ( options . showarrow ) {
@@ -486,13 +487,15 @@ annotations.draw = function(gd, index, opt, value) {
486
487
// make sure the arrowhead (if there is one)
487
488
// and the annotation center are visible
488
489
if ( options . showarrow ) {
489
- if ( options . absolutetail ) {
490
+ if ( options . axref === options . xref )
490
491
arrowX = Lib . constrain ( annPosPx . x , 1 , fullLayout . width - 1 ) ;
491
- arrowY = Lib . constrain ( annPosPx . y , 1 , fullLayout . height - 1 ) ;
492
- } else {
492
+ else
493
493
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
494
498
arrowY = Lib . constrain ( annPosPx . y - options . ay , 1 , fullLayout . height - 1 ) ;
495
- }
496
499
}
497
500
annPosPx . x = Lib . constrain ( annPosPx . x , 1 , fullLayout . width - 1 ) ;
498
501
annPosPx . y = Lib . constrain ( annPosPx . y , 1 , fullLayout . height - 1 ) ;
@@ -512,13 +515,15 @@ annotations.draw = function(gd, index, opt, value) {
512
515
outerwidth - borderwidth , outerheight - borderwidth ) ;
513
516
514
517
var annX = 0 , annY = 0 ;
515
- if ( options . absolutetail ) {
518
+ if ( options . axref === options . xref )
516
519
annX = Math . round ( annPosPx . aax - outerwidth / 2 ) ;
517
- annY = Math . round ( annPosPx . aay - outerheight / 2 ) ;
518
- } else {
520
+ else
519
521
annX = Math . round ( annPosPx . x - outerwidth / 2 ) ;
522
+
523
+ if ( options . ayref === options . yref )
524
+ annY = Math . round ( annPosPx . aay - outerheight / 2 ) ;
525
+ else
520
526
annY = Math . round ( annPosPx . y - outerheight / 2 ) ;
521
- }
522
527
523
528
ann . call ( Lib . setTranslate , annX , annY ) ;
524
529
@@ -539,13 +544,15 @@ annotations.draw = function(gd, index, opt, value) {
539
544
// how-to-get-the-width-of-an-svg-tspan-element
540
545
var arrowX0 , arrowY0 ;
541
546
542
- if ( options . absolutetail ) {
547
+ if ( options . axref === options . xref )
543
548
arrowX0 = annPosPx . aax + dx ;
544
- arrowY0 = annPosPx . aay + dy ;
545
- } else {
549
+ else
546
550
arrowX0 = annPosPx . x + dx ;
551
+
552
+ if ( options . ayref === options . yref )
553
+ arrowY0 = annPosPx . aay + dy ;
554
+ else
547
555
arrowY0 = annPosPx . y + dy ;
548
- }
549
556
550
557
// create transform matrix and related functions
551
558
var transform =
@@ -648,14 +655,15 @@ annotations.draw = function(gd, index, opt, value) {
648
655
( options . y + dy / ya . _m ) :
649
656
( 1 - ( ( arrowY + dy - gs . t ) / gs . h ) ) ;
650
657
651
- if ( options . absolutetail ) {
658
+ if ( options . axref === options . xref )
652
659
update [ annbase + '.ax' ] = xa ?
653
660
( options . ax + dx / xa . _m ) :
654
661
( ( arrowX + dx - gs . l ) / gs . w ) ;
662
+
663
+ if ( options . ayref === options . yref )
655
664
update [ annbase + '.ay' ] = ya ?
656
665
( options . ay + dy / ya . _m ) :
657
666
( 1 - ( ( arrowY + dy - gs . t ) / gs . h ) ) ;
658
- }
659
667
660
668
anng . attr ( {
661
669
transform : 'rotate(' + textangle + ',' +
@@ -698,13 +706,16 @@ annotations.draw = function(gd, index, opt, value) {
698
706
ann . call ( Lib . setTranslate , x0 + dx , y0 + dy ) ;
699
707
var csr = 'pointer' ;
700
708
if ( options . showarrow ) {
701
- if ( options . absolutetail ) {
709
+ if ( options . axref === options . xref )
702
710
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
705
712
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
706
717
update [ annbase + '.ay' ] = options . ay + dy ;
707
- }
718
+
708
719
drawArrow ( dx , dy ) ;
709
720
}
710
721
else {
0 commit comments