[英]Angular nvd3 forced directed graph - increase edge length
I am using angular nvd3 to plot a forced directed graph. 我正在使用角度nvd3绘制强制有向图。
http://krispo.github.io/angular-nvd3/#/forceDirectedGraph
These are the configurations : 这些是配置:
$scope.graphOption = {
chart: {
type: 'forceDirectedGraph',
height: 450,
width: (function(){ return nv.utils.windowSize().width - 350 })(),
margin:{top: 20, right: 20, bottom: 20, left: 20},
color: function(d){
return color(d.group)
},
charge: -300,
tooltip: {
contentGenerator: function (key, x, y, e, graph) {
var ttContent = $scope.getTooltilContent(key);
return '<div class="nvd3-tooltip-wls">'+ttContent+'</div>';
}
},
nodeExtras: function(node) {
node && node
.append("text")
.text(function(d) { return d.name })
.style('font-size', '11px');
}
}
};
HTML : HTML:
<nvd3 id="graphPlot" options="graphOption" data="graphData"></nvd3>
Graph edges are too short and nodes are too close, i wanted to increase edge length. 图形边缘太短,节点太近,我想增加边缘长度。 This is the output :
这是输出:
This link gives option to modify link distance : 该链接提供了修改链接距离的选项:
http://bl.ocks.org/sathomas/11550728
I tried like this in chrome console, it didnt change any thing : 我在chrome控制台中尝试过这种方法,它没有改变任何东西:
var force = d3.layout.force()
.size([1000, 450])
.nodes(nodes)
.links(links);
force.linkDistance(1000);
force.start()
Edit: I also want to show font-awesome
icon on some of the nodes. 编辑:我也想在某些节点上显示
font-awesome
图标。
You can play with both the values of linkStrength
and linkDist
attributes to adjust the graph's shape. 您可以同时使用
linkStrength
和linkDist
属性的值来调整图形的形状。 Decrease linkStrength
, perhaps to 0.05 instead of 0.1, and increase linkDist
(default 30 in the example). 将
linkStrength
减小到0.05而不是0.1,然后增加linkDist
(在示例中默认为30)。
$scope.graphOption = {
chart: {
type: 'forceDirectedGraph',
// [...]
charge: -300,
linkStrength: .05,
linkDist: 100,
// [...]
}
};
All the supported chart options are visible when you click on "extended" at the top right-hand-side of the example page . 当您单击示例页面右上角的“扩展”时,所有支持的图表选项均可见。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.