@@ -145,11 +145,10 @@ function plot(gd, cdModule) {
145
145
s . attr ( 'data-notex' , 1 ) ;
146
146
} ) ;
147
147
148
- var font = Lib . extendFlat ( { } , textPosition === 'outside' ?
148
+ var font = Lib . ensureUniformFontSize ( gd , textPosition === 'outside' ?
149
149
determineOutsideTextFont ( trace , pt , fullLayout . font ) :
150
- determineInsideTextFont ( trace , pt , fullLayout . font ) , { }
150
+ determineInsideTextFont ( trace , pt , fullLayout . font )
151
151
) ;
152
- font . size = Math . max ( font . size , fullLayout . uniformtext . minsize || 0 ) ;
153
152
154
153
sliceText . text ( pt . text )
155
154
. attr ( {
@@ -169,14 +168,11 @@ function plot(gd, cdModule) {
169
168
} else {
170
169
transform = transformInsideText ( textBB , pt , cd0 ) ;
171
170
if ( textPosition === 'auto' && transform . scale < 1 ) {
172
- var newFont = Lib . extendFlat ( { } , trace . outsidetextfont , { } ) ;
173
- newFont . size = Math . max ( newFont . size , fullLayout . uniformtext . minsize || 0 ) ;
171
+ var newFont = Lib . ensureUniformFontSize ( gd , trace . outsidetextfont ) ;
174
172
175
173
sliceText . call ( Drawing . font , newFont ) ;
176
- if ( newFont . family !== font . family || newFont . size !== font . size ) {
177
- // recompute bounding box
178
- textBB = Drawing . bBox ( sliceText . node ( ) ) ;
179
- }
174
+ textBB = Drawing . bBox ( sliceText . node ( ) ) ;
175
+
180
176
transform = transformOutsideText ( textBB , pt ) ;
181
177
}
182
178
}
@@ -201,7 +197,7 @@ function plot(gd, cdModule) {
201
197
recordMinTextSize ( trace . type , transform , fullLayout ) ;
202
198
cd [ i ] . transform = transform ;
203
199
204
- sliceText . attr ( 'transform' , Lib . getTextTransform ( transform , true ) ) ;
200
+ sliceText . attr ( 'transform' , Lib . getTextTransform ( transform ) ) ;
205
201
} ) ;
206
202
} ) ;
207
203
@@ -565,11 +561,14 @@ function transformInsideText(textBB, pt, cd0) {
565
561
var rInscribed = pt . rInscribed ;
566
562
var r = cd0 . r || pt . rpx1 ;
567
563
var orientation = cd0 . trace . insidetextorientation ;
568
- var allTransforms = [ ] ;
569
-
564
+ var isHorizontal = orientation === 'horizontal' ;
565
+ var isTangential = orientation === 'tangential' ;
566
+ var isRadial = orientation === 'radial' ;
567
+ var isAuto = orientation === 'auto' ;
570
568
var isCircle = ( ring === 1 ) && ( Math . abs ( pt . startangle - pt . stopangle ) === Math . PI * 2 ) ;
569
+ var allTransforms = [ ] ;
571
570
572
- if ( isCircle || orientation === 'auto' || orientation === 'h' ) {
571
+ if ( isCircle || isAuto || isHorizontal ) {
573
572
// max size text can be inserted inside without rotating it
574
573
// this inscribes the text rectangle in a circle, which is then inscribed
575
574
// in the slice, so it will be an underestimate, which some day we may want
@@ -587,7 +586,7 @@ function transformInsideText(textBB, pt, cd0) {
587
586
allTransforms . push ( transform ) ;
588
587
}
589
588
590
- if ( orientation === 'h' ) {
589
+ if ( isHorizontal ) {
591
590
// max size if text is placed (horizontally) at the top or bottom of the arc
592
591
593
592
var considerCrossing = function ( angle , key ) {
@@ -603,32 +602,33 @@ function transformInsideText(textBB, pt, cd0) {
603
602
} else { // case of 'rad'
604
603
newT = calcRadTransform ( textBB , r , ring , closestEdge , Math . PI / 2 ) ;
605
604
}
606
- newT . _repos = getCoords ( r , angle ) ;
605
+ newT . pxtxt = getCoords ( r , angle ) ;
607
606
608
607
allTransforms . push ( newT ) ;
609
608
}
610
609
} ;
611
610
612
611
for ( var i = 3 ; i >= - 3 ; i -- ) { // to cover all cases with trace.rotation added
613
- considerCrossing ( Math . PI * ( i + 0.0 ) , 'tan' ) ;
612
+ considerCrossing ( Math . PI * i , 'tan' ) ;
614
613
considerCrossing ( Math . PI * ( i + 0.5 ) , 'rad' ) ;
615
614
}
616
615
}
617
616
618
- if ( orientation === 'auto' || orientation === 'r' ) {
617
+ if ( isAuto || isRadial ) {
619
618
allTransforms . push ( calcRadTransform ( textBB , r , ring , halfAngle , midAngle ) ) ;
620
619
}
621
620
622
- if ( orientation === 'auto' || orientation === 't' ) {
621
+ if ( isAuto || isTangential ) {
623
622
allTransforms . push ( calcTanTransform ( textBB , r , ring , halfAngle , midAngle ) ) ;
624
623
}
625
624
626
625
var maxScaleTransform = allTransforms . sort ( function ( a , b ) {
627
626
return b . scale - a . scale ;
628
627
} ) [ 0 ] ;
629
628
630
- if ( maxScaleTransform . _repos ) {
631
- pt . pxtxt = maxScaleTransform . _repos ;
629
+ if ( maxScaleTransform . pxtxt ) {
630
+ // copy text position if not at the middle
631
+ pt . pxtxt = maxScaleTransform . pxtxt ;
632
632
}
633
633
634
634
return maxScaleTransform ;
@@ -1119,6 +1119,7 @@ function computeTransform(
1119
1119
var midY = ( textBB . top + textBB . bottom ) / 2 ;
1120
1120
transform . textX = midX * cosA - midY * sinA ;
1121
1121
transform . textY = midX * sinA + midY * cosA ;
1122
+ transform . noCenter = true ;
1122
1123
}
1123
1124
1124
1125
module . exports = {
0 commit comments