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/09/10 05:24:10 UTC

[GitHub] [echarts] Ovilia opened a new pull request #15706: fix(sunburst): radius in levels

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


   <!-- 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 ONCE SENTENCE TO DESCRIBE WHAT THIS PR DOES. -->
   
   Some sunburst examples uses `series.levels.r` and `series.levels.r0` but this option is not exposed in the document. After further examination, we found the original implementation supports `series.data.r` but we don't find the necessary scenario for this by now.  And `radius` typed in `number | number[]` may be a better option name than `r` and `r0` to be consistent with Pie series.
   
   So this PR fixes this problem and exposes `series.levels.radius` to developers.
   
   
   ## Misc
   
   <!-- ADD RELATED ISSUE ID WHEN APPLICABLE -->
   
   - [x] 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
   
   NA.
   
   
   
   ## Others
   
   ### Merging options
   
   - [ ] Please squash the commits into a single one when merge.
   
   ### 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 #15706: fix(sunburst): radius in levels

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



##########
File path: src/chart/sunburst/SunburstSeries.ts
##########
@@ -152,16 +163,18 @@ class SunburstSeriesModel extends SeriesModel<SunburstSeriesOption> {
     ignoreStyleOnData = true;
 
     private _viewRoot: TreeNode;
+    private _levelModels: Model<SunburstSeriesLevelOption>[];
 
     getInitialData(option: SunburstSeriesOption, ecModel: GlobalModel) {
         // Create a virtual root.
         const root = { name: option.name, children: option.data } as SunburstSeriesNodeItemOption;
 
         completeTreeValue(root);
 
-        const levelModels = zrUtil.map(option.levels || [], function (levelDefine) {
+        this._levelModels = zrUtil.map(option.levels || [], function (levelDefine) {

Review comment:
       Can be simplified to 
   ```js
   const levelModels = this._levelModels = ...
   ```

##########
File path: src/chart/sunburst/sunburstLayout.ts
##########
@@ -119,16 +120,28 @@ export default function sunburstLayout(
                 let rStart = r0 + rPerLevel * depth;
                 let rEnd = r0 + rPerLevel * (depth + 1);
 
-                const itemModel = node.getModel<SunburstSeriesNodeItemOption>();
-                // @ts-ignore. TODO this is not provided to developer yet. Rename it.
-                if (itemModel.get('r0') != null) {
-                    // @ts-ignore
-                    rStart = parsePercent(itemModel.get('r0'), size / 2);
-                }
-                // @ts-ignore
-                if (itemModel.get('r') != null) {
-                    // @ts-ignore
-                    rEnd = parsePercent(itemModel.get('r'), size / 2);
+                const levelModel = seriesModel.getLevelModel(node);
+                if (levelModel) {
+                    const r0 = levelModel.get('r0', true);

Review comment:
       The code can be more tighter:
   ```ts
   let r0: number | percent = levelModel.get('r0', true);
   let r1: number | percent = levelModel.get('r1', true);
   let radius: number | number[] = levelModel.get('radius', true);
   if (radius != null) {
     if (zrUtil.isArray(radius)) {
       r0 = radius[0];
       r1 = radius[1]
     }
     else {
        // I think there is no need to handle this case.
        r0 = r1 = radius;
      }
   }
   r0 != null && (rStart = parsePercent(radius[0], size / 2));
   r1 != null && (rEnd = parsePercent(radius[1], size / 2));
   ```

##########
File path: src/chart/sunburst/sunburstLayout.ts
##########
@@ -119,16 +120,28 @@ export default function sunburstLayout(
                 let rStart = r0 + rPerLevel * depth;
                 let rEnd = r0 + rPerLevel * (depth + 1);
 
-                const itemModel = node.getModel<SunburstSeriesNodeItemOption>();
-                // @ts-ignore. TODO this is not provided to developer yet. Rename it.
-                if (itemModel.get('r0') != null) {
-                    // @ts-ignore
-                    rStart = parsePercent(itemModel.get('r0'), size / 2);
-                }
-                // @ts-ignore
-                if (itemModel.get('r') != null) {
-                    // @ts-ignore
-                    rEnd = parsePercent(itemModel.get('r'), size / 2);
+                const levelModel = seriesModel.getLevelModel(node);
+                if (levelModel) {
+                    const r0 = levelModel.get('r0', true);
+                    if (r0 != null) {
+                        // Compatible with deprecated r0
+                        rStart = parsePercent(r0, size / 2);
+                    }
+                    const r = levelModel.get('r', true);
+                    if (r != null) {
+                        // Compatible with deprecated r
+                        rEnd = parsePercent(r, size / 2);
+                    }
+
+                    // level-specific radius should override that of series
+                    let radius: number | number[] = levelModel.get('radius', true);
+                    if (radius != null) {
+                        if (typeof radius === 'number') {

Review comment:
       radius can be `string`. Also, I'm thinking there is no need to support a single number in `levels`. `innerRadius` and `outerRadius` are always needed. Not like `pie`, which the `innerRadius` may be 0.




-- 
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 #15706: fix(sunburst): radius in levels

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


   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


[GitHub] [echarts] pissang commented on a change in pull request #15706: fix(sunburst): radius in levels

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



##########
File path: src/chart/sunburst/sunburstLayout.ts
##########
@@ -119,16 +120,28 @@ export default function sunburstLayout(
                 let rStart = r0 + rPerLevel * depth;
                 let rEnd = r0 + rPerLevel * (depth + 1);
 
-                const itemModel = node.getModel<SunburstSeriesNodeItemOption>();
-                // @ts-ignore. TODO this is not provided to developer yet. Rename it.
-                if (itemModel.get('r0') != null) {
-                    // @ts-ignore
-                    rStart = parsePercent(itemModel.get('r0'), size / 2);
-                }
-                // @ts-ignore
-                if (itemModel.get('r') != null) {
-                    // @ts-ignore
-                    rEnd = parsePercent(itemModel.get('r'), size / 2);
+                const levelModel = seriesModel.getLevelModel(node);
+                if (levelModel) {
+                    const r0 = levelModel.get('r0', true);

Review comment:
       The code can be tighter:
   ```ts
   let r0: number | percent = levelModel.get('r0', true);
   let r1: number | percent = levelModel.get('r', true);
   const radius: number | number[] = levelModel.get('radius', true);
   if (radius != null) {
     if (zrUtil.isArray(radius)) {
       r0 = radius[0];
       r1 = radius[1]
     }
     else {
        // I think there is no need to handle this case. 
        // At least `r0` should be zero If we need this case
        r0 = 0;
        r1 = radius;
      }
   }
   r0 != null && (rStart = parsePercent(radius[0], size / 2));
   r1 != null && (rEnd = parsePercent(radius[1], size / 2));
   ```




-- 
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 #15706: fix(sunburst): radius in levels

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


   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.
   
   Document changes are required in this PR. Please also make a PR to [apache/echarts-doc](https://github.com/apache/echarts-doc) for document changes and update the issue id in the PR description. When the doc PR is merged, the maintainers will remove the `PR: awaiting doc` label.


-- 
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 merged pull request #15706: fix(sunburst): radius in levels

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


   


-- 
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 #15706: fix(sunburst): radius in levels

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



##########
File path: src/chart/sunburst/sunburstLayout.ts
##########
@@ -119,16 +120,28 @@ export default function sunburstLayout(
                 let rStart = r0 + rPerLevel * depth;
                 let rEnd = r0 + rPerLevel * (depth + 1);
 
-                const itemModel = node.getModel<SunburstSeriesNodeItemOption>();
-                // @ts-ignore. TODO this is not provided to developer yet. Rename it.
-                if (itemModel.get('r0') != null) {
-                    // @ts-ignore
-                    rStart = parsePercent(itemModel.get('r0'), size / 2);
-                }
-                // @ts-ignore
-                if (itemModel.get('r') != null) {
-                    // @ts-ignore
-                    rEnd = parsePercent(itemModel.get('r'), size / 2);
+                const levelModel = seriesModel.getLevelModel(node);
+                if (levelModel) {
+                    const r0 = levelModel.get('r0', true);

Review comment:
       The code can be tighter:
   ```ts
   let r0: number | percent = levelModel.get('r0', true);
   let r1: number | percent = levelModel.get('r', true);
   const radius: number | number[] = levelModel.get('radius', true);
   if (radius != null) {
     if (zrUtil.isArray(radius)) {
       r0 = radius[0];
       r1 = radius[1]
     }
     else {
        // I think there is no need to handle this case. 
        // At least `r0` should be zero if we need this case
        r0 = 0;
        r1 = radius;
      }
   }
   r0 != null && (rStart = parsePercent(radius[0], size / 2));
   r1 != null && (rEnd = parsePercent(radius[1], size / 2));
   ```




-- 
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 #15706: fix(sunburst): radius in levels

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



##########
File path: src/chart/sunburst/sunburstLayout.ts
##########
@@ -119,16 +120,28 @@ export default function sunburstLayout(
                 let rStart = r0 + rPerLevel * depth;
                 let rEnd = r0 + rPerLevel * (depth + 1);
 
-                const itemModel = node.getModel<SunburstSeriesNodeItemOption>();
-                // @ts-ignore. TODO this is not provided to developer yet. Rename it.
-                if (itemModel.get('r0') != null) {
-                    // @ts-ignore
-                    rStart = parsePercent(itemModel.get('r0'), size / 2);
-                }
-                // @ts-ignore
-                if (itemModel.get('r') != null) {
-                    // @ts-ignore
-                    rEnd = parsePercent(itemModel.get('r'), size / 2);
+                const levelModel = seriesModel.getLevelModel(node);
+                if (levelModel) {
+                    const r0 = levelModel.get('r0', true);
+                    if (r0 != null) {
+                        // Compatible with deprecated r0
+                        rStart = parsePercent(r0, size / 2);
+                    }
+                    const r = levelModel.get('r', true);
+                    if (r != null) {
+                        // Compatible with deprecated r
+                        rEnd = parsePercent(r, size / 2);
+                    }
+
+                    // level-specific radius should override that of series
+                    let radius: number | number[] = levelModel.get('radius', true);
+                    if (radius != null) {
+                        if (typeof radius === 'number') {

Review comment:
       radius can be `string`. Also, I'm thinking there is no need to support a single number in `levels`. `innerRadius` and `outerRadius` are always needed. Not like `pie`, in which the `innerRadius` may be 0.




-- 
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 #15706: fix(sunburst): radius in levels

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



##########
File path: src/chart/sunburst/sunburstLayout.ts
##########
@@ -119,16 +120,28 @@ export default function sunburstLayout(
                 let rStart = r0 + rPerLevel * depth;
                 let rEnd = r0 + rPerLevel * (depth + 1);
 
-                const itemModel = node.getModel<SunburstSeriesNodeItemOption>();
-                // @ts-ignore. TODO this is not provided to developer yet. Rename it.
-                if (itemModel.get('r0') != null) {
-                    // @ts-ignore
-                    rStart = parsePercent(itemModel.get('r0'), size / 2);
-                }
-                // @ts-ignore
-                if (itemModel.get('r') != null) {
-                    // @ts-ignore
-                    rEnd = parsePercent(itemModel.get('r'), size / 2);
+                const levelModel = seriesModel.getLevelModel(node);
+                if (levelModel) {
+                    const r0 = levelModel.get('r0', true);

Review comment:
       The code can be tighter:
   ```ts
   let r0: number | percent = levelModel.get('r0', true);
   let r1: number | percent = levelModel.get('r', true);
   const radius: number | number[] = levelModel.get('radius', true);
   if (radius != null) {
     if (zrUtil.isArray(radius)) {
       r0 = radius[0];
       r1 = radius[1]
     }
     else {
        // I think there is no need to handle this case.
        r0 = r1 = radius;
      }
   }
   r0 != null && (rStart = parsePercent(radius[0], size / 2));
   r1 != null && (rEnd = parsePercent(radius[1], size / 2));
   ```




-- 
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 #15706: fix(sunburst): radius in levels

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



##########
File path: src/chart/sunburst/sunburstLayout.ts
##########
@@ -119,16 +120,28 @@ export default function sunburstLayout(
                 let rStart = r0 + rPerLevel * depth;
                 let rEnd = r0 + rPerLevel * (depth + 1);
 
-                const itemModel = node.getModel<SunburstSeriesNodeItemOption>();
-                // @ts-ignore. TODO this is not provided to developer yet. Rename it.
-                if (itemModel.get('r0') != null) {
-                    // @ts-ignore
-                    rStart = parsePercent(itemModel.get('r0'), size / 2);
-                }
-                // @ts-ignore
-                if (itemModel.get('r') != null) {
-                    // @ts-ignore
-                    rEnd = parsePercent(itemModel.get('r'), size / 2);
+                const levelModel = seriesModel.getLevelModel(node);
+                if (levelModel) {
+                    const r0 = levelModel.get('r0', true);
+                    if (r0 != null) {
+                        // Compatible with deprecated r0
+                        rStart = parsePercent(r0, size / 2);
+                    }
+                    const r = levelModel.get('r', true);
+                    if (r != null) {
+                        // Compatible with deprecated r
+                        rEnd = parsePercent(r, size / 2);
+                    }
+
+                    // level-specific radius should override that of series
+                    let radius: number | number[] = levelModel.get('radius', true);
+                    if (radius != null) {
+                        if (typeof radius === 'number') {

Review comment:
       radius can be `string`. Also, I'm thinking there is no need to support a single number for `levels.radius`. `innerRadius` and `outerRadius` are always needed. Not like `pie`, in which the `innerRadius` may be 0.




-- 
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 #15706: fix(sunburst): radius in levels

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



##########
File path: src/chart/sunburst/sunburstLayout.ts
##########
@@ -119,16 +120,28 @@ export default function sunburstLayout(
                 let rStart = r0 + rPerLevel * depth;
                 let rEnd = r0 + rPerLevel * (depth + 1);
 
-                const itemModel = node.getModel<SunburstSeriesNodeItemOption>();
-                // @ts-ignore. TODO this is not provided to developer yet. Rename it.
-                if (itemModel.get('r0') != null) {
-                    // @ts-ignore
-                    rStart = parsePercent(itemModel.get('r0'), size / 2);
-                }
-                // @ts-ignore
-                if (itemModel.get('r') != null) {
-                    // @ts-ignore
-                    rEnd = parsePercent(itemModel.get('r'), size / 2);
+                const levelModel = seriesModel.getLevelModel(node);
+                if (levelModel) {
+                    const r0 = levelModel.get('r0', true);

Review comment:
       The code can be tighter:
   ```ts
   let r0: number | percent = levelModel.get('r0', true);
   let r1: number | percent = levelModel.get('r1', true);
   let radius: number | number[] = levelModel.get('radius', true);
   if (radius != null) {
     if (zrUtil.isArray(radius)) {
       r0 = radius[0];
       r1 = radius[1]
     }
     else {
        // I think there is no need to handle this case.
        r0 = r1 = radius;
      }
   }
   r0 != null && (rStart = parsePercent(radius[0], size / 2));
   r1 != null && (rEnd = parsePercent(radius[1], size / 2));
   ```

##########
File path: src/chart/sunburst/sunburstLayout.ts
##########
@@ -119,16 +120,28 @@ export default function sunburstLayout(
                 let rStart = r0 + rPerLevel * depth;
                 let rEnd = r0 + rPerLevel * (depth + 1);
 
-                const itemModel = node.getModel<SunburstSeriesNodeItemOption>();
-                // @ts-ignore. TODO this is not provided to developer yet. Rename it.
-                if (itemModel.get('r0') != null) {
-                    // @ts-ignore
-                    rStart = parsePercent(itemModel.get('r0'), size / 2);
-                }
-                // @ts-ignore
-                if (itemModel.get('r') != null) {
-                    // @ts-ignore
-                    rEnd = parsePercent(itemModel.get('r'), size / 2);
+                const levelModel = seriesModel.getLevelModel(node);
+                if (levelModel) {
+                    const r0 = levelModel.get('r0', true);

Review comment:
       The code can be tighter:
   ```ts
   let r0: number | percent = levelModel.get('r0', true);
   let r1: number | percent = levelModel.get('r1', true);
   const radius: number | number[] = levelModel.get('radius', true);
   if (radius != null) {
     if (zrUtil.isArray(radius)) {
       r0 = radius[0];
       r1 = radius[1]
     }
     else {
        // I think there is no need to handle this case.
        r0 = r1 = radius;
      }
   }
   r0 != null && (rStart = parsePercent(radius[0], size / 2));
   r1 != null && (rEnd = parsePercent(radius[1], size / 2));
   ```




-- 
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