forked from SamPom100/StockClustering
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
308 lines (282 loc) · 9.34 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
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
305
306
307
308
<html>
<head>
<meta property="og:image" content="https://user-images.githubusercontent.com/28206070/231950065-4bc0fefc-984f-4ede-a45a-308d2a557a7f.png"/>
<meta property="og:type" content="website" />
<meta property="og:url" content="https://sampom100.github.io/StockClustering/"/>
<meta property="og:title" content="SamPom100 StockClustering" />
<meta property="og:description" content="Network of Robinhood-based Similar Stocks"/>
<link rel="icon" href="https://sampomerantz.me/favicon.ico" />
<title>RobinClusters</title>
<meta charset="utf-8" />
<script src="lib/bindings/utils.js"></script>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Ubuntu:wght@700&display=swap" rel="stylesheet"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"/>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.13.0/css/all.css"/>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.13.0/css/v4-shims.css"/>
<link rel="stylesheet" href="https://unpkg.com/aos@next/dist/aos.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/vis-network/9.1.2/dist/dist/vis-network.min.css" integrity="sha512-WgxfT5LWjfszlPHXRmBWHkV2eceiWTOBvrKCNbdgDYTHrT2AeLCGbF4sZlZw3UMN3WtL0tGUoIAKsu8mllg/XA==" crossorigin="anonymous" referrerpolicy="no-referrer"/>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/vis-network/9.1.2/dist/vis-network.min.js"
integrity="sha512-LnvoEWDFrqGHlHmDD2101OrLcbsfkrzoSpvtSQtxK3RMnRV0eOkhhBN2dXHKRrUU8p2DGRTk35n4O8nWSVe1mQ=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
></script>
<link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6"
crossorigin="anonymous"
/>
<script
src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/js/bootstrap.bundle.min.js"
integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf"
crossorigin="anonymous"
></script>
<style type="text/css">
#mynetwork {
width: 100%;
height: 100%;
background-color: #222222;
border: 0px solid rgb(34, 34, 34);
position: relative;
float: left;
}
.note {
position: fixed;
z-index: 1;
background-color: white;
text-align: center;
border-radius: 10px;
top: 0%;
left: 0%;
}
.html {
font-family: "Ubuntu", sans-serif;
}
.note > h3 {
margin-bottom: 1px;
font-size: 40px;
margin-left: 5px;
font-weight: bold;
}
.fa,
.far,
.fab {
color: black;
}
.searchBox {
border: 2px solid #ebebeb;
font-family: inherit;
font-size: 20px;
padding: 0 1px;
border-radius: 1.25rem;
transition: all 0.375s;
margin-left: 5px;
margin-top: 15px;
text-align: center;
}
.searchButton {
display: inline-block;
width: 70px;
padding: 6px 0px;
border-radius: 15px;
background: var(black);
color: black;
font-weight: 500;
font-size: 17px;
border: none;
cursor: pointer;
transition: all .3s ease;
margin-right: 5px;
}
@media (pointer: none), (pointer: coarse) {
.note > h3 {
margin-bottom: 1px;
font-size: 80px;
margin-left: 5px;
font-weight: bold;
}
.note > h8 {
font-size: 50px;
}
.note > .fa,
.far,
.fab {
font-size: 50px;
letter-spacing: 10px;
color: black;
}
.searchBox {
border: 2px solid #ebebeb;
width: 70%;
font-family: inherit;
font-size: 2.3rem;
padding: 0 1px;
border-radius: 1.25rem;
transition: all 0.375s;
margin-left: 5px;
margin-top: 15px;
text-align: center;
}
.searchButton {
display: inline-block;
width: 8rem;
padding: 6px 0px;
border-radius: 15px;
background: var(black);
color: black;
font-weight: 400;
font-size: 2.3rem;
border: none;
cursor: pointer;
transition: all .3s ease;
margin-right: 5px;
}
}
</style>
</head>
<body style="background-color: rgb(34, 34, 34); font-size: 16px;">
<div>
<div class="note">
<h3>
RobinClusters<a href="https://github.com/SamPom100/StockClustering/"target="_blank"><i class="fa fa-github" style="margin-right: 8px; margin-left: 8px; margin-top: 15px;"></i></a>
</h3>
<h8>
Sam Pomerantz<a href="https://www.linkedin.com/in/pomerantzsam/" target="_blank"><i class="fab fa-linkedin" style="margin-right: 8px; margin-left: 8px"></i></a>
</h8>
<form onSubmit="return false;" style="margin-bottom: 8px;">
<input type="text" id="searchInput" class="searchBox" value=""></input>
<button onclick="focusOnNode()" value="submit" class="searchButton">Search</button>
</form>
</div>
<div id="mynetwork" class="card-body" style="padding: 0px;"></div>
</div>
<script type="text/javascript">
// initialize global variables.
var edges;
var nodes;
var allNodes;
var allEdges;
var nodeColors;
var originalNodes;
var network;
var container;
var options, data;
var filter = {
item: "",
property: "",
value: [],
};
function isMobile() {
const maxWidth = 767; // set the maximum width for mobile devices
return screen.width <= maxWidth;
}
function loadGraph() {
return new Promise(function (resolve, reject) {
var xhr = new XMLHttpRequest();
if (isMobile()) {
xhr.open("GET", "graph_mobile.json", true);
} else {
xhr.open("GET", "graph.json", true);
}
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
var graph = JSON.parse(xhr.responseText);
resolve(graph);
} else {
reject(xhr.status);
}
}
};
xhr.send();
});
}
function focusOnNode() {
const nodeName = document.getElementById("searchInput").value;
network.focus(nodeName.toUpperCase(), {
scale: 2,
animation: {
locked: true,
duration: 1000,
easingFunction: "easeInOutQuad"}
})
document.getElementById("searchInput").value = "";
}
// This method is responsible for drawing the graph, returns the drawn network
async function drawGraph() {
var container = document.getElementById("mynetwork");
try {
var graph = await loadGraph();
var nodeLoaded = graph.nodes;
var edgeLoaded = graph.edges;
} catch (error) {
console.log(error);
}
// parsing and collecting nodes and edges from the python
nodes = new vis.DataSet(nodeLoaded);
edges = new vis.DataSet(edgeLoaded);
nodeColors = {};
allNodes = nodes.get({ returnType: "Object" });
for (nodeId in allNodes) {
nodeColors[nodeId] = allNodes[nodeId].color;
}
allEdges = edges.get({ returnType: "Object" });
data = { nodes: nodes, edges: edges };
var options = {
configure: {
enabled: false,
},
edges: {
hidden: true,
color: {
inherit: true,
},
smooth: {
enabled: false,
type: "dynamic",
},
},
interaction: {
dragNodes: true,
hideEdgesOnDrag: true,
hideNodesOnDrag: false,
},
"physics": {
"enabled": true,
"forceAtlas2Based": {
"avoidOverlap": 0,
"centralGravity": 0.01,
"damping": 0.4,
"gravitationalConstant": -50,
"springConstant": 0.08,
"springLength": 100
},
"solver": "forceAtlas2Based",
"stabilization": {
"enabled": false,
"fit": true,
"iterations": 10,
"onlyDynamicEdges": false,
"updateInterval": 50
}
},
layout: { improvedLayout: false },
nodes: {
shapeProperties: {
interpolation: true, // 'true' for intensive zooming
},
},
};
network = new vis.Network(container, data, options);
return network;
}
drawGraph();
setTimeout(function () {
network.setOptions({edges: {hidden: false}})
}, 1500);
</script>
</body>
</html>