提交 7fa25721 编写于 作者: D deqingli

feat(sankey): support specify the node depth with constant y position

上级 527f8416
......@@ -80,8 +80,9 @@ function getViewRect(seriesModel, api) {
}
function layoutSankey(nodes, edges, nodeWidth, nodeGap, width, height, iterations, orient, nodeAlign) {
computeNodeBreadths(nodes, edges, nodeWidth, width, height, orient, nodeAlign);
var kx = computeNodeBreadths(nodes, edges, nodeWidth, width, height, orient, nodeAlign);
computeNodeDepths(nodes, edges, height, width, nodeGap, iterations, orient);
scaleNodeBreadths(nodes, kx, orient);
computeEdgeDepths(nodes, orient);
}
......@@ -227,12 +228,7 @@ function computeNodeBreadths(nodes, edges, nodeWidth, width, height, orient, nod
if (item.depth > maxDepth) {
maxDepth = item.depth;
}
if (orient === 'vertical') {
node.setLayout({y: item.depth}, true);
}
else {
node.setLayout({x: item.depth}, true);
}
node.setLayout({skDepth: item.depth}, true);
}
});
......@@ -242,7 +238,9 @@ function computeNodeBreadths(nodes, edges, nodeWidth, width, height, orient, nod
else {
kx = (width - nodeWidth) / maxDepth;
}
scaleNodeBreadths(nodes, kx, orient);
return kx;
// scaleNodeBreadths(nodes, kx, orient);
}
/**
......@@ -274,13 +272,24 @@ function moveSinksRight(nodes, x, orient) {
*/
function scaleNodeBreadths(nodes, kx, orient) {
zrUtil.each(nodes, function (node) {
if (orient === 'vertical') {
var nodeY = node.getLayout().y * kx;
node.setLayout({y: nodeY}, true);
if (node.getLayout().skDepth) {
var depth = node.getLayout().skDepth * kx;
if (orient === 'vertical') {
node.setLayout({y: depth}, true);
}
else {
node.setLayout({x: depth}, true);
}
}
else {
var nodeX = node.getLayout().x * kx;
node.setLayout({x: nodeX}, true);
if (orient === 'vertical') {
var nodeY = node.getLayout().y * kx;
node.setLayout({y: nodeY}, true);
}
else {
var nodeX = node.getLayout().x * kx;
node.setLayout({x: nodeX}, true);
}
}
});
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册