-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathindex.html
More file actions
204 lines (178 loc) · 7.75 KB
/
index.html
File metadata and controls
204 lines (178 loc) · 7.75 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link rel="shortcut icon" href="assets/ico/favicon.png">
<title>Networkmap.js</title>
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.css" rel="stylesheet">
<link href="dist/networkmap.css" rel="stylesheet">
<script src="lib/mootools-core.js"></script>
<script src="lib/mootools-more.js"></script>
<script src="lib/svg.js"></script>
<script src="lib/svg.draggable.js"></script>
<script src="lib/svg.math.js"></script>
<script src="lib/svg.path.js"></script>
<script src="dist/networkmap.js"></script>
<style type="text/css">
.nm-icon-menu {
background-image: url(resources/img/settings.png) !important;
}
#example1 {
height: 500px;
}
#example2 {
height: 400px;
}
#example3 {
height: 500px;
}
</style>
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="/assets/js/html5shiv.js"></script>
<script src="/assets/js/respond.min.js"></script>
<![endif]-->
</head>
<body>
<a href="https://github.com/otm/networkmap.js"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a>
<div class="container">
<!-- Main component for a primary marketing message or call to action -->
<div class="jumbotron">
<h1>networkmap.js</h1>
<p>A library for visualizing flows in networks. The most common use case would be network weathermaps. Networkmap.js is completely running on the clientside, configuration can either be done by loading a JSON file or building the weathermap directly in the browser with the API.</p>
</div>
<div class="panel panel-primary">
<div class="panel-heading">
<h4 class="panel-titel">Simple Example</h4>
</div>
<div class="panel-body">
Initialize a networkmap and load a configuration file from the server. Here is the <a href="assets/weathermap/example1.json">JSON file</a> used in the example.
<br><br>
<pre>
var map;
window.addEvent('load', function(){
map = new networkMap.Graph('example1').load('assets/weathermap/example1.json');
});
</pre>
</div>
<div class="panel-footer">
<script>
var map;
window.addEvent('load', function(){
map = new networkMap.Graph('example1').load('assets/weathermap/example1.json');
});
</script>
<div id="example1"></div>
</div>
</div> <!-- panel -->
<div class="panel panel-primary">
<div class="panel-heading">
<h4 class="panel-titel">Register a Datasource</h4>
</div>
<div class="panel-body">
By regitering a new datasource it is possible to load custom data into the graph. The datasource is a function that takes two parameters <code>url</code> and <code>requests</code>. <code>requests</code> is an array of request object. Each of the request objects has two properties <code>link</code> and <code>callback</code>.
<code>request.link</code> is a instance of <code>networkMap.LinkPath</code>, and <code>request.callback</code> should be called to update the LinkPath.<br><br>
<pre>
networkMap.registerDatasource('example', function(url, requests){
requests.each(function(request){
// Example on how to get the node to get node specific data
//request.link.getNode().options.id;
new Request.JSON({
url: 'assets/request/' + request.link.getNode().options.id + '/' + request.link.options.name,
onSuccess: function(response){
request.callback({
url: url,
request: request.link,
value: response.value,
realValue: response.realValue
});
}
}).get();
});
});
var map;
window.addEvent('load', function(){
map = new networkMap.Graph('example2', {datasource: 'example'}).load('assets/weathermap/example2.json');
});
</pre>
</div>
<div class="panel-footer">
<script>
networkMap.registerDatasource('example', function(url, requests){
requests.each(function(request){
// Example on how to get the node to get node specific data
//request.link.getNode().options.id;
new Request.JSON({
url: 'assets/request/' + request.link.getNode().options.id + '/' + request.link.options.name,
onSuccess: function(response){
request.callback({
url: url,
request: request.link,
value: response.value,
realValue: response.realValue
});
}
}).get();
});
});
var map2;
window.addEvent('load', function(){
map2 = new networkMap.Graph('example2', {datasource: 'example'}).load('assets/weathermap/example2.json');
});
</script>
<div id="example2"></div>
</div>
</div> <!-- panel -->
<div class="panel panel-primary">
<div class="panel-heading">
<h4 class="panel-titel">Adding Custom Event Handlers</h4>
</div>
<div class="panel-body">
In this example the normal click event and hover event is replaced.
<br>
The <code>click</code> function takes two arguments, <code>e</code> and <code>link</code>. <code>e</code> is an event, and <code>link</code> is an instance of <code>networkMap.LinkPath</code> from which it is posssible to access link and node information.
<br>
The <code>hover</code> function takes three arguments. <code>e</code> and <code>link</code> which is the same as above, and <code>el</code> which is a DOM element where it is possible to inject your own HTML.
<br><br>
<pre>
networkMap.registerEvent('click', function(e, link){
window.location.href = 'http://example.com/fqdn/' + link.getNode().options.id + '/if/' + link.options.name;
});
networkMap.registerEvent('hover', function(e, link, el){
// remove the original click event
el.removeEvents('click');
// set custom html in the hover popup
el.set('html', '<a href="http://example.com/fqdn/' + link.getNode().options.id + '/if/' + link.options.name + '">' + link.options.name + '</a>');
});
var map;
window.addEvent('load', function(){
map = new networkMap.Graph('example3').load('assets/weathermap/example1.json');
});
</pre>
</div>
<div class="panel-footer">
<script>
networkMap.registerEvent('click', function(e, link){
window.location.href = 'http://example.com/fqdn/' + link.getNode().options.id + '/if/' + link.options.name;
});
networkMap.registerEvent('hover', function(e, link, el){
// remove the original click event
el.removeEvents('click');
// set custom html in the hover popup
el.set('html', '<a href="http://example.com/fqdn/' + link.getNode().options.id + '/if/' + link.options.name + '">' + link.options.name + '</a>');
});
var map;
window.addEvent('load', function(){
map = new networkMap.Graph('example3').load('assets/weathermap/example1.json');
});
</script>
<div id="example3"></div>
</div>
</div> <!-- panel -->
</div> <!-- /container -->
</body>
</html>