from dash import Dash,dcc,html
import plotly.express as px
import pandas as pd
# 创建示例数据
df = pd.DataFrame(dict(
x=[1, 2, 3, 4, 5],
y=[1, 4, 9, 16, 25],
label = ["aaaa","bbbb","cccc","ddddd","eeee"]
))
fig = px.scatter(df, x='x', y='y')
for index, row in df.iterrows():
fig.add_annotation(
x = row["x"],
y = row["y"],
text = row["label"]
)
# 初始化Dash应用
app = Dash(__name__)
# 定义布局
app.layout = html.Div([
dcc.Graph(
figure=fig,
config= {
'editable': True,
'edits': {
'annotationPosition': True,
'annotationText': True
}}
)
])
if __name__ == '__main__':
app.run_server(debug=True)
I want to get the click event of the annotation text and then call the callback in dash. How should I do it?