forked from bricaud/graphexp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
graphexp.html
304 lines (260 loc) · 9.82 KB
/
graphexp.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Graphexp, graph explorer</title>
<head>
<link rel="stylesheet" href="css/graphStyle.css">
<link rel="stylesheet" href="css/styles.css">
<!--<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<link rel="stylesheet" href="font-awesome-4.7.0/css/font-awesome.min.css">-->
<script src="http://code.jquery.com/jquery-3.2.1.min.js"></script>
<!--<script src="jquery-3.2.1.min.js"></script>-->
<script src="http://d3js.org/d3.v4.min.js"></script>
<!--<script src="d3/d3.min.js"></script>-->
<script src="scripts/graphConf.js"></script>
<script src="scripts/graphShapes.js"></script>
<script src="scripts/infobox.js"></script>
<script src="scripts/graph_viz.js"></script>
<script src="scripts/graphioGremlin.js"></script>
<script type="text/javascript">
///////////////////////////////////////////////
function search_query(){
//if (typeof graph_viz.simulation!=='undefined') {graph_viz.simulation.stop(); console.log('Simulation stopped!');}
graphioGremlin.search_query();
}
function get_graph_info(){
graphioGremlin.get_graph_info();
infobox.show_element("#graphInfo");
document.getElementById ("showgraphinfo").checked = true;
}
</script>
<!-- ------------------------------------------------- -->
</head>
<body>
<!--
<div class="header">
<div class="container">
<h1 class="header-heading">Graph Explorer v 0.6</h1>
</div>
</div>
-->
<div class="nav-bar">
<div class="nav container" id="nav_bar">
<div class="nav inputs_container">
<div class="nav input_unit_container">
<label for="search_field">Enter a field: </label>
<input name="search_field" id="search_field" value="" />
</div>
<div class="nav input_unit_container">
<label class="nav input_label" for="search_value">Enter a Keyword/value: </label>
<input name="search_value" id="search_value" value="" />
</div>
<div class="nav input_unit_container">
<label class="nav input_label" for="edge_filter">Traverse by edge: </label>
<input name="edge_filter" id="edge_filter" value="" />
</div>
<div class="nav input_unit_container">
<label class="nav input_label" for="nbLayers">Nb of layers </label>
<input type="number" id="nbLayers" min="1" max="128" onclick="set_nb_layers()">
</div>
<div class="nav input_unit_container">
<input type="checkbox" name="Freeze" id="freeze-in" />
<label class="nav input_label" for="freeze-in">Freeze exploration</label>
</div>
<div class="nav input_unit_container">
<input type="checkbox" name="showName_box" id="showName" onclick="graphShapes.show_names()"/>
<label class="nav input_label" for="showName">Show labels</label>
</div>
</div>
<div class="nav controls">
<button name="search query" onclick="search_query();">Search</button>
<button name="clear" onclick="graph_viz.clear();">Clear</button>
</div>
</div>
</div>
<div class="content">
<div class="main" id="main">
<svg></svg>
</div>
<div class="aside left_bar" style="background-color:transparent;pointer-events:auto;">
<div id="graphInfoBar" style="background-color:transparent;pointer-events:auto;">
<button name="graphInfo" onclick="get_graph_info();">Get graph info</button>
<input type="checkbox" name="showgraphinfo" id="showgraphinfo" onchange="show_hide_element('#graphInfo')"/>Show/hide graph info
</div>
<div id="graphInfo" style="background-color:transparent;pointer-events:none;">
</div>
</div>
<div class="aside right_bar" id="details" style="background-color:transparent;pointer-events:auto;">
<div id="messageArea"></div><div id="outputArea"></div>
<div id="nodeInfo" style="background-color:transparent;pointer-events:none;">
</div>
</div>
<!--
<div class="aside" id="ImageInfo" style="background-color:transparent;">
<center><svg width="100" height="100"></svg></center>
</div>
-->
</div>
<div class="footer">
<div class="container">
<a href="http://www.github.com/bricaud/graphexp">Graph Explorer V 0.7</a>
</div>
</div>
<!-- INITIALIZATION -->
<script type="text/javascript">
init_property_bar();
// Create the graph canvas in the chosen div element
graph_viz.init("#main");
// Add the zoom layer to the graph
//var svg_graph =
graph_viz.addzoom();
//graph_viz.layers.set_nb_layers(4);
// Create the info box for node details
infobox.create("#graphInfo","#nodeInfo"); // from module in infobox.js
//console.log(graph_viz.graph_events.ev);
//graph_viz.graph_events.test();
function init_property_bar(){
document.getElementById('nbLayers').value = default_nb_of_layers;
}
function change_nav_bar(node_data,edge_data){
var nav_bar = d3.select("#prop_choice");
nav_bar.select("input").remove();
nav_bar.select("select").remove();
//nav_choices = nav_bar.append("ul");
//nav_choices.append("li").append("button").attr("onclick",search_query).text("Search")
var select = d3.select('#prop_choice')
.append('select').attr('class','select').attr('id','search_field')
var select_node = select.append('optgroup').attr('label','Nodes')
//.on('change',onchange)
var select_edge = select.append('optgroup').attr('label','Edges')
var node_options = select_node
.selectAll('option')
.data(node_data).enter()
.append('option')
.text(function (d) { return d; });
var edge_options = select_edge
.selectAll('option')
.data(edge_data).enter()
.append('option')
.text(function (d) { return d; });
}
function display_properties_bar(prop_list,item,text){
var nav_bar = d3.select("#graphInfoBar");
nav_bar.select("#property_bar_"+item).remove();
var property_bar = nav_bar.append("div").attr("id","property_bar_"+item);
property_bar.append('text').text(text).style("font-weight","bold");
//d3.select('#property_bar').append('text').text('hello')
var property_label = property_bar.selectAll('input').append("ul")
.data(prop_list).enter().append("li");
//.append('label');
property_label.append('input').attr('type','checkbox').attr('id',function (d) { return item+"_"+d; })
.attr('id_nb',function (d) { return prop_list.indexOf(d); })
//.attr('onchange',function(d){display_prop(d);});
.attr('onchange','display_prop(this)');
property_label.append('label').text(function (d) { return d; });
}
function display_color_choice(prop_list,item,text){
prop_list = ['none','label'].concat(prop_list);
var nav_bar = d3.select("#graphInfoBar");
nav_bar.select("#color_choice_"+item).remove();
var color_bar = nav_bar.append("div").attr("id","color_choice_"+item);
color_bar.append("div").append("text").text(text).style("font-weight","bold");
color_bar.append("div").append("select").attr("class","select").attr("id","color_select_"+item)
.attr("onchange","colorize(this)")
.selectAll("option")
.data(prop_list).enter()
.append("option")
.text(function (d) { return d; });
}
function colorize(selection){
var value = selection.value;
console.log(value);
graphShapes.colorize(value);
}
function display_prop(prop){
var prop_id = prop.id;
var prop_id_nb = prop.getAttribute('id_nb');
var text_base_offset = 10;
var text_offset = 10;
var prop_name = prop_id.slice(prop_id.indexOf("_")+1);
var item = prop_id.slice(0,prop_id.indexOf("_"));
console.log(prop_id,item)
if(d3.select("#"+prop_id).property("checked")){
if (item=='nodes'){
var elements_text = d3.selectAll('.node');
} else if (item=='edges'){
var elements_text = d3.selectAll('.edgelabel');
}
attach_property(elements_text,prop_name,prop_id_nb,item)
}
else{
if (item=='nodes'){
d3.selectAll('.node').select('.'+prop_id).remove();
}
else if (item=='edges'){
d3.selectAll('.edgelabel').select('.'+prop_id).remove();
}
}
}
function attach_property(graph_objects,prop_name,prop_id_nb,item){
var text_base_offset = 10;
var text_offset = 10;
var prop_id = item+"_"+prop_name;
if (item=='nodes'){
elements_text = graph_objects.append("text").style("pointer-events", "none");
}
else if (item=='edges'){
var elements_text = graph_objects.append("textPath")
.attr('class','edge_text')
.attr('href', function (d, i) {return '#edgepath' + d.id})
.style("text-anchor", "middle")
.style("pointer-events", "none")
.attr("startOffset", "70%");
//.text(function (d) {return d.label});
prop_id_nb = prop_id_nb + 1;
}
else {
console.log('Bad item name.'); return 1;
}
elements_text.classed("prop_details",true).classed(prop_id,true)
//.attr("x", 12)
.attr("dy",function(d){return graphShapes.node_size(d)+text_base_offset+text_offset*parseInt(prop_id_nb);})
//.attr("y", ".31em")
.text(function(d){return get_prop_value(d,prop_name,item);});
}
function get_prop_value(d,prop_name,item){
if (prop_name in d.properties){
if (item=='nodes'){
if (COMMUNICATION_METHOD == 'GraphSON3') {
return d.properties[prop_name]['summary'];
} else if (COMMUNICATION_METHOD == 'GraphSON1') {
return d.properties[prop_name][0].value;
}
}
else if (item=='edges'){
console.log(d.properties[prop_name])
return d.properties[prop_name];
}
}
else {
return "";
}
}
function set_nb_layers(){
var nb_layers = parseInt(document.getElementById('nbLayers').value);
//var nb_layers = parseInt(layer_input.getAttribute("value"));
console.log(nb_layers)
graph_viz.layers.set_nb_layers(nb_layers);
}
function show_hide_element(element_label){
element = d3.select(element_label);
var input = document.getElementById ("showgraphinfo");
var isChecked = input.checked;
if (isChecked) element.style("display", "inline");
else {element.style("display", "none");}
}
</script>
</body>
</html>