Skip to content
Snippets Groups Projects

Viz devl 2021 02 08

Merged Jürgen Dammers requested to merge viz-devl-2021-02-08 into master
2 files
+ 194
68
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 63
38
@@ -48,7 +48,7 @@ __version__= "2021-01-21-001"
class _FIGURE_DATA(_SLOTS):
__slots__=("id","data","times","label","labels","type","info","ics","topo_img","chop","downsampling","table",
__slots__=("id","data","times","label","labels","type","info","ics","topo_img","chop","downsampling","table","types",
"figure","page_spacing","plot_spacing","magrin","layout","cols","rows","_param","_cls_name")
@property
@@ -94,6 +94,7 @@ class _BASE(_SLOTS):
def init_group_toggle_buttons(self,groups=None,color="info"):
id = self._id_toggle_button_group
tgls= [ dbc.Col( html.H3( dbc.Badge("Groups",color=color,className="mr-2")),width="auto")]
for g in groups:
tgls.append( html.H3( g.upper(),style={'color':self.colors['white'],'font-weight':'bold'})),
tgls.append( dbc.Col( html.H3( daq.BooleanSwitch( id=f"{g.lower()}-{id}",on=True,className='dark-theme-control')),width="auto"))
@@ -216,18 +217,24 @@ class DCNN_APP(_BASE):
def _init_ica_panel(self):
divs = []
#for d,l in zip(data,labels,spacing):
sp = 2
mag = dict(l=sp,r=sp,t=sp,b=sp)
cl="blue"
for fd in self.figure_data:
divs.append(
divs.append(
html.Div([dcc.Graph(figure=fd.figure,id=fd.id,config={'displayModeBar':False},style={'height':f"{fd.plot_spacing}vh"}),
dcc.Store(id=f"{fd.id}-data-store")],id=f"{fd.id}-div",
style={'overflowY':'scroll','height':f"{fd.page_spacing}vh",
'border-style':'solid','border-color':'blue','margin-left':'0.5%'}))
return dbc.Card( html.Div([dbc.Collapse(div,id=f"collapse-{fd.id}",is_open=True) for div,fd in zip(divs,self.figure_data) ] ),body=True)
'border-style':'solid','border-color':cl,'magrin':mag}))
cl="green"
return dbc.Card( html.Div([dbc.Collapse(div,id=f"{fd.id}-collapse",is_open=True) for div,fd in zip(divs,self.figure_data) ] ),body=True)
def _init_performance_panel(self):
fd=self.figure_data[0]
sp = 2
mag = dict(l=sp,r=sp,t=sp,b=sp)
return dbc.Card([
dbc.Card(
[
@@ -236,7 +243,7 @@ class DCNN_APP(_BASE):
# dcc.Store(id=f"{fd.id}-table-data-store")
],id=f"{fd.id}-table-div",
style={'overflowY':'scroll','height':f"{fd.page_spacing}vh",
'border-style':'solid','border-color':'blue','margin-left':'0.001%','margin-right':'0.001%'})
'border-style':'solid','border-color':'blue','margin':mag})
],body=True,style={'border-style': 'solid', 'border-color': 'gray','height':'49,4vh'}),
dbc.Card(
[
@@ -247,10 +254,11 @@ class DCNN_APP(_BASE):
def _init_main_panel(self):
sp=2
style = {'border-style':'solid','border-color':'gray','magrin':dict(l=sp,r=sp,t=sp,b=sp)}
return dbc.Row([
dbc.Col(children=[self._init_performance_panel()], width=3,style={'border-style': 'solid', 'border-color': 'gray','margin-left': '0.01%'}),
dbc.Col(children=[self._init_ica_panel()],style={'border-style': 'solid', 'border-color': 'gray','margin-left': '0.02%'}, )
dbc.Col(children=[self._init_performance_panel()], width=3,style=style),
dbc.Col(children=[self._init_ica_panel()],style=style)
])
@@ -262,15 +270,15 @@ class DCNN_APP(_BASE):
#self.app.config.suppress_callback_exceptions = True
self.app.run_server(debug=True, use_reloader=True)
def _clickOnToggleButton(status):
def OnToggleFigure(self,status):
return status
'''
def _update_figure(self,chop_idx):
ctx = dash.callback_context
id = ctx.triggered[0]['prop_id']
fig_ics,fig_aux = self.update_figure()# chop_index=int(chop_idx)-1 )
return fig_ics,fig_aux #,chop_idx
'''
#def _init_callback_plots( self ):
#
# self.app.callback(
@@ -292,7 +300,7 @@ class DCNN_APP(_BASE):
#logger.info(f"ctx output list: {ctx.outputs_list}" )
id = ctx.outputs_list[0]['id'].split('-')[0]
#logger.info(id)
return [ self.update_figure(type=id,chop=cop_idx-1) ]
return [ self.update_figure(type=id) ]
def OnChangeSelectionBox(self,down,up,options,idx):
ctx = dash.callback_context
@@ -311,8 +319,14 @@ class DCNN_APP(_BASE):
return [idx]
def OnFileChange(self,idx):
self.update_data( file_index=int(idx) -1 )
def OnChangeChop(self,idx):
# -- update chop data
#logger.info(f" index: {idx}\n --> {options}" )
self.update_data( file_index=None,chop_index= int(idx)-1 )
return [f"{int(idx):03d}"]
def OnChangeFile(self,idx):
self.update_data(file_index=int(idx) -1)
return [ [{'label':f"{c}",'value':c} for c in np.arange(self.n_chops)+1] ]
#return [f"{int(idx):03d}",chops]
@@ -321,48 +335,59 @@ class DCNN_APP(_BASE):
idx=idx[0]
return [f"{int(idx):03d}"]
# --- selectionbox
# -- selectionbox
def _init_callback_selectionbox(self):
type1 = f"file-{self._id_selection_box}" # -- Files
type2 = f"chop-{self._id_selection_box}" # -- Chops
id_files = f"file-{self._id_selection_box}" # -- Files
id_chops = f"chop-{self._id_selection_box}" # -- Chops
# -- File
app.callback([Output(f"{type1}-sl",'value')],
[Input(f"{type1}-bt-down",'n_clicks'),Input(f"{type1}-bt-up",'n_clicks')],
[State(f"{type1}-sl",'options'),State(f"{type1}-sl",'value')],
app.callback([Output(f"{id_files}-sl",'value')],
[Input(f"{id_files}-bt-down",'n_clicks'),Input(f"{id_files}-bt-up",'n_clicks'),
Input(f"{id_files}-sl",'options')],
[State(f"{id_files}-sl",'value')],
prevent_initial_call=True)(self.OnChangeSelectionBox)
app.callback([Output(f"{type2}-sl","options") ],
[Input(f"{type1}-sl", 'value')],
prevent_initial_call=True)(self.OnFileChange)
app.callback([Output(f"{id_chops}-sl","options") ],
[Input(f"{id_files}-sl", 'value')],
prevent_initial_call=True)(self.OnChangeFile)
app.callback([Output(f"{type1}-badge",'children')],
[Input(f"{type1}-sl", 'value')],
app.callback([Output(f"{id_files}-badge",'children')],
[Input(f"{id_files}-sl", 'value')],
prevent_initial_call=True)(self.OnChangeBadge)
# -- Chop
app.callback([Output(f"{type2}-sl",'value')],
[Input(f"{type2}-bt-down",'n_clicks'),Input(f"{type2}-bt-up",'n_clicks'),Input(f"{type2}-sl",'options')],
[State(f"{type2}-sl",'value')],
prevent_initial_call=True)(self.OnChangeSelectionBox)
# -- Chop
app.callback([Output(f"{id_chops}-sl",'value')],
[Input(f"{id_chops}-bt-down",'n_clicks'),Input(f"{id_chops}-bt-up",'n_clicks'),
Input(f"{id_chops}-sl",'options')],
[State(f"{id_chops}-sl",'value')],
prevent_initial_call=True)(self.OnChangeSelectionBox) #self.OnChopChange)
app.callback([Output(f"{type2}-badge",'children')],
[Input(f"{type2}-sl", 'value')],
prevent_initial_call=True)(self.OnChangeBadge)
app.callback([Output(f"{id_chops}-badge",'children')],
[Input(f"{id_chops}-sl", 'value')],
prevent_initial_call=True)(self.OnChangeChop) #ChangeBadge)
fd=self.figure_data[0]
app.callback([Output(f"{fd.id}-table-div",'children')],
[Input(f"{type2}-sl", 'value')],
[Input(f"{id_chops}-badge",'children')],
prevent_initial_call=True)(self.OnChangeTable)
for fg in self.figure_data:
app.callback(
self.app.callback(
[Output(f"{fg.id}","figure")],
[Input(f"{type2}-sl",'value')],
[Input(f"{id_chops}-badge",'children')],
#[State(f"{id_chops}-sl", 'value')],
prevent_initial_call=True)(self.OnChangeFigure)
for g in self.groups:
self.app.callback(
Output(f"{g.lower()}-figure-collapse", "is_open"),
[Input(f"{g.lower()}-{self._id_toggle_button_group}","on")],
prevent_initial_call=True)(self.OnToggleFigure)
#app.callback(
# [Output(f"{fg.id}","figure") for fg in self.figure_data],
# [Input(f"{type2}-sl",'value')],
Loading