Cytoscape.js: 需要线性布局
Cytoscape.js: Needed linear layout
我正在尝试使用 cytoscape.js 创建网络图。有几个布局将从上到下设计节点和链接。其中之一是 "dagre" 布局。但是,我想要的是从左到右显示相同的布局。但我没有运气找到这样的选择。
有什么办法可以做到这一点。
我正在分享一张图片 url。
http://share.pho.to/9M6Sa。
它是两个图像的组合 A) 我正在使用 "dagre" 布局 B) 我需要的。
任何帮助将不胜感激。
谢谢
Chop 的建议很好,特别是因为许多布局只是包装外部库,如 Dagre。他的建议在实践中的一个例子:
cy.one('layoutstop', function(){
cy.nodes.positions(function(n){
var pos = n.position();
return { x: pos.y, y: pos.x };
});
cy.fit(); // fit to new node positions
}).layout({ /* my options... */ });
var cy = window.cy = cytoscape({
容器:document.getElementById('cy'),
boxSelectionEnabled : true,
autounselectify : true,
layout : {
name: 'dagre',
rankDir: 'LR' // this is left to right , dagre options(rankDir)
},
我正在尝试使用 cytoscape.js 创建网络图。有几个布局将从上到下设计节点和链接。其中之一是 "dagre" 布局。但是,我想要的是从左到右显示相同的布局。但我没有运气找到这样的选择。
有什么办法可以做到这一点。 我正在分享一张图片 url。 http://share.pho.to/9M6Sa。 它是两个图像的组合 A) 我正在使用 "dagre" 布局 B) 我需要的。
任何帮助将不胜感激。
谢谢
Chop 的建议很好,特别是因为许多布局只是包装外部库,如 Dagre。他的建议在实践中的一个例子:
cy.one('layoutstop', function(){
cy.nodes.positions(function(n){
var pos = n.position();
return { x: pos.y, y: pos.x };
});
cy.fit(); // fit to new node positions
}).layout({ /* my options... */ });
var cy = window.cy = cytoscape({ 容器:document.getElementById('cy'),
boxSelectionEnabled : true,
autounselectify : true,
layout : {
name: 'dagre',
rankDir: 'LR' // this is left to right , dagre options(rankDir)
},