You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by de...@apache.org on 2018/10/18 11:56:27 UTC
[incubator-echarts] branch master updated: feat(sankey): support
user specify the depth of the node in sankey diagram
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 527f841 feat(sankey): support user specify the depth of the node in sankey diagram
527f841 is described below
commit 527f8416cb87b05a1e7dfd6229587f611b7845f5
Author: deqingli <an...@gmail.com>
AuthorDate: Thu Oct 18 19:55:33 2018 +0800
feat(sankey): support user specify the depth of the node in sankey diagram
---
src/chart/sankey/sankeyLayout.js | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/src/chart/sankey/sankeyLayout.js b/src/chart/sankey/sankeyLayout.js
index 2a525e7..37fde87 100644
--- a/src/chart/sankey/sankeyLayout.js
+++ b/src/chart/sankey/sankeyLayout.js
@@ -146,6 +146,9 @@ function computeNodeBreadths(nodes, edges, nodeWidth, width, height, orient, nod
node.setLayout({x: x}, true);
node.setLayout({dx: nodeWidth}, true);
}
+
+ // node.setLayout({skDepth: x}, true);
+
for (var edgeIdx = 0; edgeIdx < node.outEdges.length; edgeIdx++) {
var edge = node.outEdges[edgeIdx];
var indexEdge = edges.indexOf(edge);
@@ -217,11 +220,27 @@ function computeNodeBreadths(nodes, edges, nodeWidth, width, height, orient, nod
moveSinksRight(nodes, x, orient);
}
+ var maxDepth = x - 1;
+ zrUtil.each(nodesCopy, function (node) {
+ var item = node.hostGraph.data.getRawDataItem(node.dataIndex);
+ if (item.depth && !isNaN(item.depth) && item.depth >= 0) {
+ if (item.depth > maxDepth) {
+ maxDepth = item.depth;
+ }
+ if (orient === 'vertical') {
+ node.setLayout({y: item.depth}, true);
+ }
+ else {
+ node.setLayout({x: item.depth}, true);
+ }
+ }
+ });
+
if (orient === 'vertical') {
- kx = (height - nodeWidth) / (x - 1);
+ kx = (height - nodeWidth) / maxDepth;
}
else {
- kx = (width - nodeWidth) / (x - 1);
+ kx = (width - nodeWidth) / maxDepth;
}
scaleNodeBreadths(nodes, kx, orient);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org