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

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


The following commit(s) were added to refs/heads/master by this push:
     new 012d613  resolve the remove node problem in the tree view
     new f5f4521  Merge branch 'master' of https://github.com/ecomfe/echarts
012d613 is described below

commit 012d613e122a8bfe669ac81eb85439867f3a14d0
Author: deqingli <annong...@gmail.com>
AuthorDate: Wed Apr 4 20:15:36 2018 +0800

    resolve the remove node problem in the tree view
---
 src/chart/tree.js                                 |   6 +-
 src/chart/tree/TreeSeries.js                      |   3 +-
 src/chart/tree/TreeView.js                        |   4 +-
 src/chart/tree/orthogonalLayout.js                |   7 --
 src/chart/tree/radialLayout.js                    |   7 --
 src/chart/tree/{commonLayout.js => treeLayout.js} |   9 +-
 test/README.md                                    |   4 -
 test/tree-removeNode.html                         | 132 ++++++++++++++++++++++
 8 files changed, 146 insertions(+), 26 deletions(-)

diff --git a/src/chart/tree.js b/src/chart/tree.js
index fec3db9..6eda1d2 100644
--- a/src/chart/tree.js
+++ b/src/chart/tree.js
@@ -5,9 +5,7 @@ import './tree/TreeView';
 import './tree/treeAction';
 
 import visualSymbol from '../visual/symbol';
-import orthogonalLayout from './tree/orthogonalLayout';
-import radialLayout from './tree/radialLayout';
+import treeLayout from './tree/treeLayout';
 
 echarts.registerVisual(visualSymbol('tree', 'circle'));
