From 45fb5f2bdda2bbe5fd6bae887a6dfa230e69bb62 Mon Sep 17 00:00:00 2001 From: shefali shetty Date: Thu, 3 May 2012 12:01:36 +0530 Subject: a gnowsys-studio/ --- gstudio/templates/gstudio/graph1.html | 2 +- gstudio/templates/gstudio/skeleton.html | 370 ++++++++++++-------------------- 2 files changed, 140 insertions(+), 232 deletions(-) (limited to 'gstudio/templates') diff --git a/gstudio/templates/gstudio/graph1.html b/gstudio/templates/gstudio/graph1.html index 587b703b..ab66e51f 100644 --- a/gstudio/templates/gstudio/graph1.html +++ b/gstudio/templates/gstudio/graph1.html @@ -94,7 +94,7 @@ $(function() { success : function(json) { var force; - + // this contains all the nodes as a dict with _id as the key var nodes_by_id = _.reduce(json.node_metadata, function(acc, n) { diff --git a/gstudio/templates/gstudio/skeleton.html b/gstudio/templates/gstudio/skeleton.html index 1fcf9ccf..1e790ff3 100644 --- a/gstudio/templates/gstudio/skeleton.html +++ b/gstudio/templates/gstudio/skeleton.html @@ -16,14 +16,14 @@ .mainnode{ font: 15px sans-serif; - fill:"red"; + fill:"black"; border-width: 1px; font-weight:bold; border-color: gray; } .relnode { - font: 10px sans-serif; + font: 12px sans-serif; font-weight:bold; fill:#000; } @@ -32,8 +32,9 @@ .node { border-width: 1px; border-color: gray; - fill:"green"; - font: 10px sans-serif; + font: 12px sans-serif; + fill:#25587E; + font-weight:bold; } body { background-color: white; @@ -45,8 +46,8 @@ display: block; } svg { - margin-left: 10%; - margin-right: 10%; + margin-left: 50%; + margin-right: 50%; display: block; position: absolute; } @@ -168,52 +169,18 @@ -- cgit v1.2.3-70-g09d2 From 2b8a427dc2defae171a30abdf9dc54a28ae24857 Mon Sep 17 00:00:00 2001 From: shefali shetty Date: Fri, 4 May 2012 16:11:44 +0530 Subject: Graphs are merged by the'Cntrl+click' event and by the 'click' event,hyperlink is enabled --- gstudio/templates/gstudio/skeleton.html | 49 ++++++++++++++++++----------- objectapp/templates/objectapp/skeleton.html | 31 +++++++++++------- 2 files changed, 51 insertions(+), 29 deletions(-) (limited to 'gstudio/templates') diff --git a/gstudio/templates/gstudio/skeleton.html b/gstudio/templates/gstudio/skeleton.html index 1e790ff3..41df7564 100644 --- a/gstudio/templates/gstudio/skeleton.html +++ b/gstudio/templates/gstudio/skeleton.html @@ -10,7 +10,7 @@ } .nodetext { #pointer-events: none; - font: 10px Serif; + font: 12px Serif; font-style:italic; } .mainnode{ @@ -195,7 +195,7 @@ function init(a,b) return e; }).filter(function(e){ - return nodes_by_id[e.from] && nodes_by_id[e.to]&& e.type!="title" + return nodes_by_id[e.from] && nodes_by_id[e.to]&& e.type!="title" && e.type!="content" }).value(); @@ -279,6 +279,9 @@ var a = 25 * s; force.links(edges); force.start(); + + + link = d3.select("#chart g.edges").selectAll("line.link") .data(edges, function(e){return e.from + "-" + e.to + "-" + e.type}); @@ -304,8 +307,7 @@ var a = 25 * s; }) .append("a") - .text(function(d) { return d.type; }); - + .text(function(d) { return d.type; }); @@ -316,30 +318,40 @@ var a = 25 * s; var new_g = node.enter().append("svg:a") - .attr("class", function(d) { var e=(d._id).charAt(0); if (d._id==key) return "mainnode"; else if (e=="-") return "nodetext"; else if (isNaN(d._id)) return "relnode" ; else return "node"; }) - - //.attr("xlink:href",function(d){return d.url;}) + .attr("class", function(d) { var e=(d._id).charAt(0); if (d._id==key) return "mainnode"; else if (e=="-") return "nodetext"; else if (isNaN(d._id)) return "relnode" ; else return "node"; }) + .call(force.drag); - +$(window).bind('keydown',function(event){ + if(17==event.keyCode){ new_g.on("click",function(d){ - if(d._id>0) + if(d._id>0 && d.expanded=="false") { d3.select("#amazingViz").remove(); 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; metadata=_.union(new_metadata,metadata); relations=_.union(new_relations,relations); init(metadata,relations); load(d._id) }) - } - }); + + }); + +} +}); + + + + new_g.on("click", function(d) { + + new_g.attr("xlink:href",function(d){return d.url;}); + }); /*new_g.append("svg:ellipse") @@ -356,8 +368,9 @@ var a = 25 * s; var text1 = new_g.append("svg:text") .attr("class",function(d) {var e=(d._id).charAt(0); if (d._id==key) return "mainnode";else if (e=="-") return "nodetext"; else if (isNaN(d._id)) return "relnode"; else return "node"; }) - .attr("dy", 20) - .attr("dx", 25) + .attr("y", 20) + .attr("x", 25) + .attr("dy", ".35em") .attr("text-anchor","middle") // .attr("style",function text(d) { if ((d._id)>0) return "font-size:9.00pt;fill:blue;" ; else return "font-size:9.00pt;fill:black;"}) @@ -370,9 +383,9 @@ var a = 25 * s; new_g.filter(function(d) { return (d._id).charAt(0)=="-"; }).append("svg:rect") - .attr("x",bbox.x-5) + .attr("x",bbox.x-22) .attr("y", bbox.y) - .attr("width", function(d) {var ttx=d.screen_name ; return (ttx.length + bbox.width)}) + .attr("width", function(d) {var ttx=d.screen_name ; return (ttx.length+bbox.width+40)}) .attr("height", bbox.height) .call(force.drag) .style("fill-opacity", ".1") @@ -388,9 +401,9 @@ var a = 25 * s; .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 + 45)}) + .attr("rx",function(d) {var ttx=d.screen_name ; return (ttx.length + 40)}) .attr("ry",13) - .style("fill-opacity", ".5") + .style("fill-opacity", ".2") .style("stroke", "#666") .style("stroke-width", "1.5px") .style("fill", function color(d) {var e=(d._id).charAt(0); if (d.expanded=="true") return "red"; else return "none"}); diff --git a/objectapp/templates/objectapp/skeleton.html b/objectapp/templates/objectapp/skeleton.html index 34bc9b57..2990d9a5 100644 --- a/objectapp/templates/objectapp/skeleton.html +++ b/objectapp/templates/objectapp/skeleton.html @@ -11,7 +11,7 @@ } .nodetext { #pointer-events: none; - font: 10px Serif; + font: 12px Serif; font-style:italic; } .mainnode{ @@ -24,7 +24,7 @@ } .relnode { - font: 10px sans-serif; + font: 12px sans-serif; font-weight:bold; fill:#000; } @@ -206,7 +206,7 @@ function init(a,b) return e; }).filter(function(e){ - return nodes_by_id[e.from] && nodes_by_id[e.to]&& e.type!="title" + return nodes_by_id[e.from] && nodes_by_id[e.to]&& e.type!="title" && e.type!="content" }).value(); @@ -327,16 +327,17 @@ var a = 800 * s; var new_g = node.enter().append("svg:a") - .attr("class", function(d) { var e=(d._id).charAt(0); if (d._id==key) return "mainnode"; else if (e=="-") return "nodetext"; else if (isNaN(d._id)) return "relnode" ; else return "node"; }) - - //.attr("xlink:href",function(d){return d.url;}) + .attr("class", function(d) { var e=(d._id).charAt(0); if (d._id==key) return "mainnode"; else if (e=="-") return "nodetext"; else if (isNaN(d._id)) return "relnode" ; else return "node"; }) + .call(force.drag); +$(window).bind('keydown',function(event){ + if(17==event.keyCode){ new_g.on("click",function(d){ - if(d._id>0) + if(d._id>0 && d.expanded=="false") { d3.select("#amazingViz").remove(); d.expanded="true"; @@ -351,6 +352,13 @@ var a = 800 * s; } }); +} +}); + + new_g.on("click", function(d) { + + new_g.attr("xlink:href",function(d){return d.url;}); + }); /*new_g.append("svg:ellipse") @@ -381,15 +389,16 @@ var a = 800 * s; new_g.filter(function(d) { return (d._id).charAt(0)=="-"; }).append("svg:rect") - .attr("x",bbox.x-5) + .attr("x",bbox.x-22) .attr("y", bbox.y) - .attr("width", function(d) {var ttx=d.screen_name ; return (ttx.length + bbox.width)}) + .attr("width", function(d) {var ttx=d.screen_name ; return (ttx.length +bbox.width+40)}) .attr("height", bbox.height) .call(force.drag) .style("fill-opacity", ".1") .style("stroke", "#000") .style("stroke-width","1px" ); + @@ -399,9 +408,9 @@ var a = 800 * s; .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 + 45)}) + .attr("rx",function(d) {var ttx=d.screen_name ; return (ttx.length + 40)}) .attr("ry",13) - .style("fill-opacity", ".5") + .style("fill-opacity", ".2") .style("stroke", "#666") .style("stroke-width", "1.5px") .style("fill", function color(d) {var e=(d._id).charAt(0); if (d.expanded=="true") return "red"; else return "none"}); -- cgit v1.2.3-70-g09d2 From be7765e07e626c8be1e3d433ddb2e4f84259cf59 Mon Sep 17 00:00:00 2001 From: shefali shetty Date: Wed, 9 May 2012 11:24:16 +0530 Subject: bug related to 'relation' is rectified --- gstudio/models.py | 32 +++++++++++++++++++++-------- gstudio/static/gstudio/css/screen.css | 6 +++--- gstudio/templates/gstudio/skeleton.html | 19 +++++++++-------- objectapp/models.py | 24 +++++++++++++++++----- objectapp/static/objectapp/css/screen.css | 6 +++--- objectapp/templates/objectapp/skeleton.html | 2 +- 6 files changed, 61 insertions(+), 28 deletions(-) (limited to 'gstudio/templates') diff --git a/gstudio/models.py b/gstudio/models.py index 65262cc4..0b6886de 100644 --- a/gstudio/models.py +++ b/gstudio/models.py @@ -729,7 +729,7 @@ class Nodetype(Node): predicate_id = {} for key in nbh.keys(): - val = str(counter)+"a" + val = str(counter) + "a" predicate_id[key] = val counter = counter + 1 #print predicate_id @@ -750,14 +750,30 @@ class Nodetype(Node): #g_json[str(key)].append({"from":self.id , "to":predicate_id[key],"value":1, "level":1 }) g_json["relations"].append({"from":self.id ,"type":str(key),"value":1,"to":predicate_id[key] }) + if not isinstance(nbh[key],basestring): for item in nbh[key]: - #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[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 }) + if item.reftype!="Relation": + # 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[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 }) + + else: + + if item.left_subject.id==self.id: + item1=item.right_subject + elif item.right_subject.id==self.id: + item1=item.left_subject + + g_json["node_metadata"].append({"_id":str(item1.id),"screen_name":item1.title,"title":self.title, "url":item1.get_absolute_url(),"expanded":"false"}) + + # 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":item1.id }) else: #value={nbh["plural"]:"a4",nbh["altnames"]:"a5"} @@ -765,7 +781,7 @@ class Nodetype(Node): #for item in value.keys(): g_json["node_metadata"].append({"_id":(str(attr_counter)+"a"),"screen_name":nbh[key]}) #g_json[str(key)].append({"from":predicate_id[key] , "to":attr_counter ,"value":1, "level":2 }) - g_json["relations"].append({"from":predicate_id[key] ,"type":str(key) ,"value":1,"to":(str(attr_counter)+"a") }) + g_json["relations"].append({"from":predicate_id[key] ,"type":str(key) ,"value":1,"to":(str(attr_counter)+"a")}) attr_counter-=1 except: diff --git a/gstudio/static/gstudio/css/screen.css b/gstudio/static/gstudio/css/screen.css index f786de60..a5e3ba39 100644 --- a/gstudio/static/gstudio/css/screen.css +++ b/gstudio/static/gstudio/css/screen.css @@ -475,9 +475,9 @@ a:hover { text-decoration: underline; } font-weight: bold; } #graphcss { - margin-left: 224px; - margin-right: 150px; - margin-top: 1px; + margin-left: 180px; + margin-right: 200px; + margin-top: -150px; position: absolute; width: 300px; height: 900px diff --git a/gstudio/templates/gstudio/skeleton.html b/gstudio/templates/gstudio/skeleton.html index 41df7564..c5a15c3c 100644 --- a/gstudio/templates/gstudio/skeleton.html +++ b/gstudio/templates/gstudio/skeleton.html @@ -192,10 +192,10 @@ function init(a,b) all_edges =_(b).chain().map(function(e) { e.source = nodes_by_id[e.from]; e.target = nodes_by_id[e.to]; - + //`e.type = nodes_by_id[e.type] return e; }).filter(function(e){ - return nodes_by_id[e.from] && nodes_by_id[e.to]&& e.type!="title" && e.type!="content" + return nodes_by_id[e.from] && nodes_by_id[e.to]&& e.type!="title" && e.type!="content" }).value(); @@ -253,7 +253,7 @@ var a = 25 * s; .charge(-5000) .friction(0.7) .gravity(0.7) - .linkDistance(75) + .linkDistance(50) .nodes([]) .links([]) .size([w, h]) @@ -304,12 +304,13 @@ var a = 25 * s; }) .attr("text", function(d) { return d.type; - }) + }); + + + + - .append("a") - .text(function(d) { return d.type; }); - var node = d3.select("#chart g.nodes").selectAll("g.node").data(nodes); @@ -383,7 +384,8 @@ $(window).bind('keydown',function(event){ new_g.filter(function(d) { return (d._id).charAt(0)=="-"; }).append("svg:rect") - .attr("x",bbox.x-22) + .attr("x",bbox.x-22 + ) .attr("y", bbox.y) .attr("width", function(d) {var ttx=d.screen_name ; return (ttx.length+bbox.width+40)}) .attr("height", bbox.height) @@ -411,6 +413,7 @@ $(window).bind('keydown',function(event){ + node.exit().remove(); diff --git a/objectapp/models.py b/objectapp/models.py index a27832af..97501c81 100644 --- a/objectapp/models.py +++ b/objectapp/models.py @@ -391,13 +391,27 @@ class Gbobject(Node): g_json["relations"].append({"from":self.id ,"type":str(key),"value":1,"to":predicate_id[key] }) if not isinstance(nbh[key],basestring): for item in nbh[key]: + if item.reftype!="Relation": # 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[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 }) - + 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[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 }) + + else: + + if item.left_subject.id==self.id: + item1=item.right_subject + elif item.right_subject.id==self.id: + item1=item.left_subject + + g_json["node_metadata"].append({"_id":str(item1.id),"screen_name":item1.title,"title":self.title, "url":item1.get_absolute_url(),"expanded":"false"}) + + # 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":item1.id }) else: #value={nbh["plural"]:"a4",nbh["altnames"]:"a5"} #this_node[str(key)]=nbh[key] key, nbh[key] diff --git a/objectapp/static/objectapp/css/screen.css b/objectapp/static/objectapp/css/screen.css index c69ca997..fd913f71 100644 --- a/objectapp/static/objectapp/css/screen.css +++ b/objectapp/static/objectapp/css/screen.css @@ -479,9 +479,9 @@ a:hover { text-decoration: underline; } font-weight: bold; } #graphcss{ - margin-left: 230px; - margin-right: 150px; - margin-top: 1px; + margin-left: 180px; + margin-right: 200px; + margin-top: -150px; position: absolute; width: 300px; height: 900px diff --git a/objectapp/templates/objectapp/skeleton.html b/objectapp/templates/objectapp/skeleton.html index 2990d9a5..f3325b87 100644 --- a/objectapp/templates/objectapp/skeleton.html +++ b/objectapp/templates/objectapp/skeleton.html @@ -264,7 +264,7 @@ var a = 800 * s; .charge(-5000) .friction(0.7) .gravity(0.7) - .linkDistance(75) + .linkDistance(50) .nodes([]) .links([]) .size([w, h]) -- cgit v1.2.3-70-g09d2