Skip to content

Commit 2a9725f

Browse files
committed
Extended example page.
1 parent 6479ec8 commit 2a9725f

File tree

1 file changed

+55
-5
lines changed

1 file changed

+55
-5
lines changed

index_example.html

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,31 @@
1111
<script type="text/javascript" src="layouts/force-directed-layout.js"></script>
1212
<script type="text/javascript" src="drawings/simple_graph.js"></script>
1313
<script type="text/javascript" src="drawings/sphere_graph.js"></script>
14-
14+
15+
<script type="text/javascript">
16+
var drawing;
17+
function createDrawing() {
18+
var index = parseInt(location.search.split("?")[1]);
19+
if(isNaN(index)) {
20+
index = 1;
21+
}
22+
switch(index) {
23+
case 0:
24+
drawing = new Drawing.SimpleGraph({layout: '2d', selection: true, numNodes: 50, showStats: true, showInfo: true});
25+
break;
26+
case 1:
27+
drawing = new Drawing.SimpleGraph({layout: '3d', selection: true, numNodes: 50, showStats: true, showInfo: true});
28+
break;
29+
case 2:
30+
drawing = new Drawing.SphereGraph({numNodes: 50, showStats: true, showInfo: true});
31+
break;
32+
default:
33+
drawing = new Drawing.SimpleGraph({layout: '3d', selection: true, numNodes: 50, showStats: true, showInfo: true});
34+
}
35+
document.getElementById("drawing_select").selectedIndex = index;
36+
}
37+
</script>
38+
1539
<style type="text/css">
1640
body {
1741
margin: 0;
@@ -29,13 +53,39 @@
2953
color: #333;
3054
padding: 5px 10px;
3155
}
56+
#options {
57+
position: absolute;
58+
top: 0;
59+
right: 0;
60+
z-index: 10;
61+
}
3262
</style>
3363
</head>
34-
<body onload="new Drawing.SimpleGraph({layout: '3d', selection: true, numNodes: 50, showStats: true, showInfo: true})">
64+
<body onload="createDrawing()">
65+
<div id="options">
66+
<form>
67+
<p>
68+
<label>Drawing</label><br>
69+
<select id="drawing_select" onchange="window.location.href = 'http://localhost/master/graph-visualization/index_example.html?' + this.selectedIndex;">
70+
<option>2D-Force-Directed</option>
71+
<option selected="selected">3D-Force-Directed</option>
72+
<option>Sphere Graph</option>
73+
</select>
74+
</p>
75+
<p>
76+
<input type="checkbox" id="show_labels">
77+
<label for="show_labels">Show labels</label>
78+
</p>
79+
<p>
80+
<input type="button" value="Stop layout" onclick="drawing.stop_calculating();">
81+
</p>
82+
</form>
83+
</div>
84+
3585
<div style="position: absolute; bottom: 0;">
3686
Rotate: Left Mouse Button and Move<br />
37-
Zoom: Left Mouse Button + Key S and Move<br />
38-
Drag: Left Mouse Button + Key D and Move
39-
</div>
87+
Zoom: Press Key S + Left Mouse Button and Move<br />
88+
Drag: Press Key D + Left Mouse Button and Move
89+
</div>
4090
</body>
4191
</html>

0 commit comments

Comments
 (0)