Quantcast
Channel: 🎛️ Dash - Plotly Community Forum
Viewing all articles
Browse latest Browse all 6271

Create a callback for dashboard that reads data from annotations when hovering

$
0
0

I have created a figure in which I first plot an image then I add a scatterplot as new trace and then I have add some annotations in at specific points in the scatterplot using the fig.add_annotation function.

fig = go.Figure(layout = layout, data =px.imshow(wave_mask))#, 
fig.update_traces(hoverinfo='none', hovertemplate='')
fig.add_trace(go.Scatter(y=np.asarray(var_position)[:,0],
                 x=np.asarray(var_position)[:,1],
                 mode='markers',
                 marker=dict(
                    opacity=1,#0 =transparent
                    ),
                 text=np.asarray(var_str),
                 #hoverinfo='none',
                 #visible=False,
                 #hovertext=np.asarray(var_str)
))

for i in idx_or1:# add annotation at the indices contained in the list idx_or1
    
    fig.add_annotation(y=np.asarray(var_position)[i,0],
         x=np.asarray(var_position)[i,1],
         text=np.asarray(var_str)[i],
         textangle=90,
         showarrow=False,
         xanchor="left",
         yanchor="top",
         clicktoshow='onout',
         captureevents=True,
         hovertext='some text',
         )

How do I write a callback for my dashboard from which I can retrieve the text in the added annotations?

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 6271

Trending Articles