Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions streamlit_analytics/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
)
Expand Down
4 changes: 2 additions & 2 deletions streamlit_analytics/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down