@@ -117,8 +117,8 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
117
117
118
118
// calculated pixel positions
119
119
// x & y each will get text, head, and tail as appropriate
120
- var annPosPx = { x : { } , y : { } } ,
121
- textangle = + options . textangle || 0 ;
120
+ var annPosPx = { x : { } , y : { } } ;
121
+ var textangle = + options . textangle || 0 ;
122
122
123
123
// create the components
124
124
// made a single group to contain all, so opacity can work right
@@ -185,9 +185,9 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
185
185
} ) ;
186
186
}
187
187
188
- var borderwidth = options . borderwidth ,
189
- borderpad = options . borderpad ,
190
- borderfull = borderwidth + borderpad ;
188
+ var borderwidth = options . borderwidth ;
189
+ var borderpad = options . borderpad ;
190
+ var borderfull = borderwidth + borderpad ;
191
191
192
192
var annTextBG = annTextGroupInner . append ( 'rect' )
193
193
. attr ( 'class' , 'bg' )
@@ -270,24 +270,24 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
270
270
var letters = [ 'x' , 'y' ] ;
271
271
272
272
for ( var i = 0 ; i < letters . length ; i ++ ) {
273
- var axLetter = letters [ i ] ,
274
- axRef = options [ axLetter + 'ref' ] || axLetter ,
275
- tailRef = options [ 'a' + axLetter + 'ref' ] ,
276
- ax = { x : xa , y : ya } [ axLetter ] ,
277
- dimAngle = ( textangle + ( axLetter === 'x' ? 0 : - 90 ) ) * Math . PI / 180 ,
278
- // note that these two can be either positive or negative
279
- annSizeFromWidth = outerWidth * Math . cos ( dimAngle ) ,
280
- annSizeFromHeight = outerHeight * Math . sin ( dimAngle ) ,
281
- // but this one is the positive total size
282
- annSize = Math . abs ( annSizeFromWidth ) + Math . abs ( annSizeFromHeight ) ,
283
- anchor = options [ axLetter + 'anchor' ] ,
284
- overallShift = options [ axLetter + 'shift' ] * ( axLetter === 'x' ? 1 : - 1 ) ,
285
- posPx = annPosPx [ axLetter ] ,
286
- basePx ,
287
- textPadShift ,
288
- alignPosition ,
289
- autoAlignFraction ,
290
- textShift ;
273
+ var axLetter = letters [ i ] ;
274
+ var axRef = options [ axLetter + 'ref' ] || axLetter ;
275
+ var tailRef = options [ 'a' + axLetter + 'ref' ] ;
276
+ var ax = { x : xa , y : ya } [ axLetter ] ;
277
+ var dimAngle = ( textangle + ( axLetter === 'x' ? 0 : - 90 ) ) * Math . PI / 180 ;
278
+ // note that these two can be either positive or negative
279
+ var annSizeFromWidth = outerWidth * Math . cos ( dimAngle ) ;
280
+ var annSizeFromHeight = outerHeight * Math . sin ( dimAngle ) ;
281
+ // but this one is the positive total size
282
+ var annSize = Math . abs ( annSizeFromWidth ) + Math . abs ( annSizeFromHeight ) ;
283
+ var anchor = options [ axLetter + 'anchor' ] ;
284
+ var overallShift = options [ axLetter + 'shift' ] * ( axLetter === 'x' ? 1 : - 1 ) ;
285
+ var posPx = annPosPx [ axLetter ] ;
286
+ var basePx ;
287
+ var textPadShift ;
288
+ var alignPosition ;
289
+ var autoAlignFraction ;
290
+ var textShift ;
291
291
292
292
/*
293
293
* calculate the *primary* pixel position
@@ -353,8 +353,8 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
353
353
posPx . head = Lib . constrain ( posPx . head , 1 , maxPx - 1 ) ;
354
354
}
355
355
if ( tailRef === 'pixel' ) {
356
- var shiftPlus = - Math . max ( posPx . tail - 3 , posPx . text ) ,
357
- shiftMinus = Math . min ( posPx . tail + 3 , posPx . text ) - maxPx ;
356
+ var shiftPlus = - Math . max ( posPx . tail - 3 , posPx . text ) ;
357
+ var shiftMinus = Math . min ( posPx . tail + 3 , posPx . text ) - maxPx ;
358
358
if ( shiftPlus > 0 ) {
359
359
posPx . tail += shiftPlus ;
360
360
posPx . text += shiftPlus ;
@@ -451,32 +451,32 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
451
451
. selectAll ( '.annotation-arrow-g' )
452
452
. remove ( ) ;
453
453
454
- var headX = annPosPx . x . head ,
455
- headY = annPosPx . y . head ,
456
- tailX = annPosPx . x . tail + dx ,
457
- tailY = annPosPx . y . tail + dy ,
458
- textX = annPosPx . x . text + dx ,
459
- textY = annPosPx . y . text + dy ,
460
-
461
- // find the edge of the text box, where we'll start the arrow:
462
- // create transform matrix to rotate the text box corners
463
- transform = Lib . rotationXYMatrix ( textangle , textX , textY ) ,
464
- applyTransform = Lib . apply2DTransform ( transform ) ,
465
- applyTransform2 = Lib . apply2DTransform2 ( transform ) ,
466
-
467
- // calculate and transform bounding box
468
- width = + annTextBG . attr ( 'width' ) ,
469
- height = + annTextBG . attr ( 'height' ) ,
470
- xLeft = textX - 0.5 * width ,
471
- xRight = xLeft + width ,
472
- yTop = textY - 0.5 * height ,
473
- yBottom = yTop + height ,
474
- edges = [
475
- [ xLeft , yTop , xLeft , yBottom ] ,
476
- [ xLeft , yBottom , xRight , yBottom ] ,
477
- [ xRight , yBottom , xRight , yTop ] ,
478
- [ xRight , yTop , xLeft , yTop ]
479
- ] . map ( applyTransform2 ) ;
454
+ var headX = annPosPx . x . head ;
455
+ var headY = annPosPx . y . head ;
456
+ var tailX = annPosPx . x . tail + dx ;
457
+ var tailY = annPosPx . y . tail + dy ;
458
+ var textX = annPosPx . x . text + dx ;
459
+ var textY = annPosPx . y . text + dy ;
460
+
461
+ // find the edge of the text box, where we'll start the arrow:
462
+ // create transform matrix to rotate the text box corners
463
+ var transform = Lib . rotationXYMatrix ( textangle , textX , textY ) ;
464
+ var applyTransform = Lib . apply2DTransform ( transform ) ;
465
+ var applyTransform2 = Lib . apply2DTransform2 ( transform ) ;
466
+
467
+ // calculate and transform bounding box
468
+ var width = + annTextBG . attr ( 'width' ) ;
469
+ var height = + annTextBG . attr ( 'height' ) ;
470
+ var xLeft = textX - 0.5 * width ;
471
+ var xRight = xLeft + width ;
472
+ var yTop = textY - 0.5 * height ;
473
+ var yBottom = yTop + height ;
474
+ var edges = [
475
+ [ xLeft , yTop , xLeft , yBottom ] ,
476
+ [ xLeft , yBottom , xRight , yBottom ] ,
477
+ [ xRight , yBottom , xRight , yTop ] ,
478
+ [ xRight , yTop , xLeft , yTop ]
479
+ ] . map ( applyTransform2 ) ;
480
480
481
481
// Remove the line if it ends inside the box. Use ray
482
482
// casting for rotated boxes: see which edges intersect a
@@ -500,9 +500,9 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
500
500
}
501
501
} ) ;
502
502
503
- var strokewidth = options . arrowwidth ,
504
- arrowColor = options . arrowcolor ,
505
- arrowSide = options . arrowside ;
503
+ var strokewidth = options . arrowwidth ;
504
+ var arrowColor = options . arrowcolor ;
505
+ var arrowSide = options . arrowside ;
506
506
507
507
var arrowGroup = annGroup . append ( 'g' )
508
508
. style ( { opacity : Color . opacity ( arrowColor ) } )
@@ -557,9 +557,9 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
557
557
}
558
558
} ,
559
559
moveFn : function ( dx , dy ) {
560
- var annxy0 = applyTransform ( annx0 , anny0 ) ,
561
- xcenter = annxy0 [ 0 ] + dx ,
562
- ycenter = annxy0 [ 1 ] + dy ;
560
+ var annxy0 = applyTransform ( annx0 , anny0 ) ;
561
+ var xcenter = annxy0 [ 0 ] + dx ;
562
+ var ycenter = annxy0 [ 1 ] + dy ;
563
563
annTextGroupInner . call ( Drawing . setTranslate , xcenter , ycenter ) ;
564
564
565
565
modifyItem ( 'x' , xa ?
@@ -629,9 +629,8 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
629
629
xUpdate = xa . p2r ( xa . r2p ( options . x ) + dx ) ;
630
630
631
631
} else {
632
- var widthFraction = options . _xsize / gs . w ,
633
- xLeft = options . x + ( options . _xshift - options . xshift ) / gs . w -
634
- widthFraction / 2 ;
632
+ var widthFraction = options . _xsize / gs . w ;
633
+ var xLeft = options . x + ( options . _xshift - options . xshift ) / gs . w - widthFraction / 2 ;
635
634
636
635
xUpdate = dragElement . align ( xLeft + dx / gs . w ,
637
636
widthFraction , 0 , 1 , options . xanchor ) ;
@@ -640,9 +639,8 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
640
639
if ( ya ) {
641
640
yUpdate = ya . p2r ( ya . r2p ( options . y ) + dy ) ;
642
641
} else {
643
- var heightFraction = options . _ysize / gs . h ,
644
- yBottom = options . y - ( options . _yshift + options . yshift ) / gs . h -
645
- heightFraction / 2 ;
642
+ var heightFraction = options . _ysize / gs . h ;
643
+ var yBottom = options . y - ( options . _yshift + options . yshift ) / gs . h - heightFraction / 2 ;
646
644
647
645
yUpdate = dragElement . align ( yBottom - dy / gs . h ,
648
646
heightFraction , 0 , 1 , options . yanchor ) ;
0 commit comments