@@ -21,15 +21,15 @@ var tickText = require('../../plots/cartesian/axes').tickText;
2121
2222var style = require ( './style' ) ;
2323var helpers = require ( './helpers' ) ;
24+ var constants = require ( './constants' ) ;
2425var attributes = require ( './attributes' ) ;
2526
2627var attributeText = attributes . text ;
2728var attributeTextPosition = attributes . textposition ;
2829
2930var appendArrayPointValue = require ( '../../components/fx/helpers' ) . appendArrayPointValue ;
3031
31- // padding in pixels around text
32- var TEXTPAD = 3 ;
32+ var TEXTPAD = constants . TEXTPAD ;
3333
3434function keyFunc ( d ) { return d . id ; }
3535function getKeyFunc ( trace ) {
@@ -381,7 +381,7 @@ function appendBarText(gd, plotinfo, bar, calcTrace, i, x0, x1, y0, y1, opts, ma
381381 trace . constraintext === 'both' ||
382382 trace . constraintext === 'outside' ;
383383
384- transform = getTransform ( toMoveOutsideBar ( x0 , x1 , y0 , y1 , textBB , {
384+ transform = Lib . getTextTransform ( toMoveOutsideBar ( x0 , x1 , y0 , y1 , textBB , {
385385 isHorizontal : isHorizontal ,
386386 constrained : constrained ,
387387 angle : trace . textangle
@@ -391,7 +391,7 @@ function appendBarText(gd, plotinfo, bar, calcTrace, i, x0, x1, y0, y1, opts, ma
391391 trace . constraintext === 'both' ||
392392 trace . constraintext === 'inside' ;
393393
394- transform = getTransform ( toMoveInsideBar ( x0 , x1 , y0 , y1 , textBB , {
394+ transform = Lib . getTextTransform ( toMoveInsideBar ( x0 , x1 , y0 , y1 , textBB , {
395395 isHorizontal : isHorizontal ,
396396 constrained : constrained ,
397397 angle : trace . textangle ,
@@ -549,35 +549,6 @@ function toMoveOutsideBar(x0, x1, y0, y1, textBB, opts) {
549549 } ;
550550}
551551
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-
581552function getText ( fullLayout , calcTrace , index , xa , ya ) {
582553 var trace = calcTrace [ 0 ] . trace ;
583554 var texttemplate = trace . texttemplate ;
@@ -734,7 +705,6 @@ function calcTextinfo(calcTrace, index, xa, ya) {
734705
735706module . exports = {
736707 plot : plot ,
737- getTransform : getTransform ,
738708 toMoveInsideBar : toMoveInsideBar ,
739709 toMoveOutsideBar : toMoveOutsideBar
740710} ;
0 commit comments