-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
197 lines (172 loc) · 7.61 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>visjs-extra-layout-group-sequence</title>
<meta name="author" content="Thiago Ferreira">
<meta name="description" content="COVID-19 Simulator">
<meta name="keywords" content="vis.js, vis-network, visjs-extra-layout-group-sequence">
<meta name="robots" content="index, follow">
<!-- CSS only -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<!-- Custom -->
<style type="text/css">
body{
margin-top: 70px;
}
#network {
background-clip: border-box;
border: 1px solid rgba(0,0,0,.125);
border-radius: .25rem;
}
#editor {
width: 100%;
height: 400px;
border: 1px solid rgba(0,0,0,.125);
border-radius: .25rem;
}
/*
* ==========================================
* Navbar
* ==========================================
*/
.navbar-custom {
background: #07508E;
background: -moz-linear-gradient(-45deg, #134099 0%, #207cca 66%, #378ed6 100%);
background: -webkit-linear-gradient(-45deg, #134099 0%,#207cca 66%,#378ed6 100%);
background: linear-gradient(135deg, #134099 0%,#207cca 66%,#378ed6 100%);
}
/* change the brand and text color */
.navbar-custom .navbar-brand, .navbar-custom .navbar-text {
color: white;
}
/* change the link color */
.navbar-custom .navbar-nav .nav-link {
color: #d5d7d8;
}
/* change the color of active or hovered links */
.navbar-custom .nav-item.active .nav-link, .navbar-custom .nav-item:hover .nav-link {
color: #ffffff;
}
.navbar-custom .navbar-toggler-icon {
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='30' height='30' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(255, 255, 255, 0.5)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}
</style>
</head>
<body>
<header>
<nav class="navbar navbar-expand-md fixed-top navbar-custom">
<a class="navbar-brand mt-0 pt-0 pb-0" href="#">
<img width="180px" src="https://user-images.githubusercontent.com/114015/82130874-41ee0900-979d-11ea-944e-e61cb88ccb82.png"/>
</a>
</nav>
</header>
<main>
<div class="container-fluid">
<div class="card mb-3 ">
<div class="card-body pt-1 pb-1 pl-1">
<a class="btn btn-outline-secondary btn-sm" id="btn-execute" href="#">Execute</span></a>
</div>
</div>
<div class="row">
<div class="col-6">
<div id="editor">
let options = {
useHead: true,
useGroups: true,
groupNodeBy: "group"
};
var nodes = [
{id: 1, label: 'Node 1', group: "group", shape: 'box'},
{id: 2, label: 'Node 2\nNode 1\nNode 1', group: "group"},
{id: 6, label: 'Node 6', group: 2},
{id: 7, label: 'Node 7', group: 3, shape: 'box'},
{id: 5, label: 'Node 5', group: 3, shape: 'box'},
{id: 4, label: 'Node 4', group: 1, shape: 'box'},
{id: 3, label: 'Node 3', group: 1, shape: 'box'},
{id: 8, label: 'Node 8', group: 3, shape: 'box'},
{id: 9, label: 'Node 9', group: 3, shape: 'box'},
{id: 10, label: 'Node 10', group: 3, shape: 'box'},
{id: 11, label: 'Node 1Node 1', group: 4, shape: 'box'},
{id: 12, label: 'Node 1Node 1Node 1', group: 5, shape: 'box'},
{id: 13, label: 'Node 1\nNode 1\nNode 1\nNode 1', group: 6, shape: 'box'},
{id: 14, label: 'Node 1', group: 7, shape: 'box'},
{id: 15, label: 'Node 22', group: 8, shape: 'box'},
];
var edges = [
{from: 1, to: 2, arrows: "from"},
{from: 2, to: 6},
{from: 2, to: 6},
{from: 2, to: 6},
{from: 1, to: 6},
{from: 8, to: 7},
{from: 3, to: 4, },
{from: 4, to: 3},
{from: 4, to: 3},
{from: 3, to: 4, arrows: "from"},
{from: 5, to: 8},
{from: 5, to: 9},
{from: 8, to: 5, arrows: "from"},
{from: 7, to: 10},
];
</div>
</div>
<div class="col-6">
<div id="network"></div>
</div>
</div>
</div>
</main>
<!-- JS, Popper.js, and jQuery -->
<script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script type="text/javascript" src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
<!-- <script type="text/javascript" src="https://unpkg.com/vis-network/standalone/umd/vis-network.min.js"></script> -->
<script type="text/javascript" src="https://pagecdn.io/lib/ace/1.4.11/ace.js"></script>
<script type="text/javascript" src="https://pagecdn.io/lib/ace/1.4.11/mode-javascript.min.js"></script>
<script type="text/javascript" src="src/vis-network.js"></script>
<script type="text/javascript" src="src/group-sequence.js"></script>
<!-- Custom -->
<script type="text/javascript">
let $window = $(window);
let $row = $(".row");
let $container = $('#network');
let $editor = $('#editor');
let $btnExecute = $("#btn-execute");
let editor = ace.edit($editor[0]);
editor.setShowPrintMargin(false);
editor.getSession().setMode("ace/mode/javascript");
$window.resize(() => {
$container.height($window.height() - $row.offset().top - 20);
$editor.height($window.height() - $row.offset().top - 20);
});
$window.trigger('resize');
$btnExecute.click((event) => {
let content = `
${editor.getValue()}
return {
nodes: nodes,
edges: edges,
options: options
};
`;
let graph = new Function (content)();
// provide the data in the vis format
var dataSet = {
nodes: new vis.DataSet(graph.nodes),
edges: new vis.DataSet(graph.edges)
};
var options = {
physics: false
};
var network = new vis.Network($container[0] , dataSet, options);
let layout = new GroupSequence(graph.options);
layout.arrange(network, dataSet);
});
$btnExecute.trigger('click');
</script>
<script>document.write('<script src="http://' + (location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1"></' + 'script>')</script>
</body>
</html>