diff --git a/streamlit_analytics/display.py b/streamlit_analytics/display.py index 9a8cbbb..04bf1bd 100644 --- a/streamlit_analytics/display.py +++ b/streamlit_analytics/display.py @@ -60,7 +60,11 @@ def show_results(counts, reset_callback, unsafe_password=None): alt.themes.enable("streamlit") except: pass # probably old Streamlit version + df = pd.DataFrame(counts["per_day"]) + # Formatting date by ISO-8601 to fix altair's date parsing bug + df["days"] = df["days"] + "T00:00:00" + base = alt.Chart(df).encode( x=alt.X("monthdate(days):O", axis=alt.Axis(title="", grid=True)) ) diff --git a/streamlit_analytics/main.py b/streamlit_analytics/main.py index 442b5ec..2ba17d8 100644 --- a/streamlit_analytics/main.py +++ b/streamlit_analytics/main.py @@ -20,11 +20,11 @@ def reset_counts(): # Use yesterday as first entry to make chart look better. - yesterday = str(datetime.date.today() - datetime.timedelta(days=1)) + today = datetime.date.today() counts["total_pageviews"] = 0 counts["total_script_runs"] = 0 counts["total_time_seconds"] = 0 - counts["per_day"] = {"days": [str(yesterday)], "pageviews": [0], "script_runs": [0]} + counts["per_day"] = {"days": [str(today)], "pageviews": [0], "script_runs": [0]} counts["widgets"] = {} counts["start_time"] = datetime.datetime.now().strftime("%d %b %Y, %H:%M:%S")