@@ -117,8 +117,8 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
117117
118118 // calculated pixel positions
119119 // 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 ;
122122
123123 // create the components
124124 // made a single group to contain all, so opacity can work right
@@ -185,9 +185,9 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
185185 } ) ;
186186 }
187187
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 ;
191191
192192 var annTextBG = annTextGroupInner . append ( 'rect' )
193193 . attr ( 'class' , 'bg' )
@@ -270,24 +270,24 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
270270 var letters = [ 'x' , 'y' ] ;
271271
272272 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 ;
291291
292292 /*
293293 * calculate the *primary* pixel position
@@ -353,8 +353,8 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
353353 posPx . head = Lib . constrain ( posPx . head , 1 , maxPx - 1 ) ;
354354 }
355355 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 ;
358358 if ( shiftPlus > 0 ) {
359359 posPx . tail += shiftPlus ;
360360 posPx . text += shiftPlus ;
@@ -451,32 +451,32 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
451451 . selectAll ( '.annotation-arrow-g' )
452452 . remove ( ) ;
453453
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 ) ;
480480
481481 // Remove the line if it ends inside the box. Use ray
482482 // casting for rotated boxes: see which edges intersect a
@@ -500,9 +500,9 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
500500 }
501501 } ) ;
502502
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 ;
506506
507507 var arrowGroup = annGroup . append ( 'g' )
508508 . style ( { opacity : Color . opacity ( arrowColor ) } )
@@ -557,9 +557,9 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
557557 }
558558 } ,
559559 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 ;
563563 annTextGroupInner . call ( Drawing . setTranslate , xcenter , ycenter ) ;
564564
565565 modifyItem ( 'x' , xa ?
@@ -629,9 +629,8 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
629629 xUpdate = xa . p2r ( xa . r2p ( options . x ) + dx ) ;
630630
631631 } 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 ;
635634
636635 xUpdate = dragElement . align ( xLeft + dx / gs . w ,
637636 widthFraction , 0 , 1 , options . xanchor ) ;
@@ -640,9 +639,8 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
640639 if ( ya ) {
641640 yUpdate = ya . p2r ( ya . r2p ( options . y ) + dy ) ;
642641 } 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 ;
646644
647645 yUpdate = dragElement . align ( yBottom - dy / gs . h ,
648646 heightFraction , 0 , 1 , options . yanchor ) ;
0 commit comments