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 faddfef  modify the code struct of the sankeyLayout.js
faddfef is described below

commit faddfef330ba73628630bf6a142a28ccaa786833
Author: deqingli <annong...@gmail.com>
AuthorDate: Tue Apr 10 13:30:08 2018 +0800

    modify the code struct of the sankeyLayout.js
---
 src/chart/sankey/SankeySeries.js |  2 +-
 src/chart/sankey/sankeyLayout.js | 45 ++++++++++++++++++++++++++++++----------
 2 files changed, 35 insertions(+), 12 deletions(-)

diff --git a/src/chart/sankey/SankeySeries.js b/src/chart/sankey/SankeySeries.js
index 60a7b91..9a4e798 100644
--- a/src/chart/sankey/SankeySeries.js
+++ b/src/chart/sankey/SankeySeries.js
@@ -23,7 +23,7 @@ var SankeySeries = SeriesModel.extend({
         var links = option.edges || option.links;
         var nodes = option.data || option.nodes;
         if (nodes && links) {
-            var graph = createGraphFromNodeEdge(nodes, links, this, false);
+            var graph = createGraphFromNodeEdge(nodes, links, this, true);
             return graph.data;
         }
     },
diff --git a/src/chart/sankey/sankeyLayout.js b/src/chart/sankey/sankeyLayout.js
index ce0258e..d324018 100644
--- a/src/chart/sankey/sankeyLayout.js
+++ b/src/chart/sankey/sankeyLayout.js
@@ -84,25 +84,48 @@ function computeNodeValues(nodes) {
  */
 function computeNodeBreadths(nodes, nodeWidth, width) {
     var remainNodes = nodes;
-    var nextNode = null;
+    // var computedNodes = [];
+    var nextNode = [];
     var x = 0;
     var kx = 0;
 
+    // while (remainNodes.length) {
+    //     nextNode = [];
+    //     for (var i = 0, len = remainNodes.length; i < len; i++) {
+    //         var node = remainNodes[i];
+    //         node.setLayout({x: x}, true);
+    //         node.setLayout({dx: nodeWidth}, true);
+    //         // if (computedNodes.indexOf(node) === -1) {
+    //             // computedNodes.push(node);
+    //         // }
+            
+    //         for (var j = 0; j < node.outEdges.length; j++) {
+    //             var targetNode = node.outEdges[j].node2;
+    //             // if (computedNodes.indexOf(targetNode) === -1) {
+    //                 nextNode.push(node.outEdges[j].node2);
+
+    //             // } 
+    //         }
+    //     }
+    //     remainNodes = nextNode;
+    //     ++x;
+    // }
     while (remainNodes.length) {
-        nextNode = [];
-        for (var i = 0, len = remainNodes.length; i < len; i++) {
-            var node = remainNodes[i];
+        zrUtil.each(remainNodes, function (node) {
             node.setLayout({x: x}, true);
             node.setLayout({dx: nodeWidth}, true);
-            for (var j = 0, lenj = node.outEdges.length; j < lenj; j++) {
-                nextNode.push(node.outEdges[j].node2);
-            }
-        }
-        remainNodes = nextNode;
+            zrUtil.each(node.outEdges, function (edge) {
+                var targetNode = edge.node2;
+                if (nextNode.indexOf(targetNode) < 0) {
+                    nextNode.push(targetNode);
+                }
+            });
+        });
         ++x;
+        remainNodes = nextNode;
+        nextNode = [];
     }
-
-    // moveSinksRight(nodes, x);
+    moveSinksRight(nodes, x);
     kx = (width - nodeWidth) / (x - 1);
 
     scaleNodeBreadths(nodes, kx);

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