pissang commented on a change in pull request #16425:
URL: https://github.com/apache/echarts/pull/16425#discussion_r804311789



##########
File path: src/chart/sunburst/SunburstPiece.ts
##########
@@ -239,8 +239,15 @@ class SunburstPiece extends graphic.Sector {
             state.style.align = textAlign;
             state.style.verticalAlign = getLabelAttr(labelStateModel, 
'verticalAlign') || 'middle';
 
-            state.x = r * dx + layout.cx;
-            state.y = r * dy + layout.cy;
+            // set the position of label in center when angle is 2π & r0 is 0
+            if (textAlign === 'center' && angle === 2 * Math.PI && layout.r0 
=== 0) {
+                state.x = layout.cx;

Review comment:
       Also this logic is better to be put in the branch 
   
   
https://github.com/apache/echarts/blob/98819a694712dd9e0772a71b4e697599d15293fc/src/chart/sunburst/SunburstPiece.ts#L222

##########
File path: src/chart/sunburst/SunburstPiece.ts
##########
@@ -239,8 +239,15 @@ class SunburstPiece extends graphic.Sector {
             state.style.align = textAlign;
             state.style.verticalAlign = getLabelAttr(labelStateModel, 
'verticalAlign') || 'middle';
 
-            state.x = r * dx + layout.cx;
-            state.y = r * dy + layout.cy;
+            // set the position of label in center when angle is 2π & r0 is 0
+            if (textAlign === 'center' && angle === 2 * Math.PI && layout.r0 
=== 0) {
+                state.x = layout.cx;

Review comment:
       Seems the variable `r` is used for offseting the labels. It will a bit 
neater and more consistent if we only set the `r` to 0 here, then do a general 
calculating on the `state.x` and `state.y` with fomular:
   
   ```ts
   state.x = r * dx + layout.cx;
   state.y = r * dy + layout.cy;
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to