Best approach to mapping with dynamic updates

Hey there,

Iā€™ve been thrown into a data science project (yes, Covid-19) and have been experimenting heavily with streamlit, which is awesome. There may be one key concept Iā€™m missing, however.

Thereā€™s one use case Iā€™ve havenā€™t quite been able to master, which is producing rich and performant maps where the user can change what is being displayed on the maps, without the plot resetting itself when they change an option using provided controls. By this I mean, the users selects the fields for the size/colour/hovertext of the marker, and the markers and their data update quickly. I can make nice plots in several packages, for instance Plotly, but the downside is every time the user makes a change, I call my ā€œmake_plotā€ function, the chart is redrawn and the zoom/positioning is reset.

st.map is too simple for my uses and PyDeck seems to have several bugs, e.g. hovertext not supported. Is there anything Iā€™m missing - some way to interact with a plot without redrawing the whole thing from scratch? I canā€™t tell from the docs how this is accomplished with the built-in map, for instance. And custom javascript seems unimplemented/not the streamlit way.

Any tips appreciated.

When you use streamlit selectors, it will always re-render the viz as everything is run from top to bottom.

I think the way to go is to use streamlit inputs for the big picture stuff which doesnā€™t get changed often, and the rest of the interactive map changes to do in plotly directly.

That way the often used sliders or dropdowns wonā€™t re-render the whole thing.

see these covid dashboard - they are using altair for viz and are coding some of the selection stuff into altair itself.

1 Like

Hi @khalido, I did try to do the same in altair, but the graph freezes in streamlit when I change the slider embedded into altair. Things are working fine in Jupyter.