My streamlit app generates charts using Plotly.
Plotly allows you to add annotations to a chart, for instance under the chart title like so.
But the annotation is hard coded.
user_input="This is my hard-coded annotathon that helps understand the chart and that I would like to type in with a widget." fig.add_annotation(text = user_input, xref = "paper", yref = "paper", x = 0, y = 1.060, showarrow = False, align = "left", xanchor = "left", font = dict(size = 11, color = "#242526"))
I would like the user to be able write the annotation into a text input widget and (after re-submitting ) magically show up in the chart. The text input widget should be on top or just below each chart (there is more than one chart).
I have tried adding a widget, but when, after entering my comment, I rerun the chart, my widget naturally goes to blank and no annotation shows up in the chart.
I am sure this is a job for st.session_state() but I have no idea how to implement it.
It should be possible to annotate each chart independently with a different widget .
Thanks so much for your help!