I need multiple vertically stacked charts to change width as browser changes its window width. But with altair charts, width of vconcat-ed charts is not handled well.
Iโm using streamlit 0.71.0, and just upgraded to 0.72.0.
Using this example vertical-concatenation
, slightly change it and without explicitly setting witdh property and setting use_container_width=True, the width is fixed and does not change as browser window width.
When I do the same when showing only single chart or showing two charts layered, width changes when I run the app in wide-mode. But in centered-mode, the width stays unchanged even if I change browser window width.
I tried using autoSizeParams like this but no luck and the result is the same.
There has been PR684 from a year ago and it seems the code has been merged.
The code Iโm using to show vconcat-ed charts is following. What am I missing?
Thanks in advance.
indent preformatted text by 4 spaces
import streamlit as st
import altair as alt
from vega_datasets import data
source = data.sp500.url
brush = alt.selection(type='interval', encodings=['x'])
base = alt.Chart(source).mark_area().encode(
x = 'date:T',
y = 'price:Q'
).properties(
height=200
)
upper = base.encode(
alt.X('date:T', scale=alt.Scale(domain=brush))
)
lower = base.properties(
height=60
).add_selection(brush)
autosize = alt.AutoSizeParams(contains="content", resize=True, type='fit-x')
c = alt.vconcat(upper, lower, autosize=autosize)
st.altair_chart(c, use_container_width=True)
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.