-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
euler.html
86 lines (81 loc) · 2.12 KB
/
euler.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
<!doctype html>
<html>
<head>
<title>Sample</title>
<style>
#app {
position: absolute;
left: 0;
top: 0;
bottom: 0;
right: 0;
}
</style>
</head>
<body>
<div id="app"></div>
<script src="https://cdn.jsdelivr.net/npm/cytoscape"></script>
<script src="https://cdn.jsdelivr.net/npm/cytoscape-layers"></script>
<script src="https://cdn.jsdelivr.net/npm/cytoscape-euler"></script>
<script src="../build/index.umd.js"></script>
<script>
const cy = cytoscape({
container: document.getElementById('app'), // container to render in
layout: {
name: 'euler',
randomize: false,
animate: false,
// some more options here...
},
style: [
{
selector: 'node',
style: {
'background-color': '#126814',
},
},
{
selector: 'node[sbgnlabel]',
style: {
label: 'data(sbgnlabel)',
},
},
{
selector: 'edge',
style: {
'line-color': '#126814',
opacity: 0.5,
},
},
{
selector: ':selected',
style: {},
},
],
elements: fetch('https://cytoscape.org/cytoscape.js-euler/example-graphs/planar-chain.json').then((res) =>
res.json()
),
});
cy.ready(() => {
const bb = cy.bubbleSets();
const atp = cy.nodes().filter(`[sbgnlabel = 'ATP']`);
bb.addPath(atp, null, cy.nodes().diff(atp).left, {
virtualEdges: true,
style: {
fill: 'rgba(255, 0, 0, 0.2)',
stroke: 'red',
},
});
const edges = cy.$('node#glyph20').connectedEdges();
const nodes = edges.connectedNodes();
bb.addPath(nodes, edges, cy.nodes().diff(nodes).left, {
virtualEdges: true,
style: {
fill: 'rgba(70, 130, 180, 0.2)',
stroke: 'steelblue',
},
});
});
</script>
</body>
</html>