Skip to content

Commit

Permalink
fix #11644
Browse files Browse the repository at this point in the history
  • Loading branch information
deqingli committed Jan 14, 2020
1 parent 2264b0d commit 3cc1049
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 142 deletions.
7 changes: 4 additions & 3 deletions src/chart/sankey/sankeyLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
Expand Down Expand Up @@ -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;
}
Expand Down
134 changes: 0 additions & 134 deletions test/sankey-horizontal.html

This file was deleted.

13 changes: 8 additions & 5 deletions test/sankey-vertical.html
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@
}
},
{
name: 'b'
name: 'b',
value: 4
},
{
name: 'a1'
Expand All @@ -133,7 +134,8 @@
name: 'c'
},
{
name: 'e'
name: 'e',
value: 10
}
],
links: [
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3cc1049

Please sign in to comment.