comparison d3s_examples/python-neo4jrestclient/static/index_sphaera.html @ 8:18ef6948d689

new d3s examples
author Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
date Thu, 01 Oct 2015 17:17:27 +0200
parents
children
comparison
equal deleted inserted replaced
7:45dad9e38c82 8:18ef6948d689
1 <html>
2 <head>
3 <meta name="viewport" content="width=device-width, initial-scale=1.0">
4 <link rel="stylesheet" href="http://neo4j-contrib.github.io/developer-resources/language-guides/assets/css/main.css">
5 <title>Neo4j Editions</title>
6 </head>
7
8 <body>
9
10 <div role="navigation" class="navbar navbar-default navbar-static-top">
11 <div class="container">
12 <div class="row">
13 <div class="col-sm-6 col-md-6">
14 <ul class="nav navbar-nav">
15 <li>
16 <form role="search" class="navbar-form" id="search">
17 <div class="form-group">
18 <input type="text" value="Matrix" placeholder="Search for Movie Title" class="form-control" name="search">
19 </div>
20 <button class="btn btn-default" type="submit">Search</button>
21 </form>
22 </li>
23 </ul>
24 </div>
25 <div class="navbar-header col-sm-6 col-md-6">
26 <div class="logo-well">
27 <a href="http://neo4j.com/developer-resources">
28 <img src="http://neo4j-contrib.github.io/developer-resources/language-guides/assets/img/logo-white.svg" alt="Neo4j World's Leading Graph Database" id="logo">
29 </a>
30 </div>
31 <div class="navbar-brand">
32 <div class="brand">Neo4j Movies</div>
33 </div>
34 </div>
35 </div>
36 </div>
37 </div>
38
39 <div class="row">
40 <div class="col-md-5">
41 <div class="panel panel-default">
42 <div class="panel-heading">Search Results</div>
43 <table id="results" class="table table-striped table-hover">
44 <thead>
45 <tr>
46 <th>Nid</th>
47 <th>Title</th>
48 <th>Year</th>
49 </tr>
50 </thead>
51 <tbody>
52 </tbody>
53 </table>
54 </div>
55 </div>
56 <div class="col-md-7">
57 <div class="panel panel-default">
58 <div class="panel-heading" id="title">Details</div>
59 <div class="row">
60 <div class="col-md-8 col-sm-8">
61 <!-- <h4>Name</h4>
62 <ul id="crew">
63 </ul>-->
64 <h4>Name</h4><div id="name">Name</div>
65 </div>
66 </div>
67 </div>
68 </div>
69 </div>
70 <div class="row" id="graph" style="height:500px; width:1000px">
71 </div>
72
73 <div style="visibility:hidden;" id="dataloaderContainerDiv" ></div>
74 <div id="plotContainerDiv"> </div>
75 <div id="tableContainerDiv" style="position:relative;"></div>
76 <div id="mapContainerDiv" style="position:relative;"></div>
77
78
79
80
81
82
83 <style type="text/css">
84 .node { stroke: #222; stroke-width: 1.5px; }
85 .node.actor { fill: #888; }
86 .node.movie { fill: #BBB; }
87 .link { stroke: #999; stroke-opacity: .6; stroke-width: 1px; }
88 </style>
89
90 <script type="text/javascript" src="//code.jquery.com/jquery-1.11.0.min.js"></script>
91 <script src="http://d3js.org/d3.v3.min.js" type="text/javascript"></script>
92 <script type="text/javascript">
93 $(function () {
94 function showMovie(title) {
95 $.get("/edition/" + encodeURIComponent(title),
96 function (data) {
97 if (!data) return;
98 $("#title").text(data.title);
99 $("#name").text(data.name);
100 // var $list = $("#crew").empty();
101 // data.cast.forEach(function (cast) {
102 // $list.append($("<li>" + cast.name + " " +cast.job + (cast.job == "acted"?" as " + cast.role : "") + "</li>"));
103 // });
104 }, "json");
105 return false;
106 }
107 function search() {
108 var query=$("#search").find("input[name=search]").val();
109 $.get("/search?q=" + encodeURIComponent(query),
110 function (data) {
111 var t = $("table#results tbody").empty();
112 if (!data || data.length == 0) return;
113 data.forEach(function (row) {
114 var movie = row.edition;
115 $("<tr><td class='movie'>" + movie.Nid + "</td><td>" + movie.name + "</td><td>" + movie["Year of Publication"] + "</td></tr>").appendTo(t)
116 .click(function() { showMovie($(this).find("td.movie").text());})
117 });
118 showMovie(data[0].edition.Nid);
119 }, "json");
120 return false;
121 }
122
123 $("#search").submit(search);
124 search();
125 })
126 </script>
127 <link href="platin/css/platin.css" rel="stylesheet" type="text/css">
128 <script src="platin/js/Util/Publisher.js"></script>
129 <script src="platin/js/Build/Loader/DynaJsLoader.js"></script>
130 <script src="platin/js/Build/Loader/Loader.js"></script>
131 <script>
132 Publisher.Subscribe( 'GeoTemCoReady', this, function(){
133 var datasets = [];
134 var timeDiv = document.getElementById("plotContainerDiv");
135 var time = new WidgetWrapper();
136 var timeWidget = new FuzzyTimelineWidget(time,timeDiv,{
137 timeTitle: "Publication Date"
138 });
139
140 var dataloaderDiv = document.getElementById("dataloaderContainerDiv");
141 var dataloader = new WidgetWrapper();
142 var dataloaderWidget = new DataloaderWidget(dataloader,dataloaderDiv);
143
144 var tableDiv = document.getElementById("tableContainerDiv");
145 var table = new WidgetWrapper();
146 var tableWidget = new TableWidget(table,tableDiv);
147
148 var mapDiv = document.getElementById("mapContainerDiv");
149 var map = new WidgetWrapper();
150 var mapWidget = new MapWidget(map,mapDiv,{
151 mapTitle: "Publication Place"
152 });
153 dataloaderWidget.loadFromURL();
154 //});
155 //
156 ///script>
157 //script type="text/javascript">
158 var width = 800, height = 800;
159
160 var force = d3.layout.force()
161 .charge(-200).linkDistance(30).size([width, height]);
162
163 var svg = d3.select("#graph").append("svg")
164 .attr("width", "100%").attr("height", "100%")
165 .attr("pointer-events", "all");
166
167 d3.json("/graph", function(error, graph) {
168 if (error) return;
169
170
171 //DW ADDITIONS for Platin
172
173 var convSet= []
174
175 var resultObjects = graph.nodes;
176 for (var i=0;i<resultObjects.length;i++){
177
178 obj = resultObjects[i];
179 var nob = {};
180 //nob["TimeSpan:end"]=2020 //default
181 for( var x in obj){
182
183
184
185
186 if (x=="TimeSpan_begin"){
187 nob["TimeSpan:begin"]=obj[x];
188
189 } else if (x=="TimeSpan_end"){
190 nob["TimeSpan:end"]=obj[x];
191 } else if (x=="name"){ //name auf name2 kopieren damit es in der tabelle angezeigt wird
192 nob["name2"]=obj[x];
193 nob["place"]=obj[x];
194 } else if (x=="time"){ //time auf time2 kopieren damie es in der tabelle angezeigt wird.
195 nob["time2"]=obj[x];
196
197 }
198 nob[x]= obj[x];
199 }
200
201
202
203 convSet.push(nob);
204
205 }
206
207 GeoTemConfig.removeAllDatasets();
208 var dataSet = new Dataset(GeoTemConfig.loadJson(convSet),"GRAPH");
209 GeoTemConfig.addDataset(dataSet);
210
211
212 //DW ADDITIONS END
213
214
215
216
217
218 var link = svg.selectAll(".link")
219 .data(graph.links).enter()
220 .append("line")
221 .attr("class", "link");
222
223 var linklabel = svg.selectAll(".linklabel")
224 .data(graph.links).enter()
225 .append("text")
226 .text("MYTEXT");
227 // .attr("dx", function(d) { return d.source.x; })
228 // .attr("dy", function(d) { return d.source.y; })
229 // .text("MYTEXT");
230
231 var gnodes = svg.selectAll('g.gnode')
232 .data(graph.nodes)
233 .enter()
234 .append('g')
235 .classed('gnode', true);
236
237 var node = gnodes.append("circle")
238 .attr("class", function (d) { return "node "+d.label })
239 .attr("r", 10)
240 .call(force.drag);
241
242 var label =gnodes.append("text")
243 .text(function(d) { return d.title; })
244
245 // html title attribute
246 node.append("title")
247 .text(function (d) { return d.title; });
248
249
250
251 // force feed algo ticks
252 force.on("tick", function() {
253 link.attr("x1", function(d) { return d.source.x; })
254 .attr("y1", function(d) { return d.source.y; })
255 .attr("x2", function(d) { return d.target.x; })
256 .attr("y2", function(d) { return d.target.y; });
257
258
259 linklabel.attr("x", function(d) { return d.source.x + (d.target.x - d.source.x)/2; })
260 .attr("y", function(d) { return d.source.y + (d.target.y - d.source.y)/2; })
261
262 //gnode.attr("cx", function(d) { return d.x; })
263 // .attr("cy", function(d) { return d.y; });
264
265 gnodes.attr("transform", function(d) {
266 return 'translate(' + [d.x, d.y] + ')';
267 });
268
269
270
271
272 });
273
274
275 ;
276
277 var linkText = svg.selectAll(".link")
278 .data(graph.links)
279 .append("text")
280 .attr("font-family", "Arial, Helvetica, sans-serif")
281 .attr("x",0)
282 .attr("y",0)
283 // .attr("x", function(d) {
284 // if (d.target.x > d.source.x) {
285 // return (d.source.x + (d.target.x - d.source.x)/2); }
286 // else {
287 // return (d.target.x + (d.source.x - d.target.x)/2); }
288 // })
289 // .attr("y", function(d) {
290 // if (d.target.y > d.source.y) {
291 // return (d.source.y + (d.target.y - d.source.y)/2); }
292 // else {
293 // return (d.target.y + (d.source.y - d.target.y)/2); }
294 // })
295 .attr("fill", "Black")
296 .style("font", "normal 12px Arial")
297 .attr("dy", ".035em")
298 .text(function(d) {
299 return "HUHU3"; });
300
301
302 force.nodes(graph.nodes).links(graph.links).start();
303
304
305 });
306 });
307 </script>
308
309
310
311
312 </body>
313 </html>