-
-
Notifications
You must be signed in to change notification settings - Fork 124
/
Copy pathusage-concentric-layout.py
71 lines (62 loc) · 1.59 KB
/
usage-concentric-layout.py
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
"""
Original Demo: http://js.cytoscape.org/demos/concentric-layout/
Note: This example is broken because layout takes a function as input, i.e.
```
layout: {
name: 'concentric',
concentric: function( node ){
return node.degree();
},
levelWidth: function( nodes ){
return 2;
}
},
```
"""
import json
import dash
from dash import html
import dash_cytoscape as cyto
app = dash.Dash(__name__)
server = app.server
# Load Data
with open("data/concentric-layout/data.json", "r", encoding="utf-8") as f:
elements = json.loads(f.read())
# App
app.layout = html.Div(
[
cyto.Cytoscape(
id="cytoscape",
elements=elements,
layout={
"name": "concentric",
},
stylesheet=[
{
"selector": "node",
"style": {"height": 20, "width": 20, "background-color": "#30c9bc"},
},
{
"selector": "edge",
"style": {
"curve-style": "haystack",
"haystack-radius": 0,
"width": 5,
"opacity": 0.5,
"line-color": "#a8eae5",
},
},
],
style={
"width": "100%",
"height": "100%",
"position": "absolute",
"left": 0,
"top": 0,
"z-index": 999,
},
)
]
)
if __name__ == "__main__":
app.run(debug=True)