@@ -145,11 +145,10 @@ function plot(gd, cdModule) {
145145 s . attr ( 'data-notex' , 1 ) ;
146146 } ) ;
147147
148- var font = Lib . extendFlat ( { } , textPosition === 'outside' ?
148+ var font = Lib . ensureUniformFontSize ( gd , textPosition === 'outside' ?
149149 determineOutsideTextFont ( trace , pt , fullLayout . font ) :
150- determineInsideTextFont ( trace , pt , fullLayout . font ) , { }
150+ determineInsideTextFont ( trace , pt , fullLayout . font )
151151 ) ;
152- font . size = Math . max ( font . size , fullLayout . uniformtext . minsize || 0 ) ;
153152
154153 sliceText . text ( pt . text )
155154 . attr ( {
@@ -169,14 +168,11 @@ function plot(gd, cdModule) {
169168 } else {
170169 transform = transformInsideText ( textBB , pt , cd0 ) ;
171170 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 ) ;
174172
175173 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+
180176 transform = transformOutsideText ( textBB , pt ) ;
181177 }
182178 }
@@ -201,7 +197,7 @@ function plot(gd, cdModule) {
201197 recordMinTextSize ( trace . type , transform , fullLayout ) ;
202198 cd [ i ] . transform = transform ;
203199
204- sliceText . attr ( 'transform' , Lib . getTextTransform ( transform , true ) ) ;
200+ sliceText . attr ( 'transform' , Lib . getTextTransform ( transform ) ) ;
205201 } ) ;
206202 } ) ;
207203
@@ -565,11 +561,14 @@ function transformInsideText(textBB, pt, cd0) {
565561 var rInscribed = pt . rInscribed ;
566562 var r = cd0 . r || pt . rpx1 ;
567563 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' ;
570568 var isCircle = ( ring === 1 ) && ( Math . abs ( pt . startangle - pt . stopangle ) === Math . PI * 2 ) ;
569+ var allTransforms = [ ] ;
571570
572- if ( isCircle || orientation === 'auto' || orientation === 'h' ) {
571+ if ( isCircle || isAuto || isHorizontal ) {
573572 // max size text can be inserted inside without rotating it
574573 // this inscribes the text rectangle in a circle, which is then inscribed
575574 // in the slice, so it will be an underestimate, which some day we may want
@@ -587,7 +586,7 @@ function transformInsideText(textBB, pt, cd0) {
587586 allTransforms . push ( transform ) ;
588587 }
589588
590- if ( orientation === 'h' ) {
589+ if ( isHorizontal ) {
591590 // max size if text is placed (horizontally) at the top or bottom of the arc
592591
593592 var considerCrossing = function ( angle , key ) {
@@ -603,32 +602,33 @@ function transformInsideText(textBB, pt, cd0) {
603602 } else { // case of 'rad'
604603 newT = calcRadTransform ( textBB , r , ring , closestEdge , Math . PI / 2 ) ;
605604 }
606- newT . _repos = getCoords ( r , angle ) ;
605+ newT . pxtxt = getCoords ( r , angle ) ;
607606
608607 allTransforms . push ( newT ) ;
609608 }
610609 } ;
611610
612611 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' ) ;
614613 considerCrossing ( Math . PI * ( i + 0.5 ) , 'rad' ) ;
615614 }
616615 }
617616
618- if ( orientation === 'auto' || orientation === 'r' ) {
617+ if ( isAuto || isRadial ) {
619618 allTransforms . push ( calcRadTransform ( textBB , r , ring , halfAngle , midAngle ) ) ;
620619 }
621620
622- if ( orientation === 'auto' || orientation === 't' ) {
621+ if ( isAuto || isTangential ) {
623622 allTransforms . push ( calcTanTransform ( textBB , r , ring , halfAngle , midAngle ) ) ;
624623 }
625624
626625 var maxScaleTransform = allTransforms . sort ( function ( a , b ) {
627626 return b . scale - a . scale ;
628627 } ) [ 0 ] ;
629628
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 ;
632632 }
633633
634634 return maxScaleTransform ;
@@ -1119,6 +1119,7 @@ function computeTransform(
11191119 var midY = ( textBB . top + textBB . bottom ) / 2 ;
11201120 transform . textX = midX * cosA - midY * sinA ;
11211121 transform . textY = midX * sinA + midY * cosA ;
1122+ transform . noCenter = true ;
11221123}
11231124
11241125module . exports = {
0 commit comments