Hello There,
I m trying to make a UI that will help to label time series (600 seconds signal )data. In the interface 2 buttons switch between the time series.
The function defined after the callback is actually never called
Scouring the forum, I found similar problems and the solution didn’t work for me.
Can anyone help me solving this disaster?
Here is the code:
def dash(signal_type='strain',
sensor,
staring_date,
port,
project_db,
data_root ,
location ):
app = JupyterDash(__name__,external_stylesheets=[dbc.themes.BOOTSTRAP])
app.layout = html.Div([
dbc.Row(
dbc.Col(
html.H1(children='Signal Labeling of '+str(signal_type), style = {'textAlign': 'center'}),
width={'size':12, 'offset':0},
),
),
dbc.Row([
dbc.Col(
dbc.Button(
'Previous Timestamp', id='previous', style=dict(width='100%', display='inline-block'), n_clicks=0),
width=4
),
dbc.Col(
html.Div(
[staring_date],id='timestamp', style=dict(width='100%', display='inline-block')),
width=4
),
dbc.Col(
dbc.Button(
'Next Timestamp', id='next', style=dict(width='100%', display='inline-block'), n_clicks=0
),
width=4
),
]),
dbc.Row([
dbc.Col(
dcc.Graph(id='graph'),
width=10
)
]),
dbc.Row([
dbc.Col(
dcc.RangeSlider(
id='BoundaryEvent1',
min=0,
max=600,
step=1,
value=[0,600]
),
width=10
),
dbc.Col(
dbc.Button(
'Event1', id='Event1', style=dict(width='100%', display='inline-block'), n_clicks=0
),
width=2
)
]),
dbc.Row([
dbc.Col(
dcc.RangeSlider(
id='BoundaryEvent2',
min=0,
max=600,
step=1,
value=[0, 600]
),
width=10
),
dbc.Col(
dbc.Button(
'Event2', id='Event2', style=dict(width='100%', display='inline-block'), n_clicks=0
),
width=2
)
])
])
@app.callback(
[Output('timestamp','children'),
Output('graph','figure')],
[Input('previous','n_clicks'),
Input('next','n_clicks'),
Input('timestamp','children')])
def display_graph(previous,next,dt):
print('I m triggered')
ctx = dash.callback_context
triggered_id = ctx.triggered[0]['prop_id'].split('.')[0]
print(triggered_id)
if triggered_id == 'previous':
dt=dt-datetime.timedelta(minutes=10)
elif triggered_id == 'next':
dt = dt + datetime.timedelta(minutes=10)
signal = dw.getTDMS(dt,signal_type , location, root=data_root, duration=1, database=project_db)
data, layout = signal[sensor].plotly()
fig = go.Figure(data=data, layout=layout)
return dt,fig
app.run_server(mode='inline', port=port)
The print (‘I m triggered’) doesn’t show anything.
You also have the app layout here
Thank you in advance