diff options
author | shefali shetty <sshefali44@gmail.com> | 2012-05-09 14:16:09 +0530 |
---|---|---|
committer | shefali shetty <sshefali44@gmail.com> | 2012-05-09 14:16:09 +0530 |
commit | 06db97bafe284e9d974a869db4cb2b6bd86f39de (patch) | |
tree | f71faf7a5bccd8cdc8cd0842b578b308c153309b | |
parent | be7765e07e626c8be1e3d433ddb2e4f84259cf59 (diff) | |
download | gnowsys-06db97bafe284e9d974a869db4cb2b6bd86f39de.tar.gz |
Arrow marker added to the links
-rw-r--r-- | gstudio/models.py | 8 | ||||
-rw-r--r-- | gstudio/templates/gstudio/skeleton.html | 26 | ||||
-rw-r--r-- | objectapp/models.py | 4 | ||||
-rw-r--r-- | objectapp/templates/objectapp/skeleton.html | 30 |
4 files changed, 53 insertions, 15 deletions
diff --git a/gstudio/models.py b/gstudio/models.py index 0b6886d..f4715a5 100644 --- a/gstudio/models.py +++ b/gstudio/models.py @@ -722,7 +722,8 @@ class Nodetype(Node): g_json = {} g_json["node_metadata"]= [] g_json["relations"]=[] - + g_json["relset"]=[] + global counter global attr_counter nbh = self.get_nbh @@ -737,7 +738,8 @@ class Nodetype(Node): this_node = {"_id":str(self.id),"title":self.title,"screen_name":self.title, "url":self.get_absolute_url(),"expanded":"true"} - g_json["node_metadata"].append(this_node) + g_json["node_metadata"].append(this_node) + g_json["relset"].append(self.id) for key in predicate_id.keys(): if nbh[key]: @@ -757,6 +759,8 @@ class Nodetype(Node): # create nodes g_json["node_metadata"].append({"_id":str(item.id),"screen_name":item.title,"title":self.title, "url":item.get_absolute_url(),"expanded":"false"}) + g_json["relset"].append(item.id) + # g_json[str(key)].append({"from":predicate_id[key] , "to":item.id ,"value":1 }) #create links diff --git a/gstudio/templates/gstudio/skeleton.html b/gstudio/templates/gstudio/skeleton.html index c5a15c3..d179220 100644 --- a/gstudio/templates/gstudio/skeleton.html +++ b/gstudio/templates/gstudio/skeleton.html @@ -207,6 +207,7 @@ $(function fgraph() { $.getJSON('/nodetypes/graphs/graph_json/' + {{object.id}}, function (json1) { metadata=json1.node_metadata; relations=json1.relations; + relnset=json1.relset init(metadata,relations); load({{object.id}}) }); @@ -282,7 +283,7 @@ var a = 25 * s; - link = d3.select("#chart g.edges").selectAll("line.link") + link = d3.select("#chart g.edges").selectAll("line.link").select(this.arrowhead) .data(edges, function(e){return e.from + "-" + e.to + "-" + e.type}); link.enter().append("svg:line") @@ -304,13 +305,12 @@ var a = 25 * s; }) .attr("text", function(d) { return d.type; - }); + }) + .attr("marker-end", "url(#arrowhead)"); - - var node = d3.select("#chart g.nodes").selectAll("g.node").data(nodes); @@ -325,6 +325,21 @@ var a = 25 * s; + new_g.append("svg:marker") + .attr("id", "arrowhead") + .attr("viewBox","0 0 10 10") + .attr("refX","20") + .attr("refY","5") + .attr("markerUnits","strokeWidth") + .attr("markerWidth","9") + .attr("markerHeight","5") + .attr("orient","auto") + .append("svg:path") + .attr("d","M 0 0 L 10 5 L 0 10 z") + .attr("fill", "#6D6666"); + + + $(window).bind('keydown',function(event){ if(17==event.keyCode){ new_g.on("click",function(d){ @@ -334,7 +349,8 @@ $(window).bind('keydown',function(event){ d.expanded="true"; $.getJSON('/nodetypes/graphs/graph_json/' + d._id , function (json2) { new_metadata=json2.node_metadata; - new_relations=json2.relations; + new_relations=json2.relations; + new_relnset=json2.relset metadata=_.union(new_metadata,metadata); relations=_.union(new_relations,relations); init(metadata,relations); diff --git a/objectapp/models.py b/objectapp/models.py index 97501c8..2c56dbf 100644 --- a/objectapp/models.py +++ b/objectapp/models.py @@ -364,6 +364,7 @@ class Gbobject(Node): g_json = {} g_json["node_metadata"]= [] g_json["relations"]=[] + g_json["relset"]=[] global counter global attr_counter @@ -380,6 +381,7 @@ class Gbobject(Node): this_node = {"_id":str(self.id),"title":self.title,"screen_name":self.title, "url":self.get_absolute_url(),"expanded":"true"} g_json["node_metadata"].append(this_node) + g_json["relset"].append(self.id) for key in predicate_id.keys(): if nbh[key]: @@ -395,7 +397,7 @@ class Gbobject(Node): # create nodes g_json["node_metadata"].append({"_id":str(item.id),"screen_name":item.title,"title":self.title, "url":item.get_absolute_url(),"expanded":"false"}) - + g_json["relset"].append(item.id) # g_json[str(key)].append({"from":predicate_id[key] , "to":item.id ,"value":1 }) #create links g_json["relations"].append({"from":predicate_id[key] ,"type":str(key), "value":1,"to":item.id }) diff --git a/objectapp/templates/objectapp/skeleton.html b/objectapp/templates/objectapp/skeleton.html index f3325b8..2e08471 100644 --- a/objectapp/templates/objectapp/skeleton.html +++ b/objectapp/templates/objectapp/skeleton.html @@ -290,12 +290,12 @@ var a = 800 * s; force.links(edges); force.start(); - link = d3.select("#chart g.edges").selectAll("line.link") + link = d3.select("#chart g.edges").selectAll("line.link").select(this.arrowhead) .data(edges, function(e){return e.from + "-" + e.to + "-" + e.type}); link.enter().append("svg:line") .attr("class", "link") - .style("stroke-width", 2 /* function(d) { + .style("stroke-width", 2/* function(d) { return Math.sqrt(d.value); } */ ) .attr("x1", function(d) { @@ -313,9 +313,8 @@ var a = 800 * s; .attr("text", function(d) { return d.type; }) - - .append("a") - .text(function(d) { return d.type; }); + + .attr("marker-end", "url(#arrowhead)"); @@ -332,6 +331,23 @@ var a = 800 * s; .call(force.drag); + new_g.append("svg:marker") + .attr("id", "arrowhead") + .attr("viewBox","0 0 10 10") + .attr("refX","20") + .attr("refY","5") + .attr("markerUnits","strokeWidth") + .attr("markerWidth","9") + .attr("markerHeight","5") + .attr("orient","auto") + .append("svg:path") + .attr("d","M 0 0 L 10 5 L 0 10 z") + .attr("fill", "#6D6666"); + + + + + $(window).bind('keydown',function(event){ @@ -408,8 +424,8 @@ $(window).bind('keydown',function(event){ .attr("cx", bbox.x+25) .attr("cy", bbox.y+13) .call(force.drag) - .attr("rx",function(d) {var ttx=d.screen_name ; return (ttx.length + 40)}) - .attr("ry",13) + .attr("rx",function(d) {var ttx=d.screen_name ; return (ttx.length + 55)}) + .attr("ry",14) .style("fill-opacity", ".2") .style("stroke", "#666") .style("stroke-width", "1.5px") |