mirror of https://gitee.com/bigwinds/arangodb
GraphViewer: Positions of Edges are now always triggered on reshape, they do not disappear anymore on reshape withthout update
This commit is contained in:
parent
da560452c6
commit
9f5a53f5a3
|
@ -74,6 +74,20 @@ function EdgeShaper(parent, flags, idfunc) {
|
||||||
addUpdate = noop;
|
addUpdate = noop;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
getCorner = function(s, t) {
|
||||||
|
return Math.atan2(t.y - s.y, t.x - s.x) * 180 / Math.PI;
|
||||||
|
},
|
||||||
|
|
||||||
|
getDistance = function(s, t) {
|
||||||
|
return Math.sqrt(
|
||||||
|
(t.y - s.y)
|
||||||
|
* (t.y - s.y)
|
||||||
|
+ (t.x - s.x)
|
||||||
|
* (t.x - s.x)
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
addEvents = function (line, g) {
|
addEvents = function (line, g) {
|
||||||
_.each(events, function (func, type) {
|
_.each(events, function (func, type) {
|
||||||
g.on(type, func);
|
g.on(type, func);
|
||||||
|
@ -90,11 +104,26 @@ function EdgeShaper(parent, flags, idfunc) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
addPosition = function (line, g) {
|
||||||
|
g.attr("transform", function(d) {
|
||||||
|
return "translate("
|
||||||
|
+ d.source.x + ", "
|
||||||
|
+ d.source.y + ")"
|
||||||
|
+ "rotate("
|
||||||
|
+ getCorner(d.source, d.target)
|
||||||
|
+ ")";
|
||||||
|
});
|
||||||
|
line.attr("x2", function(d) {
|
||||||
|
return getDistance(d.source, d.target);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
addQue = function (line, g) {
|
addQue = function (line, g) {
|
||||||
addShape(line, g);
|
addShape(line, g);
|
||||||
addLabel(line, g);
|
addLabel(line, g);
|
||||||
addColor(line, g);
|
addColor(line, g);
|
||||||
addEvents(line, g);
|
addEvents(line, g);
|
||||||
|
addPosition(line, g);
|
||||||
},
|
},
|
||||||
|
|
||||||
shapeEdges = function (newEdges) {
|
shapeEdges = function (newEdges) {
|
||||||
|
@ -118,36 +147,11 @@ function EdgeShaper(parent, flags, idfunc) {
|
||||||
addQue(line, g);
|
addQue(line, g);
|
||||||
},
|
},
|
||||||
|
|
||||||
getCorner = function(s, t) {
|
|
||||||
return Math.atan2(t.y - s.y, t.x - s.x) * 180 / Math.PI;
|
|
||||||
},
|
|
||||||
|
|
||||||
getDistance = function(s, t) {
|
|
||||||
return Math.sqrt(
|
|
||||||
(t.y - s.y)
|
|
||||||
* (t.y - s.y)
|
|
||||||
+ (t.x - s.x)
|
|
||||||
* (t.x - s.x)
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
updateEdges = function () {
|
updateEdges = function () {
|
||||||
|
var g = self.parent.selectAll(".link"),
|
||||||
var edges = self.parent.selectAll(".link")
|
line = g.select("line");
|
||||||
// Set source x coordinate for edge.
|
addPosition(line, g);
|
||||||
.attr("transform", function(d) {
|
addUpdate(g);
|
||||||
return "translate("
|
|
||||||
+ d.source.x + ", "
|
|
||||||
+ d.source.y + ")"
|
|
||||||
+ "rotate("
|
|
||||||
+ getCorner(d.source, d.target)
|
|
||||||
+ ")";
|
|
||||||
});
|
|
||||||
edges.select("line")
|
|
||||||
.attr("x2", function(d) {
|
|
||||||
return getDistance(d.source, d.target);
|
|
||||||
});
|
|
||||||
addUpdate(edges);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
parseShapeFlag = function (shape) {
|
parseShapeFlag = function (shape) {
|
||||||
|
|
Loading…
Reference in New Issue