I want to update (the title of) this graph:
def update_zoom_chart(df5, device_name):
fig_zoom = px.scatter(df5
, x = "time"
, y = 'value'
, color = 'variable'
, symbol = 'variable'
, opacity = 0.5
, template = 'plotly_dark'
, title = "%s <br><sup>Data of a single error chosen from above graph</sup>" % (device_name)
)
fig_zoom.update_traces(marker = dict(
size = 5
)
)
fig_zoom.update_layout(
transition_duration = 500
, autosize = True
, height = 600
, hovermode='x unified'
)
return fig_zoom
which is working (except of the title update) via:
@app.callback(
Output("Zoomed", "figure"),
Input('General', 'clickData')
)
def update_hover(clickData):
if clickData:
path = clickData['points'][0]['hovertext']
df5 = df2[df2['Path'] == path]
device_name = df5['Device'][0]
return update_zoom_chart(df5, device_name)
else:
df5 = df2[df2['Path']== df2['Path'].iloc[0]]
device_name = df5['Device'][0]
return update_zoom_chart(df5, device_name)
What I wonder is that it is working in the very first instance (so the else condition seems to work) but when I click on a data point which makes the graph to be updated via the the if-condition, the title update is not working. I receive a quite long list of error which is (to me) very non-specific but the very last line is:
line 3631, in get_loc
raise KeyError(key) from err
KeyError: 0
I guess it must be somehow due to df5 = df2[df2['Path'] == path]
and df5 = df2[df2['Path']== df2['Path'].iloc[0]]
but why?
Is there a possibility to print variables etc. when being in a dash?