NetAnalyzer 0.1.5 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,65 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <%
6
+ js_file = File.open(File.join(TEMPLATES, 'cytoscape.min.js')).read
7
+ js_base64 = Base64.encode64(js_file)
8
+ %>
9
+ <script src="data:application/javascript;base64,<%= js_base64 %>" type="application/javascript"></script>
10
+ <%
11
+ js_file = File.open(File.join(TEMPLATES, 'pako.min.js')).read
12
+ js_base64 = Base64.encode64(js_file)
13
+ %>
14
+ <script src="data:application/javascript;base64,<%= js_base64 %>" type="application/javascript"></script>
15
+
16
+ <style type="text/css">
17
+ #container {
18
+ margin: 10px;
19
+ width: 1100px;
20
+ height: 1000px;
21
+ border: 2px solid black;
22
+ }
23
+ </style>
24
+ </head>
25
+ <body>
26
+ <div id="container"/>
27
+ </div>
28
+ <%
29
+ model = {nodes: [], edges: []}
30
+ @nodes.each do |id, node|
31
+ model[:nodes] << {data: {id: id}}
32
+ end
33
+ @edges.each do |source, targets|
34
+ targets.each do |target|
35
+ model[:edges] << {data: {source: source, target: target}}
36
+ end
37
+ end
38
+ network = Base64.strict_encode64(Zlib::Deflate.deflate(model.to_json))
39
+ %>
40
+
41
+ <script>
42
+ let model = JSON.parse(pako.inflate(atob("<%= network %>"), { to: 'string' }));
43
+ cytoscape({
44
+ container: document.getElementById('container'),
45
+ elements: model,
46
+ layout: {
47
+ name: 'cose',
48
+ animate: false,
49
+ },
50
+
51
+ // so we can see the ids
52
+ style: [
53
+ {
54
+ selector: 'node',
55
+ style: {
56
+ 'label': 'data(id)',
57
+ 'background-color': '#666'
58
+ }
59
+ }
60
+ ]
61
+ });
62
+
63
+ </script>
64
+ </body>
65
+ </html>