S
Solara7d ago
Jeff

Annoying transition between Plotly figure updates

I have a data analysis application that allows selection from a number of datasets. When updating the FigurePlotly component with a new figure, an odd multi-step transition occurs in the figure. Does anyone know what is going on and how to force a cleaner transition? I have tried several ideas such as updating only the data in the figure structure but nothing works. Is this transition inherent to Solara or Plotly (since Solara uses the Plotly FigureWidget)? https://py.cafe/physiksdoc/solara-plotly-figure-transition
PyCafe - Solara - Solara-Plotly Figure Transition
Create & Share Streamlit, Dash and Python Apps Online.
2 Replies
MaartenBreddels
It's a plotly thing. We know a way to solve it, but we would need to create a new plotly widget for this to work well. But I think the best way for now is to force re-creating the component instance using a unique key based on the data.
solara.FigurePlotly(plotly_figure.value,
dependencies=[plotly_figure.value['data']]).key(id(plotly_figure.value))
solara.FigurePlotly(plotly_figure.value,
dependencies=[plotly_figure.value['data']]).key(id(plotly_figure.value))
For instance, this already does a ton better don't you think?
Jeff
Jeff6d ago
Oh yes, that is a most impressive result! Thank you and I will have to look into the use of that key method in more detail. Attached is the example with the addition of your solution for anyone who wants to see the stunning improvement. https://py.cafe/physiksdoc/solara-plotly-figure-transition-key-fix
PyCafe - Solara - Solara-Plotly Figure Transition (with Key Fix)
Create & Share Streamlit, Dash and Python Apps Online.
Want results from more Discord servers?
Add your server