-echarts.registerLayout(orthogonalLayout);
-echarts.registerLayout(radialLayout);
+echarts.registerLayout(treeLayout);
diff --git a/src/chart/tree/TreeSeries.js b/src/chart/tree/TreeSeries.js
index 1256588..bab128d 100644
--- a/src/chart/tree/TreeSeries.js
+++ b/src/chart/tree/TreeSeries.js
@@ -48,6 +48,7 @@ export default SeriesModel.extend({
 
         tree.root.eachNode('preorder', function (node) {
             var item = node.hostTree.data.getRawDataItem(node.dataIndex);
+            // add item.collapsed != null, because users can collapse node 
original in the series.data.
             node.isExpand = (item && item.collapsed != null)
                 ? !item.collapsed
                 : node.depth <= expandTreeDepth;
@@ -57,7 +58,7 @@ export default SeriesModel.extend({
     },
     
     /**
-     * make the configuration 'orient' backward compatibly, with 'horizontal = 
LR', 'vertical = TB'.
+     * Make the configuration 'orient' backward compatibly, with 'horizontal = 
LR', 'vertical = TB'.
      * @returns {string} orient
      */
     getOrient: function () {
diff --git a/src/chart/tree/TreeView.js b/src/chart/tree/TreeView.js
index 2aae5b4..63b5ce0 100644
--- a/src/chart/tree/TreeView.js
+++ b/src/chart/tree/TreeView.js
@@ -76,7 +76,7 @@ export default echarts.extendChartView({
             .update(function (newIdx, oldIdx) {
                 var symbolEl = oldData.getItemGraphicEl(oldIdx);
                 if (!symbolNeedsDraw(data, newIdx)) {
-                    symbolEl && removeNode(data, newIdx, symbolEl, group, 
seriesModel, seriesScope);
+                    symbolEl && removeNode(oldData, oldIdx, symbolEl, group, 
seriesModel, seriesScope);
                     return;
                 }
                 // update  node and edge
@@ -84,7 +84,7 @@ export default echarts.extendChartView({
             })
             .remove(function (oldIdx) {
                 var symbolEl = oldData.getItemGraphicEl(oldIdx);
-                removeNode(data, oldIdx, symbolEl, group, seriesModel, 
seriesScope);
+                removeNode(oldData, oldIdx, symbolEl, group, seriesModel, 
seriesScope);
             })
             .execute();
 
diff --git a/src/chart/tree/orthogonalLayout.js 
b/src/chart/tree/orthogonalLayout.js
deleted file mode 100644
index ce87c37..0000000
--- a/src/chart/tree/orthogonalLayout.js
+++ /dev/null
@@ -1,7 +0,0 @@
-import commonLayout from './commonLayout';
-
-export default function (ecModel, api) {
-    ecModel.eachSeriesByType('tree', function (seriesModel) {
-        commonLayout(seriesModel, api);
-    });
-}
\ No newline at end of file
diff --git a/src/chart/tree/radialLayout.js b/src/chart/tree/radialLayout.js
deleted file mode 100644
index ce87c37..0000000
--- a/src/chart/tree/radialLayout.js
+++ /dev/null
@@ -1,7 +0,0 @@
-import commonLayout from './commonLayout';
-
-export default function (ecModel, api) {
-    ecModel.eachSeriesByType('tree', function (seriesModel) {
-        commonLayout(seriesModel, api);
-    });
-}
\ No newline at end of file
diff --git a/src/chart/tree/commonLayout.js b/src/chart/tree/treeLayout.js
similarity index 94%
rename from src/chart/tree/commonLayout.js
rename to src/chart/tree/treeLayout.js
index c655453..75dc7c6 100644
--- a/src/chart/tree/commonLayout.js
+++ b/src/chart/tree/treeLayout.js
@@ -11,7 +11,13 @@ import {
     getViewRect
 } from './layoutHelper';
 
-export default function (seriesModel, api) {
+export default function (ecModel, api) {
+    ecModel.eachSeriesByType('tree', function (seriesModel) {
+        commonLayout(seriesModel, api);
+    });
+}
+
+function commonLayout(seriesModel, api) {
 
     var layoutInfo = getViewRect(seriesModel, api);
     seriesModel.layoutInfo = layoutInfo;
@@ -35,6 +41,7 @@ export default function (seriesModel, api) {
 
     var virtualRoot = seriesModel.getData().tree.root;
     var realRoot = virtualRoot.children[0];
+
     init(virtualRoot);
     eachAfter(realRoot, firstWalk, separation);
     virtualRoot.hierNode.modifier = - realRoot.hierNode.prelim;
diff --git a/test/README.md b/test/README.md
index 9ecad94..e0fe0aa 100644
--- a/test/README.md
+++ b/test/README.md
@@ -1,13 +1,9 @@
 # Test Guide
 
-
-
 ## Functional Test
 
 Open `./*.html` files in Web Browsers.
 
-
-
 ## Unit Test
 
 ### Rendering-relevant
diff --git a/test/tree-removeNode.html b/test/tree-removeNode.html
new file mode 100644
index 0000000..5761746
--- /dev/null
+++ b/test/tree-removeNode.html
@@ -0,0 +1,132 @@
+<html>
+    <head>
+        <meta charset="utf-8" />
+        <meta name="viewport" content="width=device-width, initial-scale=1" />
+        <script src="lib/esl.js"></script>
+        <script src="lib/config.js"></script>
+        <script src="lib/jquery.min.js"></script>
+    </head>
+    <body>
+        <style>
+            html, body, #main {
+                width: 100%;
+                padding: 0;
+                margin: 0;
+                height: 100%;
+            }
+        </style>
+        <div id="main"></div>
+        <script>
+            require([
+                'echarts'
+                ], function (echarts) {
+                    var chart = echarts.init(document.getElementById('main'), 
null, {
+                    });
+
+                    window.onresize = function () {
+                        chart.resize();
+                    };
+
+                    var data = {
+                        "name": "flare",
+                        "children": [
+                            {
+                                "name": "flex",
+                                "children": [
+                                    {"name": "FlareVis", "value": 4116}
+                                ]
+                            },
+                            {
+                                "name": "scale",
+                                "children": [
+                                    {"name": "IScaleMap", "value": 2105},
+                                    {"name": "LinearScale", "value": 1316},
+                                    {"name": "LogScale", "value": 3151},
+                                    {"name": "OrdinalScale", "value": 3770},
+                                    {"name": "QuantileScale", "value": 2435},
+                                    {"name": "QuantitativeScale", "value": 
4839},
+                                    {"name": "RootScale", "value": 1756},
+                                    {"name": "Scale", "value": 4268},
+                                    {"name": "ScaleType", "value": 1821},
+                                    {"name": "TimeScale", "value": 5833}
+                               ]
+                            },
+                            {
+                                "name": "display",
+                                "children": [
+                                    {"name": "DirtySprite", "value": 8833}
+                               ]
+                            }
+                        ]
+                    };
+
+                    chart.setOption({
+
+                        tooltip: {
+                            trigger: 'item',
+                            triggerOn: 'mousemove'
+                        },
+
+                        legend: {
+                            top: '2%',
+                            left: '3%',
+                            orient: 'vertical',
+                            data: [{
+                                name: 'tree1',
+                                icon: 'rectangle'
+                            }],
+                            borderColor: '#c23531'
+                        },
+
+                        series:[
+                            {
+                                type: 'tree',
+                                id: '2',
+                                name: 'tree1',
+                                data: [data],
+
+                                top: '20%',
+                                left: '30%',
+                                bottom: '22%',
+                                right: '20%',
+
+                                symbolSize: 7,
+                                orient: 'RL',
+
+                                label: {
+                                    position: 'right',
+                                    verticalAlign: 'middle',
+                                    align: 'left' 
+                                },
+
+                                leaves: {
+                                    label: {
+                                            position: 'left',
+                                            verticalAlign: 'middle',
+                                            align: 'right'
+                                    }
+                                },
+                                
+                                expandAndCollapse: true,
+                                animationDuration: 550,
+                                animationDurationUpdate: 750
+                            }
+                        ]
+                    });
+
+                     setTimeout(function() {
+                        var cloneData = echarts.util.clone(data);
+                        cloneData.children.splice(0, 1);
+                        chart.setOption({
+                            series: [{
+                                type: 'tree',
+                                id: '2',
+                                data: [cloneData]
+                            }]
+                        }, false);
+                    }, 1000);
+
+                });
+        </script>
+    </body>
+</html>
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
deqin...@apache.org.

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

Reply via email to