diff --git a/src/chart/sankey/sankeyLayout.js b/src/chart/sankey/sankeyLayout.js index f776e532cf..812d188411 100644 --- a/src/chart/sankey/sankeyLayout.js +++ b/src/chart/sankey/sankeyLayout.js @@ -87,7 +87,8 @@ function computeNodeValues(nodes) { zrUtil.each(nodes, function (node) { var value1 = sum(node.outEdges, getEdgeValue); var value2 = sum(node.inEdges, getEdgeValue); - var value = Math.max(value1, value2); + var nodeRawValue = node.getValue() || 0; + var value = Math.max(value1, value2, nodeRawValue); node.setLayout({value: value}, true); }); } @@ -431,12 +432,12 @@ function getEdgeValue(edge) { return edge.getValue(); } -function sum(array, f, orient) { +function sum(array, cb, orient) { var sum = 0; var len = array.length; var i = -1; while (++i < len) { - var value = +f.call(array, array[i], orient); + var value = +cb.call(array, array[i], orient); if (!isNaN(value)) { sum += value; } diff --git a/test/sankey-horizontal.html b/test/sankey-horizontal.html deleted file mode 100644 index 1cc87c0b19..0000000000 --- a/test/sankey-horizontal.html +++ /dev/null @@ -1,134 +0,0 @@ - - - - - - - - - - - - - -
- - - \ No newline at end of file diff --git a/test/sankey-vertical.html b/test/sankey-vertical.html index fb0ecb6332..e9012fee95 100644 --- a/test/sankey-vertical.html +++ b/test/sankey-vertical.html @@ -121,7 +121,8 @@ } }, { - name: 'b' + name: 'b', + value: 4 }, { name: 'a1' @@ -133,7 +134,8 @@ name: 'c' }, { - name: 'e' + name: 'e', + value: 10 } ], links: [ @@ -208,9 +210,10 @@ var chart = testHelper.create(echarts, 'main' , { title: [ - '1. when hover on node a1 the edge a1-a is green with opacity 0.2 and the node a is yellow with opacity 0.6', - '2. when hover on edge a1-a the color is green with opacity 0.2 and the node a is yellow with opacity 0.6', - '3. when hover on node a the color is yellow with opacity 0.6 and the edge a1-a is green with opacity 0.2' + "1. when hover on node 'a1' the edge 'a1-a' is green with opacity 0.2 and the node 'a' is yellow with opacity 0.6.", + "2. when hover on edge 'a1-a' the color is green with opacity 0.2 and the node 'a' is yellow with opacity 0.6.", + "3. when hover on node 'a' the color is yellow with opacity 0.6 and the edge 'a1-a' is green with opacity 0.2.", + "4. node 'e' and node 'b''s value is customized which is longer than the max sum of inEdges or outEdges." ], option: option, height: 700