Hi
I’m trying to set custom scales to a time axis in an altair chart. It used to work fine, until I updated to streamlit version 1.15.0
import streamlit as st
import pandas as pd
import altair as alt
from vega_datasets import data
temps = data.seattle_temps()
temps = temps[ temps.date.dt.hour == 10 ]
startDate = pd.to_datetime("2010-06-01")
endDate = pd.to_datetime("2010-06-30")
myScale = alt.Scale(domain=[startDate, endDate], )
c = alt.Chart(temps).mark_line(clip=True).encode(
x=alt.X('date:T', scale=myScale),
y='temp:Q'
)
st.altair_chart( c )
c.show()
Hi @xavierc, thanks for posting in the forum! I believe this is a bug – you’ve pointed out correctly (and I’ve verified) that this works in Streamlit 1.13 but not in >=1.14. I’ve filed a bug here and you can follow as it gets resolved.
Hey @xavierc, I wanted to follow up on this – it turns out that this is a bug in Altair – not Streamlit specifically. I gave it a spin in a jupyter notebook and a colab notebook (removing any Streamlit code) and the chart is also blank there. I encourage you to give it a try. We are going to file a bug for Altair and hopefully, they can fix it!
Hi @TylerS, do you have a minimal example reproducing the Altair bug?/Altair bug report yet? I’m a little confused how a Streamlit version change exposed an Altair regression. Does Streamlit use a pinned Altair version and did they increment it?
I think Streamlit changed how they evaluate Altair calls with the upgrade to 1.14.
import altair as alt
import pandas as pd
from vega_datasets import data
import datetime
temps = data.seattle_temps()
temps = temps[temps.date.dt.hour == 10]
startDate = pd.to_datetime("2010-06-01")
endDate = pd.to_datetime("2010-06-30")
myScale = alt.Scale(domain=[startDate, endDate])
c = (alt.Chart(temps)
.mark_line(clip=True)
.encode(x=alt.X("temp:T", scale=myScale), y="temp:Q"))
c```
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.