-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
74 lines (62 loc) · 1.68 KB
/
app.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
72
73
74
import dash
from dash import dcc, html, Input, Output, callback
import dash_bootstrap_components as dbc
import blocks
external_stylesheets = [
dbc.themes.SLATE,
]
# initiate app
app = dash.Dash(
__name__,
use_pages=True,
suppress_callback_exceptions=True,
external_stylesheets=external_stylesheets,
)
# create a simple navbar containing dbc.Buttons() for navigation
navbar = dbc.Navbar(
id='navbar',
children=[
dbc.Button(
children=page['name'],
href=page['path']
)
for page in dash.page_registry.values()
if page['name'] != 'Not found 404'
],
color='primary',
className='mb-1',
style={'height': '50px'}
)
app.layout = dbc.Container(
[
navbar,
blocks.static_options,
blocks.sidebar,
dash.page_container,
dcc.Store(id={'type': 'central_store', 'index': 0}),
# ^^ selected dataset
dcc.Store(id={'type': 'central_store', 'index': 1}),
# ^^ column names of selected dataframe
dcc.Store(id={'type': 'central_store', 'index': 2}),
# ^^ trace of clicked data
],
)
# write selected data into central store
@callback(
Output({'type': 'central_store', 'index': 0}, 'data'),
Input('data_drop', 'value'),
prevent_initial_call=True
)
def select_options(value):
return value
# write columns of selected data into central store
@callback(
Output({'type': 'central_store', 'index': 1}, 'data'),
Input('data_drop', 'value'),
prevent_initial_call=True
)
def select_options(dataset):
df = blocks.create_data(dataset)
return df.columns
if __name__ == "__main__":
app.run(debug=True, port=8055)