annotate ismi-python-neo4jrestclient/static/commentaries_authors3.html @ 20:d8bbf6d5920b

now with arrowheads.
author casties
date Fri, 09 Oct 2015 12:54:39 +0200
parents
children d964d9a23837
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
20
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
1 <html>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
2 <head>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
3 <meta name="viewport" content="width=device-width, initial-scale=1.0">
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
4 <link rel="stylesheet" href="static/main.css">
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
5 <title>ISMI commentary relations</title>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
6 </head>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
7
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
8 <body style="background:none;">
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
9 <div role="navigation" class="navbar navbar-default navbar-static-top">
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
10 <div class="container">
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
11 <div class="row">
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
12 <div class="col-sm-6 col-md-6">
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
13 <ul class="nav navbar-nav">
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
14 <li>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
15 <form role="search" class="navbar-form" id="search">
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
16 <div class="form-group">
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
17 <input type="text" value="7437" placeholder="Search for person-id" class="form-control" name="search">
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
18 </div>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
19 <button class="btn btn-default" type="submit">Search for author id</button>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
20 </form>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
21 </li>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
22 </ul>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
23 </div>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
24 <div class="navbar-header col-sm-6 col-md-6">
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
25 <div class="logo-well">
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
26 <a href="//neo4j.com/developer-resources">
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
27 <img src="//neo4j-contrib.github.io/developer-resources/language-guides/assets/img/logo-white.svg" alt="Neo4j World's Leading Graph Database" id="logo">
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
28 </a>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
29 </div>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
30 <div class="navbar-brand">
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
31 <div class="brand">ISMI Commentary relations between Texts</div>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
32 </div>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
33 </div>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
34 </div>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
35 </div>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
36 </div>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
37
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
38 <div class="row">
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
39 <div class="col-md-5">
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
40 <div class="panel panel-default">
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
41 <div class="panel-heading">
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
42 <span>Texts by this author</span>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
43 <span class="clickhide">(click to hide)</span>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
44 <span class="clickhide" style="display:none;">(click to show)</span>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
45 </div>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
46 <table id="results" class="table table-striped table-hover">
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
47 <thead>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
48 <tr>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
49 <th>Author (translit)</th>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
50 <th>Title (translit)</th>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
51 <th>Title (arabic)</th>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
52 <th>ismi_id</th>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
53 </tr>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
54 </thead>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
55 <tbody>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
56 </tbody>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
57 </table>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
58 </div>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
59 </div>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
60 <div class="col-md-7">
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
61 <div class="panel panel-default">
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
62 <div class="panel-heading">
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
63 <span id="title">Text details</span>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
64 <span class="clickhide">(click to hide)</span>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
65 <span class="clickhide" style="display:none;">(click to show)</span>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
66 </div>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
67 <div class="row">
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
68 <!-- <div class="col-sm-4 col-md-4">
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
69 <img src="" class="well" id="poster"/>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
70 </div> -->
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
71 <div class="col-md-8 col-sm-8">
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
72 <h4>Details</h4>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
73 <ul id="info">
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
74 </ul>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
75 <h4>Commenting on</h4>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
76 <ul id="commenting">
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
77 </ul>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
78 <h4>Commentaries</h4>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
79 <ul id="commentaries">
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
80 </ul>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
81 </div>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
82 </div>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
83 </div>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
84 </div>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
85 </div>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
86 <div class="col-lg-12">
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
87 <div class="panel panel-default">
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
88 <div class="panel-heading">
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
89 <span>Graph of commentaries</span>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
90 <span class="clickhide">(click to hide)</span>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
91 <span class="clickhide" style="display:none;">(click to show)</span>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
92 </div>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
93 <div id="graph">
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
94 </div>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
95 </div>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
96 </div>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
97
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
98 <style type="text/css">
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
99 .node { stroke: #222; stroke-width: 1.5px; }
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
100 .node.TEXT { fill: #888; }
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
101 .node.TEXT.marked { stroke: red; }
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
102 .node.TEXT.selected { fill: red; }
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
103 .link { stroke: #999; stroke-opacity: .6; stroke-width: 2px; }
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
104 .arrowHead { fill: #999 }
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
105 tr.marked {border: 2px solid red;}
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
106 </style>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
107
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
108 <script type="text/javascript" src="//code.jquery.com/jquery-1.11.0.min.js"></script>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
109 <!-- <script src="https://d3js.org/d3.v3.min.js" type="text/javascript"></script> -->
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
110 <script src="//cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js" type="text/javascript"></script>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
111 <script type="text/javascript">
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
112 // make panels roll-up
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
113 $(".panel-heading").on("click", function() {
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
114 $(this).find(".clickhide").toggle();
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
115 $(this).next().slideToggle();
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
116 });
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
117 // provide search and graph
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
118 backendApiPrefix = "";
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
119 searchApi = {};
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
120 $(function () {
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
121 function showText(text_id) {
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
122 $.get(backendApiPrefix+"/textandcommentaries/" + encodeURIComponent(text_id),
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
123 function (data) {
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
124 if (!data) return;
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
125 $("#title").text("Title: "+data.title);
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
126 var $list = $("#info").empty();
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
127 $list.append($("<li> author: " + data.author + "</li>"));
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
128 for (var key in data.attrs) {
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
129 var val = data.attrs[key];
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
130 if (key === "link") {
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
131 val = "<a href=\"" + val + "\" target=\"_blank\">" + val + "</a>";
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
132 }
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
133 $list.append($("<li>" + key + ": " + val + "</li>"));
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
134 };
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
135 // re-set selected
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
136 $("#graph .selected").each(function(){this.classList.remove("selected")});
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
137 $("#graph .ismi-"+data.attrs.ismi_id).each(function(){this.classList.add("selected")});
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
138 var $commentaries = $("#commentaries").empty();
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
139 for (var key in data.commentaries) {
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
140 var val = data.commentaries[key];
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
141 $commentaries.append($("<li>" + val.title + " [<span class=\"text_id\">" + key + "</span>] by " + val.author + "</li>")
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
142 .click(function() { showText($(this).find("span.text_id").text());}));
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
143 }
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
144 var $commenting = $("#commenting").empty();
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
145 for (var key in data.commenting) {
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
146 var val = data.commenting[key];
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
147 $commenting.append($("<li>" + val.title + " [<span class=\"text_id\">" + key + "</span>] by " + val.author + "</li>")
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
148 .click(function() { showText($(this).find("span.text_id").text());}));
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
149 }
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
150 }, "json");
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
151 return false;
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
152 }
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
153 function search() {
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
154 var query=$("#search").find("input[name=search]").val();
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
155 $.get(backendApiPrefix+"/search?q=" + encodeURIComponent(query),
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
156 function (data) {
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
157 var t = $("table#results tbody").empty();
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
158 if (!data || data.length == 0) return;
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
159 // clear all marks
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
160 $("#graph .marked").each(function(){this.classList.remove("marked")});
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
161 data.forEach(function (row) {
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
162 var text = row.text;
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
163 var author = row.author;
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
164 var comm = row.is_commentary || row.has_commentaries;
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
165 var $row = $("<tr><td>" + author.label + "</td><td>" + text.label + "</td><td>" + text.full_title + "</td><td class='text_id'>" + text.ismi_id + "</td></tr>").appendTo(t)
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
166 .click(function() { showText($(this).find("td.text_id").text());});
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
167 if (comm) {
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
168 $row.addClass("marked");
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
169 }
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
170 // set mark
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
171 $("#graph .ismi-"+text.ismi_id).each(function(){this.classList.add("marked")});
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
172 });
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
173 showText(data[0].text.ismi_id);
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
174 }, "json");
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
175 return false;
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
176 }
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
177 // export API
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
178 searchApi.showText = showText;
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
179 searchApi.search = search;
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
180 // start search
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
181 $("#search").submit(search);
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
182 search();
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
183 });
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
184 </script>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
185
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
186 <script type="text/javascript">
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
187 var width = 1400, height = 1400;
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
188
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
189 var force = d3.layout.force()
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
190 .charge(-100) // -200
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
191 .linkDistance(30) // 30
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
192 .size([width, height]);
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
193
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
194 var svg = d3.select("#graph").append("svg")
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
195 .attr("width", "1400px").attr("height", "1400px")
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
196 .attr("pointer-events", "all");
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
197
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
198 // arrow head marker
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
199 var defs = svg.append("defs").append("marker")
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
200 .attr({
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
201 "id":"arrow",
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
202 "markerUnits": "strokeWidth",
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
203 "viewBox":"0 -5 10 10",
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
204 "refX": 20, // 5
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
205 "refY":0,
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
206 "markerWidth":4,
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
207 "markerHeight":4,
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
208 "orient":"auto"
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
209 })
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
210 .append("path")
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
211 .attr("d", "M0,-5 L10,0 L0,5")
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
212 .attr("class","arrowHead");
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
213
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
214 // load graph
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
215 d3.json(backendApiPrefix+"/graph?limit=1000", function(error, graph) {
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
216 if (error) return;
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
217
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
218 force.nodes(graph.nodes).links(graph.links).start();
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
219
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
220 var link = svg.selectAll(".link")
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
221 .data(graph.links).enter()
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
222 .append("line").attr({
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
223 "class": "link",
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
224 "marker-end": "url(#arrow)"
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
225 });
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
226
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
227 var node = svg.selectAll(".node")
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
228 .data(graph.nodes).enter()
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
229 .append("circle")
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
230 .attr("class", function (d) { return "node "+d.label+" ismi-"+d.ismi_id})
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
231 .attr("r", 8) // 10
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
232 .attr("data-ismi_id", function(d) {return d.ismi_id})
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
233 .on("click", function() {
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
234 console.log("click on ", this);
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
235 var id = this.getAttribute("data-ismi_id");
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
236 searchApi.showText(id);
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
237 })
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
238 .call(force.drag);
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
239
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
240 console.log("searchApi:", searchApi);
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
241 // html title attribute
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
242 node.append("title")
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
243 .text(function (d) { return d.title; })
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
244
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
245 // force feed algo ticks
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
246 force.on("tick", function() {
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
247 link.attr("x1", function(d) { return d.source.x; })
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
248 .attr("y1", function(d) { return d.source.y; })
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
249 .attr("x2", function(d) { return d.target.x; })
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
250 .attr("y2", function(d) { return d.target.y; });
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
251
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
252 node.attr("cx", function(d) { return d.x; })
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
253 .attr("cy", function(d) { return d.y; });
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
254 });
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
255 });
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
256
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
257 </script>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
258 </body>
d8bbf6d5920b now with arrowheads.
casties
parents:
diff changeset
259 </html>