You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by ov...@apache.org on 2020/06/03 06:15:28 UTC

[incubator-echarts] branch fix-12223 created (now 9a9d829)

This is an automated email from the ASF dual-hosted git repository.

ovilia pushed a change to branch fix-12223
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git.


      at 9a9d829  fix(sunburst): enables label formatter in levels #12223

This branch includes the following new commits:

     new 9a9d829  fix(sunburst): enables label formatter in levels #12223

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



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


[incubator-echarts] 01/01: fix(sunburst): enables label formatter in levels #12223

Posted by ov...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ovilia pushed a commit to branch fix-12223
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git

commit 9a9d829dcd69ea67e75c47861507c45b9acc30d9
Author: Ovilia <zw...@gmail.com>
AuthorDate: Wed Jun 3 14:02:55 2020 +0800

    fix(sunburst): enables label formatter in levels #12223
---
 src/chart/sunburst/SunburstPiece.js  |  6 +++++-
 src/chart/sunburst/SunburstSeries.js | 18 +++++++++++++++++-
 test/sunburst-visualMap.html         | 24 +++++++++++++++++++++++-
 3 files changed, 45 insertions(+), 3 deletions(-)

diff --git a/src/chart/sunburst/SunburstPiece.js b/src/chart/sunburst/SunburstPiece.js
index f64e5ab7..dad2efb 100644
--- a/src/chart/sunburst/SunburstPiece.js
+++ b/src/chart/sunburst/SunburstPiece.js
@@ -203,9 +203,13 @@ SunburstPieceProto._updateLabel = function (seriesModel, visualColor, state) {
         : itemModel.getModel(state + '.label');
     var labelHoverModel = itemModel.getModel('emphasis.label');
 
+    var labelFormatter = labelModel.get('formatter');
+    // Use normal formatter if no state formatter is defined
+    var labelState = labelFormatter ? state : 'normal';
+
     var text = zrUtil.retrieve(
         seriesModel.getFormattedLabel(
-            this.node.dataIndex, state, null, null, 'label'
+            this.node.dataIndex, labelState, null, null, 'label'
         ),
         this.node.name
     );
diff --git a/src/chart/sunburst/SunburstSeries.js b/src/chart/sunburst/SunburstSeries.js
index 4e43fc3..3bf66d2 100644
--- a/src/chart/sunburst/SunburstSeries.js
+++ b/src/chart/sunburst/SunburstSeries.js
@@ -20,6 +20,7 @@
 import * as zrUtil from 'zrender/src/core/util';
 import SeriesModel from '../../model/Series';
 import Tree from '../../data/Tree';
+import Model from '../../model/Model';
 import {wrapTreePathInfo} from '../helper/treeHelper';
 
 export default SeriesModel.extend({
@@ -41,6 +42,10 @@ export default SeriesModel.extend({
 
         // levels = option.levels = setDefault(levels, ecModel);
 
+        var levelModels = zrUtil.map(levels || [], function (levelDefine) {
+            return new Model(levelDefine, this, ecModel);
+        }, this);
+
         var treeOption = {};
 
         treeOption.levels = levels;
@@ -48,7 +53,18 @@ export default SeriesModel.extend({
         // Make sure always a new tree is created when setOption,
         // in TreemapView, we check whether oldTree === newTree
         // to choose mappings approach among old shapes and new shapes.
-        return Tree.createTree(root, this, treeOption).data;
+        var tree = Tree.createTree(root, this, treeOption, beforeLink);
+
+        function beforeLink(nodeData) {
+            nodeData.wrapMethod('getItemModel', function (model, idx) {
+                var node = tree.getNodeByDataIndex(idx);
+                var levelModel = levelModels[node.depth];
+                levelModel && (model.parentModel = levelModel);
+                return model;
+            });
+        }
+
+        return tree.data;
     },
 
     optionUpdated: function () {
diff --git a/test/sunburst-visualMap.html b/test/sunburst-visualMap.html
index 3d42df5..19cc7fe 100644
--- a/test/sunburst-visualMap.html
+++ b/test/sunburst-visualMap.html
@@ -128,7 +128,29 @@ under the License.
                         radius: [0, '90%'],
                         label: {
                             rotate: 'radial'
-                        }
+                        },
+                        levels: [{}, {
+                            label: {
+                                formatter: function (params) {
+                                    return 'First Level\n' + params.name;
+                                }
+                            },
+                            emphasis: {
+                                label: {
+                                    formatter: function (params) {
+                                        return 'emphasis\n' + params.name;
+                                    }
+                                }
+                            }
+                        }, {
+                            downplay: {
+                                label: {
+                                    formatter: function (params) {
+                                        return 'downplay\n' + params.name;
+                                    }
+                                }
+                            }
+                        }]
                     }
                 });
 


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