1
0
Fork 0

GraphViewer: Community-Nodes are layouted much better, they will request more space if community is larger

This commit is contained in:
Michael Hackstein 2013-07-29 13:36:21 +02:00
parent 6c598253e2
commit 1624adc044
2 changed files with 12 additions and 7 deletions

View File

@ -64,14 +64,14 @@ function CommunityNode(parent, initial) {
getDistance = function(def) {
if (self._expanded) {
return 2 * def;
return 2 * def * Math.sqrt(nodeArray.length);
}
return def;
},
getCharge = function(def) {
if (self._expanded) {
return 8 * def;
return 4 * def * Math.sqrt(nodeArray.length);
}
return def;
},

View File

@ -52,17 +52,22 @@ function ForceLayouter(config) {
gravity = config.gravity || 0.01, // 0.08
charge = config.charge || -1000, // -240
*/
defaultCharge = config.charge || -600,
defaultDistance = config.distance || 160,
defaultCharge = config.charge || -600,
defaultDistance = config.distance || 80,
gravity = config.gravity || 0.08,
distance = function(d) {
var res = 0;
if (d.source._isCommunity) {
return d.source.getDistance(defaultDistance);
res += d.source.getDistance(defaultDistance);
} else {
res += defaultDistance;
}
if (d.target._isCommunity) {
return d.target.getDistance(defaultDistance);
res += d.target.getDistance(defaultDistance);
} else {
res += defaultDistance;
}
return defaultDistance;
return res;
},
charge = function(d) {
if (d._isCommunity) {