Some fixes in the arrows.

This commit is contained in:
mdtrooper 2016-03-03 15:38:15 +01:00
parent c6f65455e7
commit ba17caf0ec
2 changed files with 33 additions and 11 deletions

View File

@ -146,10 +146,6 @@ $this->nodes = json_decode('[
"x": 218.82, "x": 218.82,
"y": 931.19 "y": 931.19
}, },
{
"graph_id": 210,
"type": 2
},
{ {
"graph_id": "183", "graph_id": "183",
"id": "89", "id": "89",
@ -164,10 +160,6 @@ $this->nodes = json_decode('[
"x": 430.66, "x": 430.66,
"y": 599.03 "y": 599.03
}, },
{
"graph_id": 211,
"type": 2
},
{ {
"graph_id": "196", "graph_id": "196",
"id": "412", "id": "412",
@ -178,11 +170,18 @@ $this->nodes = json_decode('[
{ {
"graph_id": 212, "graph_id": 212,
"type": 2 "type": 2
},
{
"graph_id": 213,
"type": 2
} }
]', true); ]', true);
//~ $this->edges = json_decode('[{"to":"165","from":"166","graph_id":208},{"to":"165","from":"169","graph_id":209},{"to":"179","from":"180","graph_id":210},{"to":"183","from":"184","graph_id":211},{"to":"183","from":"196","graph_id":212}]', true); $this->edges = json_decode(
$this->edges = json_decode('[{"to":"165","from":"166","graph_id":208}, {"to":"165","from":"169","graph_id":209}]', true); '[
{"to":"180","from":"184","graph_id":213},
{"to":"165","from":"166","graph_id":208},
{"to":"165","from":"169","graph_id":209}]', true);
//~ $this->edges = json_decode('[{"to":"165","from":"166","graph_id":208}]', true); //~ $this->edges = json_decode('[{"to":"165","from":"166","graph_id":208}]', true);

View File

@ -172,6 +172,22 @@ MapController.prototype.init_map = function() {
this.init_events(); this.init_events();
}; };
MapController.prototype.node_from_edge = function(id_graph) {
var exists = null;
$.each(edges, function(i, e) {
if (e.graph_id == id_graph) {
exists = i;
return false; // jquery.each break;
}
});
if (exists !== null)
return edges[exists];
else
return null;
}
MapController.prototype.exists_edge = function(id_graph) { MapController.prototype.exists_edge = function(id_graph) {
var exists = false; var exists = false;
@ -235,7 +251,14 @@ MapController.prototype.paint_nodes = function() {
.enter() .enter()
.append("g") .append("g")
.attr("class", "arrow") .attr("class", "arrow")
.attr("id", function(d) { return "arrow_" + d['graph_id'];}); .attr("id", function(d) { return "arrow_" + d['graph_id'];})
.attr("data-id", function(d) { return d['id'];})
.attr("data-to", function(d) {
return self.node_from_edge(d['graph_id'])["to"];})
.attr("data-from", function(d) {
return self.node_from_edge(d['graph_id'])["from"];});
create_arrow(arrow_layouts); create_arrow(arrow_layouts);