@@ -340,22 +340,22 @@ function appendBarText(gd, plotinfo, bar, calcTrace, i, x0, x1, y0, y1, opts) {
340
340
trace . constraintext === 'both' ||
341
341
trace . constraintext === 'outside' ;
342
342
343
- transform = getTransformToMoveOutsideBar ( x0 , x1 , y0 , y1 , textBB , {
343
+ transform = getTransform ( toMoveOutsideBar ( x0 , x1 , y0 , y1 , textBB , {
344
344
isHorizontal : isHorizontal ,
345
345
constrained : constrained ,
346
346
angle : trace . textangle
347
- } ) ;
347
+ } ) ) ;
348
348
} else {
349
349
constrained =
350
350
trace . constraintext === 'both' ||
351
351
trace . constraintext === 'inside' ;
352
352
353
- transform = getTransformToMoveInsideBar ( x0 , x1 , y0 , y1 , textBB , {
353
+ transform = getTransform ( toMoveInsideBar ( x0 , x1 , y0 , y1 , textBB , {
354
354
isHorizontal : isHorizontal ,
355
355
constrained : constrained ,
356
356
angle : trace . textangle ,
357
357
anchor : trace . insidetextanchor
358
- } ) ;
358
+ } ) ) ;
359
359
}
360
360
361
361
textSelection . attr ( 'transform' , transform ) ;
@@ -365,7 +365,7 @@ function getRotationFromAngle(angle) {
365
365
return ( angle === 'auto' ) ? 0 : angle ;
366
366
}
367
367
368
- function getTransformToMoveInsideBar ( x0 , x1 , y0 , y1 , textBB , opts ) {
368
+ function toMoveInsideBar ( x0 , x1 , y0 , y1 , textBB , opts ) {
369
369
var isHorizontal = ! ! opts . isHorizontal ;
370
370
var constrained = ! ! opts . constrained ;
371
371
var angle = opts . angle || 0 ;
@@ -440,10 +440,17 @@ function getTransformToMoveInsideBar(x0, x1, y0, y1, textBB, opts) {
440
440
// lastly apply auto rotation
441
441
if ( isAutoRotated ) rotation += 90 ;
442
442
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
+ } ;
444
451
}
445
452
446
- function getTransformToMoveOutsideBar ( x0 , x1 , y0 , y1 , textBB , opts ) {
453
+ function toMoveOutsideBar ( x0 , x1 , y0 , y1 , textBB , opts ) {
447
454
var isHorizontal = ! ! opts . isHorizontal ;
448
455
var constrained = ! ! opts . constrained ;
449
456
var angle = opts . angle || 0 ;
@@ -491,10 +498,24 @@ function getTransformToMoveOutsideBar(x0, x1, y0, y1, textBB, opts) {
491
498
var textX = ( textBB . left + textBB . right ) / 2 ;
492
499
var textY = ( textBB . top + textBB . bottom ) / 2 ;
493
500
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
+ } ;
495
509
}
496
510
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
+
498
519
var transformScale ;
499
520
var transformRotate ;
500
521
var transformTranslate ;
@@ -610,6 +631,7 @@ function calcTextinfo(calcTrace, index, xa, ya) {
610
631
611
632
module . exports = {
612
633
plot : plot ,
613
- getTransformToMoveInsideBar : getTransformToMoveInsideBar ,
614
- getTransformToMoveOutsideBar : getTransformToMoveOutsideBar
634
+ getTransform : getTransform ,
635
+ toMoveInsideBar : toMoveInsideBar ,
636
+ toMoveOutsideBar : toMoveOutsideBar
615
637
} ;
0 commit comments