Thanks to visit codestin.com
Credit goes to github.com

Skip to content

st.altair_chart shows blank axis and chart when provided a datetime domain  #5733

@tyler-simons

Description

@tyler-simons

Checklist

  • I have searched the existing issues for similar issues.
  • I added a very descriptive title to this issue.
  • I have provided sufficient information below to help reproduce this issue.

Summary

Axis shows blank and the chart shows blank for an altair chart when it is passed a datetime domain. Setting a domain for a non-datetime axis works (tried for quantitative, Q). Chart shows up correctly when passed to altair.show() which indicates this may be a bug with Streamlit.

Reproducible Code Example

Open in Streamlit Cloud

import altair as alt
import pandas as pd
import streamlit as st
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)

Steps To Reproduce

  1. Run the reproducible code (streamlit run app.py) in with Streamlit 1.15 and see that the chart is blank.
  2. Downgrade Streamlit to 1.13 and see that the chart displays as expected.
  3. Upgrade to Streamlit 1.14 to see that it does not work in version 1.14 either.

Expected Behavior

We expect that the domain adjusts the st.altair_chart axis when passed the datetime domain and that the data displays correctly.

Current Behavior

The chart and axis is blank.

Is this a regression?

  • Yes, this used to work in a previous version.

Debug info

  • Streamlit version: 1.15.0
  • Python version: 3.10.8
  • Operating System: Mac OSX 12.6.1
  • Browser: Chrome
  • Virtual environment: Pipenv

Additional Information

This error was reported by user xavierc on the Streamlit forums. Thanks xavierc for noticing it!

Works in Streamlit 1.13
Screen Shot 2022-11-18 at 10 22 15 AM

Fails in Streamlit >1.14
image

Are you willing to submit a PR?

  • Yes, I am willing to submit a PR!

Metadata

Metadata

Assignees

Labels

feature:st.altair_chartRelated to the `st.altair_chart` elementpriority:P3Medium prioritystatus:confirmedBug has been confirmed by the Streamlit teamtype:bugSomething isn't working as expectedtype:regressionThis bug is a regression from previous behaviorupstreamIssue caused by upstream dependency

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions