@@ -21,15 +21,15 @@ var tickText = require('../../plots/cartesian/axes').tickText;
21
21
22
22
var style = require ( './style' ) ;
23
23
var helpers = require ( './helpers' ) ;
24
+ var constants = require ( './constants' ) ;
24
25
var attributes = require ( './attributes' ) ;
25
26
26
27
var attributeText = attributes . text ;
27
28
var attributeTextPosition = attributes . textposition ;
28
29
29
30
var appendArrayPointValue = require ( '../../components/fx/helpers' ) . appendArrayPointValue ;
30
31
31
- // padding in pixels around text
32
- var TEXTPAD = 3 ;
32
+ var TEXTPAD = constants . TEXTPAD ;
33
33
34
34
function keyFunc ( d ) { return d . id ; }
35
35
function getKeyFunc ( trace ) {
@@ -381,7 +381,7 @@ function appendBarText(gd, plotinfo, bar, calcTrace, i, x0, x1, y0, y1, opts, ma
381
381
trace . constraintext === 'both' ||
382
382
trace . constraintext === 'outside' ;
383
383
384
- transform = getTransform ( toMoveOutsideBar ( x0 , x1 , y0 , y1 , textBB , {
384
+ transform = Lib . getTextTransform ( toMoveOutsideBar ( x0 , x1 , y0 , y1 , textBB , {
385
385
isHorizontal : isHorizontal ,
386
386
constrained : constrained ,
387
387
angle : trace . textangle
@@ -391,7 +391,7 @@ function appendBarText(gd, plotinfo, bar, calcTrace, i, x0, x1, y0, y1, opts, ma
391
391
trace . constraintext === 'both' ||
392
392
trace . constraintext === 'inside' ;
393
393
394
- transform = getTransform ( toMoveInsideBar ( x0 , x1 , y0 , y1 , textBB , {
394
+ transform = Lib . getTextTransform ( toMoveInsideBar ( x0 , x1 , y0 , y1 , textBB , {
395
395
isHorizontal : isHorizontal ,
396
396
constrained : constrained ,
397
397
angle : trace . textangle ,
@@ -549,35 +549,6 @@ function toMoveOutsideBar(x0, x1, y0, y1, textBB, opts) {
549
549
} ;
550
550
}
551
551
552
- function getTransform ( opts ) {
553
- var textX = opts . textX ;
554
- var textY = opts . textY ;
555
- var targetX = opts . targetX ;
556
- var targetY = opts . targetY ;
557
- var scale = opts . scale ;
558
- var rotate = opts . rotate ;
559
-
560
- var transformScale ;
561
- var transformRotate ;
562
- var transformTranslate ;
563
-
564
- if ( scale < 1 ) transformScale = 'scale(' + scale + ') ' ;
565
- else {
566
- scale = 1 ;
567
- transformScale = '' ;
568
- }
569
-
570
- transformRotate = ( rotate ) ?
571
- 'rotate(' + rotate + ' ' + textX + ' ' + textY + ') ' : '' ;
572
-
573
- // Note that scaling also affects the center of the text box
574
- var translateX = ( targetX - scale * textX ) ;
575
- var translateY = ( targetY - scale * textY ) ;
576
- transformTranslate = 'translate(' + translateX + ' ' + translateY + ')' ;
577
-
578
- return transformTranslate + transformScale + transformRotate ;
579
- }
580
-
581
552
function getText ( fullLayout , calcTrace , index , xa , ya ) {
582
553
var trace = calcTrace [ 0 ] . trace ;
583
554
var texttemplate = trace . texttemplate ;
@@ -734,7 +705,6 @@ function calcTextinfo(calcTrace, index, xa, ya) {
734
705
735
706
module . exports = {
736
707
plot : plot ,
737
- getTransform : getTransform ,
738
708
toMoveInsideBar : toMoveInsideBar ,
739
709
toMoveOutsideBar : toMoveOutsideBar
740
710
} ;
0 commit comments