-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblocks.py
150 lines (136 loc) · 4.05 KB
/
blocks.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
import dash_bootstrap_components as dbc
from dash import dcc, html
import pandas as pd
import numpy as np
import plotly.graph_objects as go
sidebar = dbc.Offcanvas(
id="sidebar_left",
title="Copy trace",
backdrop=False,
is_open=False,
class_name="border border-2",
style={'width': 300},
# content of the sidebar
children=dbc.Stack(
[
dcc.Dropdown(
id='tab_selector',
options=[],
style={'min-height': '50px'},
className='pt-1 pb-1',
placeholder='Select tab...'
),
dbc.Button(
id='send_trace',
children='Send to tab'
)
],
direction='vertical'
)
)
def create_data(seed: int) -> pd.DataFrame:
"""
function creates a dummy DataFrame
"""
# make the DataFrame reproducible
np.random.seed(seed)
cols = {
24: list('ABCD'),
42: list('EFGH')
}[seed]
return pd.DataFrame(
np.random.randint(0, 20, size=(9, 4)),
columns=cols
)
# static layout for all pages
static_options = dbc.Container(
[
dbc.Stack(
[
html.Div(
dcc.Dropdown(
id='data_drop',
options=[
{'label': 'A', 'value': 24},
{'label': 'B', 'value': 42},
],
placeholder='Select data...',
style={'width': '100%', 'min-height': '50px'}
),
style={'width': '300px'},
className='me-1'
),
dbc.Button(
id='copy_tab_btn',
children='copy main tab',
className='ms-1'
),
],
direction='horizontal',
className='pt-1'
),
html.H3(
children='This is the static part for all pages',
className='pt-2'
)
],
style={
'height': '12vh',
# 'background-color': 'gray'
},
className='bg-primary'
)
def create_tabs(num: int) -> dbc.Tab:
"""
function creates dbc.Tab components
"""
return dbc.Tab(
label=f"Tab-{num}",
tab_id=f"tab-{num}",
children=create_tab_content(num)
)
def create_tab_content(num: int) -> dbc.Stack:
"""
function creates the tab content
"""
return dbc.Stack(
[
dbc.Stack(
[
html.Div(
children=dcc.Dropdown(
id={'type': 'xaxis', 'index': num},
multi=False,
style={'width': '100%', 'min-height': '50px'},
placeholder='Select x- axis data'
),
style={'width': '30%'},
className='pe-1'
),
html.Div(
dcc.Dropdown(
id={'type': 'yaxis', 'index': num},
multi=True,
style={'width': '100%', 'min-height': '50px'},
placeholder='Select y- axis data'
),
style={'width': '30%'},
className='pe-1'
),
dbc.Button(
id={'type': 'plot_btn', 'index': num},
children='plot chart'
)
],
direction='horizontal',
className='pb-1'
),
dcc.Graph(
id={'type': 'graph', 'index': num},
figure=go.Figure(data=[])
# ^^ this is needed, otherwise the sending of traces does not work
),
dcc.Store(id={'type': 'local_tab_store', 'index': num})
],
direction='vertical'
)