You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by GitBox <gi...@apache.org> on 2021/12/30 08:05:47 UTC

[GitHub] [echarts] Ovilia opened a new pull request #16307: fix(pie): tangential rotation with startAngle #15980

Ovilia opened a new pull request #16307:
URL: https://github.com/apache/echarts/pull/16307


   <!-- Please fill in the following information to help us review your PR more efficiently. -->
   
   ## Brief Information
   
   This pull request is in the type of:
   
   - [x] bug fixing
   - [ ] new feature
   - [ ] others
   
   
   
   ### What does this PR do?
   
   <!-- USE ONE SENTENCE TO DESCRIBE WHAT THIS PR DOES. -->
   
   Fix pie label rotation when `startAngle` is set to values like 0.
   
   ### Fixed issues
   
   - #15980
   
   ## Details
   
   ### Before: What was the problem?
   
   In some cases, the text rotation is up-side-down and hard to read.
   
   ![image](https://user-images.githubusercontent.com/779050/147733011-6e04bb45-83f3-4108-8357-ea7b419fe15a.png)
   
   
   ### After: How is it fixed in this PR?
   
   All text is rotated upwards for better reading.
   
   ![image](https://user-images.githubusercontent.com/779050/147732895-fb57569d-c92b-493e-ba04-40be4e9b13f6.png)
   
   
   ## Misc
   
   <!-- ADD RELATED ISSUE ID WHEN APPLICABLE -->
   
   - [ ] The API has been changed (apache/echarts-doc#xxx).
   - [ ] This PR depends on ZRender changes (ecomfe/zrender#xxx).
   
   ### Related test cases or examples to use the new APIs
   
   - test/pie-label-rotate.html
   
   The `run` button changes `startAngle` and data to test it works in all situations.
   
   
   
   ## Others
   
   ### Merging options
   
   - [ ] Please squash the commits into a single one when merging.
   
   ### Other information
   


-- 
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: commits-unsubscribe@echarts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [echarts] pissang commented on a change in pull request #16307: fix(pie): tangential rotation with startAngle #15980

Posted by GitBox <gi...@apache.org>.
pissang commented on a change in pull request #16307:
URL: https://github.com/apache/echarts/pull/16307#discussion_r777790513



##########
File path: src/chart/pie/labelLayout.ts
##########
@@ -473,7 +474,9 @@ export default function pieLabelLayout(
                 && labelPosition !== 'outer'
             ) {
                 labelRotate = radialAngle + Math.PI / 2;
-                if (labelRotate > Math.PI / 2) {
+                if (labelRotate > Math.PI / 2 && labelRotate < Math.PI * 1.5

Review comment:
       Clould you explain the check here? Seems checking `radialAngle` will be simpler here. Similar logic in https://github.com/apache/echarts/blob/master/src/chart/graph/GraphView.ts#L185
   
   Also `Math.PI` can be saved to a variable here.




-- 
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: commits-unsubscribe@echarts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [echarts] Ovilia merged pull request #16307: fix(pie): tangential rotation with startAngle #15980

Posted by GitBox <gi...@apache.org>.
Ovilia merged pull request #16307:
URL: https://github.com/apache/echarts/pull/16307


   


-- 
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: commits-unsubscribe@echarts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [echarts] echarts-bot[bot] commented on pull request #16307: fix(pie): tangential rotation with startAngle #15980

Posted by GitBox <gi...@apache.org>.
echarts-bot[bot] commented on pull request #16307:
URL: https://github.com/apache/echarts/pull/16307#issuecomment-1002916205


   Thanks for your contribution!
   The community will review it ASAP. In the meanwhile, please checkout [the coding standard](https://echarts.apache.org/en/coding-standard.html) and Wiki about [How to make a pull request](https://github.com/apache/echarts/wiki/How-to-make-a-pull-request).
   
   The pull request is marked to be `PR: author is committer` because you are a committer of this project.


-- 
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: commits-unsubscribe@echarts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [echarts] pissang commented on a change in pull request #16307: fix(pie): tangential rotation with startAngle #15980

Posted by GitBox <gi...@apache.org>.
pissang commented on a change in pull request #16307:
URL: https://github.com/apache/echarts/pull/16307#discussion_r777789303



##########
File path: src/chart/pie/labelLayout.ts
##########
@@ -354,6 +354,7 @@ export default function pieLabelLayout(
     const viewLeft = viewRect.x;
     const viewTop = viewRect.y;
     const viewHeight = viewRect.height;
+    const seriesStartAngle = seriesModel.get('startAngle') * RADIAN;

Review comment:
       Is it an unused value?

##########
File path: src/chart/pie/labelLayout.ts
##########
@@ -473,7 +474,9 @@ export default function pieLabelLayout(
                 && labelPosition !== 'outer'
             ) {
                 labelRotate = radialAngle + Math.PI / 2;
-                if (labelRotate > Math.PI / 2) {
+                if (labelRotate > Math.PI / 2 && labelRotate < Math.PI * 1.5

Review comment:
       Clould you explain the check here? Also `Math.PI` can be saved to a variable here.




-- 
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: commits-unsubscribe@echarts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [echarts] pissang commented on a change in pull request #16307: fix(pie): tangential rotation with startAngle #15980

Posted by GitBox <gi...@apache.org>.
pissang commented on a change in pull request #16307:
URL: https://github.com/apache/echarts/pull/16307#discussion_r777790513



##########
File path: src/chart/pie/labelLayout.ts
##########
@@ -473,7 +474,9 @@ export default function pieLabelLayout(
                 && labelPosition !== 'outer'
             ) {
                 labelRotate = radialAngle + Math.PI / 2;
-                if (labelRotate > Math.PI / 2) {
+                if (labelRotate > Math.PI / 2 && labelRotate < Math.PI * 1.5

Review comment:
       Clould you explain the check here? Seems checking `radialAngle` will be simpler here.
   
   Also `Math.PI` can be saved to a variable here.




-- 
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: commits-unsubscribe@echarts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [echarts] pissang commented on a change in pull request #16307: fix(pie): tangential rotation with startAngle #15980

Posted by GitBox <gi...@apache.org>.
pissang commented on a change in pull request #16307:
URL: https://github.com/apache/echarts/pull/16307#discussion_r777790513



##########
File path: src/chart/pie/labelLayout.ts
##########
@@ -473,7 +474,9 @@ export default function pieLabelLayout(
                 && labelPosition !== 'outer'
             ) {
                 labelRotate = radialAngle + Math.PI / 2;
-                if (labelRotate > Math.PI / 2) {
+                if (labelRotate > Math.PI / 2 && labelRotate < Math.PI * 1.5

Review comment:
       Clould you explain the check here? Seems like check `radialAngle` will be simpler here.
   
   Also `Math.PI` can be saved to a variable here.




-- 
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: commits-unsubscribe@echarts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [echarts] plainheart commented on a change in pull request #16307: fix(pie): tangential rotation with startAngle #15980

Posted by GitBox <gi...@apache.org>.
plainheart commented on a change in pull request #16307:
URL: https://github.com/apache/echarts/pull/16307#discussion_r779530735



##########
File path: src/chart/pie/labelLayout.ts
##########
@@ -455,31 +455,31 @@ export default function pieLabelLayout(
                     : (nx > 0 ? 'left' : 'right'));
         }
 
-        let labelRotate;
+        const PI = Math.PI;
+        let labelRotate = 0;
         const rotate = labelModel.get('rotate');
         if (typeof rotate === 'number') {
-            labelRotate = rotate * (Math.PI / 180);
+            labelRotate = rotate * (PI / 180);
         }
         else if (labelPosition === 'center') {
             labelRotate = 0;
         }
-        else {
-            const radialAngle = nx < 0 ? -midAngle + Math.PI : -midAngle;
-            if (rotate === 'radial' || rotate === true) {
-                labelRotate = radialAngle;
-            }
-            else if (rotate === 'tangential'
-                && labelPosition !== 'outside'
-                && labelPosition !== 'outer'
-            ) {
-                labelRotate = radialAngle + Math.PI / 2;
-                if (labelRotate > Math.PI / 2) {
-                    labelRotate -= Math.PI;
-                }
+        else if (rotate === 'radial' || rotate === true) {
+            const radialAngle = nx < 0 ? -midAngle + PI : -midAngle;
+            labelRotate = radialAngle;
+        }
+        else if (rotate === 'tangential'
+            && labelPosition !== 'outside' && labelPosition !== 'outer'
+        ) {
+            let rad = Math.atan2(nx, ny);

Review comment:
       Just wondering if the order of these two arguments is unexpectedly reversed?




-- 
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: commits-unsubscribe@echarts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [echarts] echarts-bot[bot] commented on pull request #16307: fix(pie): tangential rotation with startAngle #15980

Posted by GitBox <gi...@apache.org>.
echarts-bot[bot] commented on pull request #16307:
URL: https://github.com/apache/echarts/pull/16307#issuecomment-1006552373


   Congratulations! Your PR has been merged. Thanks for your contribution! 👍


-- 
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: commits-unsubscribe@echarts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org