summaryrefslogtreecommitdiff
path: root/gstudio/templates/gstudio/skeleton.html
diff options
context:
space:
mode:
authorsndt2012 <sndt2012@labadmin-desktop4.(none)>2012-04-02 15:33:33 +0530
committersndt2012 <sndt2012@labadmin-desktop4.(none)>2012-04-02 15:33:33 +0530
commit36ab2a314ed45a427383c3018a70f40e05d49849 (patch)
tree2547bd24946f6b8240c341773912f6ac47063c61 /gstudio/templates/gstudio/skeleton.html
parent1c20d8b0e031ff388285e9259c8f7e98fab97831 (diff)
downloadgnowsys-36ab2a314ed45a427383c3018a70f40e05d49849.tar.gz
JSON object function changed in models.Also hard coded edges removed.Data visulaization group
Diffstat (limited to 'gstudio/templates/gstudio/skeleton.html')
-rw-r--r--gstudio/templates/gstudio/skeleton.html84
1 files changed, 53 insertions, 31 deletions
diff --git a/gstudio/templates/gstudio/skeleton.html b/gstudio/templates/gstudio/skeleton.html
index cb25a87..72b0034 100644
--- a/gstudio/templates/gstudio/skeleton.html
+++ b/gstudio/templates/gstudio/skeleton.html
@@ -147,7 +147,7 @@
Javascript for Object type force graph
-->
- <script type="text/javascript" >
+<script type="text/javascript" >
var w = 700,
h = 300,
@@ -161,24 +161,50 @@
vis.append("svg:g").attr("class", "edges");
vis.append("svg:g").attr("class", "nodes");
-$(function() {
- $.ajax({
- url: '/nodetypes/graphs/graph_json/{{ object.id }}',
+
+
+
+var gid={{object.id}};
+$(function fgraph(gid) {
+
+
+ $.ajax({
+ url: '/gstudio/graphs/graph_json/{{object.id}}',
//crossDomain: true,
dataType: 'json',
- success : function(json) {
+ success : function (json) {
- //var node = NID.objects.get(slug='{{ slug }}');
+
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) {
+ var nodes_by_id = _.reduce(json.node_metadata, function(acc, n) {
acc[n._id] = n;
return acc;
}, {});
-
- var member_of = _(json.member_of).chain().map(function(e) {
+
+
+ all_edges=new Array();
+
+ //this contains all the links between the nodes
+ all_edges =_(json.relations).chain().map(function(e) {
+ e.source = nodes_by_id[e.from];
+ e.target = nodes_by_id[e.to];
+
+ return e;
+ }).filter(function(e){
+ return nodes_by_id[e.from] && nodes_by_id[e.to]&& e.type!="title"
+ }).value();
+
+
+ nodes_by_id[{{object.id}}].x = w/2.0;
+ nodes_by_id[{{object.id}}].y = h/2.0;
+
+
+
+
+ /* var member_of = _(json.member_of).chain().map(function(e) {
e.source = nodes_by_id[e.from];
e.target = nodes_by_id[e.to];
e.type = 'member_of';
@@ -245,15 +271,7 @@ $(function() {
return nodes_by_id[e.from] && nodes_by_id[e.to]
}).value();
- var content = _(json.content).chain().map(function(e) {
- e.source = nodes_by_id[e.from];
- e.target = nodes_by_id[e.to];
- e.type = 'content';
- return e;
- }).filter(function(e){
- return nodes_by_id[e.from] && nodes_by_id[e.to]
- }).value();
-
+
var contains_members = _(json.contains_members).chain().map(function(e) {
e.source = nodes_by_id[e.from];
e.target = nodes_by_id[e.to];
@@ -263,7 +281,7 @@ $(function() {
return nodes_by_id[e.from] && nodes_by_id[e.to]
}).value();
-
+
var type_of = _(json.type_of).chain().map(function(e) {
e.source = nodes_by_id[e.from];
@@ -323,13 +341,13 @@ $(function() {
}).filter(function(e){
return nodes_by_id[e.from] && nodes_by_id[e.to]
}).value();
-
+ */
- nodes_by_id[{{ object.id }}].x = w/2.0;
- nodes_by_id[{{ object.id }}].y = h/2.0;
-
- all_edges = new Array();
- all_edges = all_edges.concat(follows_edges, member_of, contains_members, contains_subtypes, mentions_edges, right_subjecttype_of, left_subjecttype_of, subjecttype_of, type_of,plural,altnames,contains_members,content, prior_nodes, posterior_nodes);
+
+
+ //all_edges = new Array();
+
+ //all_edges = all_edges.concat(follows_edges, member_of, contains_members, contains_subtypes, mentions_edges, right_subjecttype_of, left_subjecttype_of, subjecttype_of, type_of,plural,altnames,contains_members, prior_nodes, posterior_nodes);
/* all_edges.concat(follows_edges);
all_edges.concat(member_of_metatype);
all_edges.concat(contains_members);
@@ -404,13 +422,12 @@ $(function() {
var node = d3.select("#chart g.nodes").selectAll("g.node").data(nodes);
var new_g = node.enter().append("svg:a")
- .attr("class", function(d) { if (d._id=={{ object.id }}) return "mainnode"; else if (isNaN(d._id)) return "relnode"; else if ((d._id)<0) return "nodetext"; else return "node"; })
+ .attr("class", function(d) { if (d._id=={{ object.id }}) return "mainnode"; else if (isNaN(d._id)) return "relnode"; else if ((d._id)<0) return "nodetext"; else return "node"; })
+
.attr("xlink:href",function(d){return d.url;})
.call(force.drag);
-
-
-
+
new_g.append("svg:circle")
.attr("cx", function(d) { return d.x - w/2.0 + 15; })
.attr("cy", function(d) { return d.y - h/2.0 + 15; })
@@ -448,8 +465,11 @@ $(function() {
});
}
-
+
+
+
update(all_edges);
+
vis.style("opacity", 1e-6)
.transition()
.duration(1000)
@@ -473,7 +493,9 @@ $(function() {
});
-</script>
+</script>
+
+
</div>
</div>
<div>