-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
61 lines (61 loc) · 2.25 KB
/
index.html
File metadata and controls
61 lines (61 loc) · 2.25 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Cytoscape.js Graph Visualization</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/cytoscape/3.20.0/cytoscape.min.js"></script>
<style>
#cy {
width: 100%;
height: 600px;
display: block;
}
</style>
</head>
<body>
<h1>Graph Visualization</h1>
<div id="cy"></div>
<script>
// Load the JSON data
fetch('cytoscape_graph.json')
.then(response => response.json())
.then(data => {
// Initialize Cytoscape
var cy = cytoscape({
container: document.getElementById('cy'),
elements: data.elements,
style: [
{
selector: 'node',
style: {
'label': 'data(label)',
'background-color': '#666',
'text-valign': 'center',
'text-halign': 'center',
'color': '#fff',
'width': '30px', // Set node diameter
'height': '30px' // Set node diameter
}
},
{
selector: 'edge',
style: {
'width': '1px', // Set edge width
'line-color': '#ccc',
'target-arrow-color': '#ccc',
'target-arrow-shape': 'triangle'
}
}
],
layout: {
name: 'circle', // Change this to try different layouts
fit: true, // Whether to fit the viewport to the graph
padding: 30, // Padding on fit
randomize: true // Whether to randomize node positions on layout start
}
});
})
.catch(error => console.error('Error loading data:', error));
</script>
</body>
</html>