-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgraph2d_app.py
More file actions
78 lines (64 loc) · 1.94 KB
/
graph2d_app.py
File metadata and controls
78 lines (64 loc) · 1.94 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
from dash import Dash, html, dcc, Input, Output
from components.components_2d import tab_ui_2d, figure_2d
from cluster_sim.app import BrowserState
from cluster_sim.simulator import ClusterState
import dash_bootstrap_components as dbc
from dash_resizable_panels import PanelGroup, Panel, PanelResizeHandle
import logging
logging.basicConfig(level=logging.DEBUG)
app = Dash(external_stylesheets=[dbc.themes.BOOTSTRAP])
app.title = "Cluster Sim"
server = app.server # For deployment
app.layout = html.Div(
[
PanelGroup(
id="main_app",
children=[
Panel(
id="resize_figure",
children=[
figure_2d,
],
),
PanelResizeHandle(
html.Div(
style={
"backgroundColor": "grey",
"height": "100%",
"width": "5px",
}
)
),
Panel(
id="resize_info",
children=tab_ui_2d,
style={"overflowY": "scroll"},
),
],
direction="horizontal",
style={"height": "100vh"},
),
dcc.Store(id="browser-data"),
dcc.Store(id="graph-data"),
dcc.Store(id="draw-plot"), # This is a dummy variable
html.Div(
id="none",
children=[],
style={"display": "none"},
),
]
)
@app.callback(
Output("browser-data", "data"),
Output("graph-data", "data"),
Input("none", "children"),
)
def initial_call(dummy):
"""
Initialize the graph in the browser as a JSON object.
"""
browser_state = BrowserState()
G = ClusterState(5)
return browser_state.to_json(), G.to_json()
if __name__ == "__main__":
app.run(debug=True)