cytoscape.js - 带有 Dagre 布局的 Cytoscape.js 可以绘制垂直树吗?
问题描述
是否可以将其配置为显示垂直树而不是水平树?我所说的垂直是类似于 Windows 资源管理器的东西。
我们有一些用户更愿意以这种方式使用它。
解决方案
dagre 布局扩展有一个github 页面,其中包含一些有用的布局默认值:
var defaults = {
nodeSep: undefined, // the separation between adjacent nodes in the same rank
edgeSep: undefined, // the separation between adjacent edges in the same rank
rankSep: undefined, // the separation between adjacent nodes in the same rank
rankDir: undefined // 'TB' for top to bottom flow, 'LR' for left to right,
ranker: undefined, // Type of algorithm to assign a rank to each node in the input graph. Possible values: 'network-simplex', 'tight-tree' or 'longest-path'
minLen: function( edge ){ return 1; }, // number of ranks to keep between the source and target of the edge
edgeWeight: function( edge ){ return 1; }, // higher weight edges are generally made shorter and straighter than lower weight edges
// general layout options
fit: true, // whether to fit to viewport
padding: 30, // fit padding
spacingFactor: undefined, // Applies a multiplicative factor (>0) to expand or compress the overall area that the nodes take up
nodeDimensionsIncludeLabels: false, // whether labels should be included in determining the space used by a node
animate: false, // whether to transition the node positions
animateFilter: function( node, i ){ return true; }, // whether to animate specific nodes when animation is on; non-animated nodes immediately go to their final positions
animationDuration: 500, // duration of animation in ms if enabled
animationEasing: undefined, // easing of animation if enabled
boundingBox: undefined, // constrain layout bounds; { x1, y1, x2, y2 } or { x1, y1, w, h }
transform: function( node, pos ){ return pos; }, // a function that applies a transform to the final node position
ready: function(){}, // on layoutready
stop: function(){} // on layoutstop
}
这里重要的部分是rankDir,你可以在那里定义LR :)
推荐阅读
- r - for循环使用which for R中的唯一名称
- pdf - 从流中以 Xamarin 表单呈现 PDF
- c# - C#:如何从 WCF 响应中获取标头?
- php - 使用 Bootstrap3 的动态表无法正常工作。
- netsuite - 如何从 netsuite 中的 scriplet 获取脚本名称和 ID
- java - 将 Scrollview 添加到整个活动
- plugins - 以编程方式安装 SonarQube 插件
- c++ - 使用 Visual Studio C++ 按名称搜索目录中的文件
- r - rmarkdown 中的 JSON 树
- doctrine - 获取 Doctrine 鉴别器值