@@ -340,22 +340,22 @@ function appendBarText(gd, plotinfo, bar, calcTrace, i, x0, x1, y0, y1, opts) {
340340 trace . constraintext === 'both' ||
341341 trace . constraintext === 'outside' ;
342342
343- transform = getTransformToMoveOutsideBar ( x0 , x1 , y0 , y1 , textBB , {
343+ transform = getTransform ( toMoveOutsideBar ( x0 , x1 , y0 , y1 , textBB , {
344344 isHorizontal : isHorizontal ,
345345 constrained : constrained ,
346346 angle : trace . textangle
347- } ) ;
347+ } ) ) ;
348348 } else {
349349 constrained =
350350 trace . constraintext === 'both' ||
351351 trace . constraintext === 'inside' ;
352352
353- transform = getTransformToMoveInsideBar ( x0 , x1 , y0 , y1 , textBB , {
353+ transform = getTransform ( toMoveInsideBar ( x0 , x1 , y0 , y1 , textBB , {
354354 isHorizontal : isHorizontal ,
355355 constrained : constrained ,
356356 angle : trace . textangle ,
357357 anchor : trace . insidetextanchor
358- } ) ;
358+ } ) ) ;
359359 }
360360
361361 textSelection . attr ( 'transform' , transform ) ;
@@ -365,7 +365,7 @@ function getRotationFromAngle(angle) {
365365 return ( angle === 'auto' ) ? 0 : angle ;
366366}
367367
368- function getTransformToMoveInsideBar ( x0 , x1 , y0 , y1 , textBB , opts ) {
368+ function toMoveInsideBar ( x0 , x1 , y0 , y1 , textBB , opts ) {
369369 var isHorizontal = ! ! opts . isHorizontal ;
370370 var constrained = ! ! opts . constrained ;
371371 var angle = opts . angle || 0 ;
@@ -440,10 +440,17 @@ function getTransformToMoveInsideBar(x0, x1, y0, y1, textBB, opts) {
440440 // lastly apply auto rotation
441441 if ( isAutoRotated ) rotation += 90 ;
442442
443- return getTransform ( textX , textY , targetX , targetY , scale , rotation ) ;
443+ return {
444+ textX : textX ,
445+ textY : textY ,
446+ targetX : targetX ,
447+ targetY : targetY ,
448+ scale : scale ,
449+ rotation : rotation
450+ } ;
444451}
445452
446- function getTransformToMoveOutsideBar ( x0 , x1 , y0 , y1 , textBB , opts ) {
453+ function toMoveOutsideBar ( x0 , x1 , y0 , y1 , textBB , opts ) {
447454 var isHorizontal = ! ! opts . isHorizontal ;
448455 var constrained = ! ! opts . constrained ;
449456 var angle = opts . angle || 0 ;
@@ -491,10 +498,24 @@ function getTransformToMoveOutsideBar(x0, x1, y0, y1, textBB, opts) {
491498 var textX = ( textBB . left + textBB . right ) / 2 ;
492499 var textY = ( textBB . top + textBB . bottom ) / 2 ;
493500
494- return getTransform ( textX , textY , targetX , targetY , scale , rotation ) ;
501+ return {
502+ textX : textX ,
503+ textY : textY ,
504+ targetX : targetX ,
505+ targetY : targetY ,
506+ scale : scale ,
507+ rotation : rotation
508+ } ;
495509}
496510
497- function getTransform ( textX , textY , targetX , targetY , scale , rotation ) {
511+ function getTransform ( opts ) {
512+ var textX = opts . textX ;
513+ var textY = opts . textY ;
514+ var targetX = opts . targetX ;
515+ var targetY = opts . targetY ;
516+ var scale = opts . scale ;
517+ var rotation = opts . rotation ;
518+
498519 var transformScale ;
499520 var transformRotate ;
500521 var transformTranslate ;
@@ -610,6 +631,7 @@ function calcTextinfo(calcTrace, index, xa, ya) {
610631
611632module . exports = {
612633 plot : plot ,
613- getTransformToMoveInsideBar : getTransformToMoveInsideBar ,
614- getTransformToMoveOutsideBar : getTransformToMoveOutsideBar
634+ getTransform : getTransform ,
635+ toMoveInsideBar : toMoveInsideBar ,
636+ toMoveOutsideBar : toMoveOutsideBar
615637} ;
0 commit comments