diff --git a/html/admin/js/graphViewer/graph/communityNode.js b/html/admin/js/graphViewer/graph/communityNode.js index f2bce315b6..42bba0201d 100644 --- a/html/admin/js/graphViewer/graph/communityNode.js +++ b/html/admin/js/graphViewer/graph/communityNode.js @@ -58,12 +58,18 @@ function CommunityNode(parent, initial) { // Private functions // //////////////////////////////////// - getDistance = function() { - return 160; + getDistance = function(def) { + if (self._expanded) { + return 2 * def; + } + return def; }, - getCharge = function() { - return -5000; + getCharge = function(def) { + if (self._expanded) { + return 8 * def; + } + return def; }, @@ -406,4 +412,37 @@ function CommunityNode(parent, initial) { this.expand = expand; this.shape = shapeAll; + + // TMP + this.getSourcePosition = function(e) { + if (self._expanded) { + var p = self.position; + var diff = e._source; + var x = p.x + diff.x; + var y = p.y + diff.y; + var z = p.z + diff.z; + return { + x: x, + y: y, + z: z + } + } + return self.position; + }; + + this.getTargetPosition = function(e) { + if (self._expanded) { + var p = self.position; + var diff = e._target; + var x = p.x + diff.x; + var y = p.y + diff.y; + var z = p.z + diff.z; + return { + x: x, + y: y, + z: z + } + } + return self.position; + }; } diff --git a/html/admin/js/graphViewer/graph/edgeShaper.js b/html/admin/js/graphViewer/graph/edgeShaper.js index 3e2b918932..f75f2eaa6a 100644 --- a/html/admin/js/graphViewer/graph/edgeShaper.js +++ b/html/admin/js/graphViewer/graph/edgeShaper.js @@ -53,7 +53,7 @@ function EdgeShaper(parent, flags, idfunc) { followEdge = {}, followEdgeG, idFunction = function(d) { - return d.source._id + "-" + d.target._id; + return d._id; }, noop = function (line, g) { @@ -109,13 +109,35 @@ function EdgeShaper(parent, flags, idfunc) { } }, + calculateNodePositions = function (e) { + var sp, tp, s, t; + s = e.source; + t = e.target; + if (s._isCommunity) { + sp = s.getSourcePosition(e); + } else { + sp = s.position; + } + if (t._isCommunity) { + tp = t.getTargetPosition(e); + } else { + tp = t.position; + } + return { + s: sp, + t: tp + }; + }, + addPosition = function (line, g) { + g.attr("transform", function(d) { + var p = calculateNodePositions(d); return "translate(" - + d.source.position.x + ", " - + d.source.position.y + ")" + + p.s.x + ", " + + p.s.y + ")" + "rotate(" - + getCorner(d.source.position, d.target.position) + + getCorner(p.s, p.t) + ")"; }); line.attr("x2", function(d) { @@ -127,7 +149,8 @@ function EdgeShaper(parent, flags, idfunc) { console.log(d.target); } */ - return getDistance(d.source.position, d.target.position); + var p = calculateNodePositions(d); + return getDistance(p.s, p.t); }); }, diff --git a/html/admin/js/graphViewer/graph/forceLayouter.js b/html/admin/js/graphViewer/graph/forceLayouter.js index 23b741dad3..25fcbbdccc 100644 --- a/html/admin/js/graphViewer/graph/forceLayouter.js +++ b/html/admin/js/graphViewer/graph/forceLayouter.js @@ -52,15 +52,23 @@ function ForceLayouter(config) { gravity = config.gravity || 0.01, // 0.08 charge = config.charge || -1000, // -240 */ - distance = config.distance || 160, + defaultCharge = config.charge || -600, + defaultDistance = config.distance || 160, gravity = config.gravity || 0.08, - //charge = config.charge || -600, - - charge = config.charge || function(d) { - if (d._isCommunity && d._expanded) { - return -5000; + distance = function(d) { + if (d.source._isCommunity) { + return d.source.getDistance(defaultDistance); } - return -600; + if (d.target._isCommunity) { + return d.target.getDistance(defaultDistance); + } + return defaultDistance; + }, + charge = function(d) { + if (d._isCommunity) { + return d.getCharge(defaultCharge); + } + return defaultCharge; }, onUpdate = config.onUpdate || function () {}, @@ -68,13 +76,13 @@ function ForceLayouter(config) { height = config.height || 680, parseConfig = function(config) { if (config.distance) { - force.linkDistance(config.distance); + defaultDistance = config.distance; } if (config.gravity) { force.gravity(config.gravity); } if (config.charge) { - force.charge(config.charge); + defaultCharge = config.charge; } };