I see that displaying a dataframe with st.dataframe(df) allows the dataframe to scroll. However, if I’m drawing multiple graphs within individual columns of an expandable, sometimes, the “overrun” the width and get clipped. It would be very helpful in this case, to allow the expandable to horizontally scroll, so that I don’t lose my graphs.
Does such functionality exist?
Here’s a minimal example of what I’m trying to do:
graphs = [some, list, of, graph, data]
with st.expandable("section title"):
cols = st.columns(len(graphs))
for col, graph_data in zip(cols, graphs):
st.altair_graph(my_draw_graph_function(graph_data))
The grid works just fine - there are n cells packed within the page width. The problem is that each cell has an altair chart in it, and the chart gets truncated/cut/clipped because it is wider than the width of the cell.
I would in fact love to be able to allow the cells to be expanded by the size of their contents (the altair charts in this case) and overflow page-width with a horizontal scrollbar
The only other option I can think of that will immediately allow you to at least view the charts would be to set the Altair charts use_container-width property to true. That should scale them up and down so the whole chart is visible in the allotted width. (however small). I’m not sure how Streamlit decides what width is a good width for viewing and when it starts kicking columns down to subsequent rows.
If you put a feature request in the streamlit github for what you are looking for (scrolling containers), the streamlit team is usually pretty good about considering and responding to feature requests.
I’m not sure that scrolling columns give the best user experience though. Typically, web pages strictly scroll vertically and the content resizes and reforms to explicitly avoid horizontal scrolling.
The option “use_container_width=True” only works with a single Altair chart. It failed when I used Altair charts with ‘alt.hconcat’ (combined 2 Altair charts horizontally) - my chart was cut off when browser was resized.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.