Spaces:
Build error
Build error
qua605
commited on
Commit
·
0454fa1
1
Parent(s):
bfd3c5f
First Viz
Browse files
app.py
CHANGED
|
@@ -1,65 +1,21 @@
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
import altair as alt
|
| 3 |
-
from vega_datasets import data
|
| 4 |
-
|
| 5 |
-
st.title('Streamlit App for IS445: ID9518')
|
| 6 |
|
| 7 |
-
|
| 8 |
|
| 9 |
-
|
|
|
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
range=["#e7ba52", "#a7a7a7", "#aec7e8", "#1f77b4", "#9467bd"],
|
| 14 |
-
)
|
| 15 |
-
color = alt.Color("weather:N", scale=scale)
|
| 16 |
-
|
| 17 |
-
# We create two selections:
|
| 18 |
-
# - a brush that is active on the top panel
|
| 19 |
-
# - a multi-click that is active on the bottom panel
|
| 20 |
-
brush = alt.selection_interval(encodings=["x"])
|
| 21 |
-
click = alt.selection_point(encodings=["color"])
|
| 22 |
-
|
| 23 |
-
# Top panel is scatter plot of temperature vs time
|
| 24 |
-
points = (
|
| 25 |
-
alt.Chart()
|
| 26 |
-
.mark_point()
|
| 27 |
-
.encode(
|
| 28 |
-
alt.X("monthdate(date):T", title="Date (Month Year)"),
|
| 29 |
-
alt.Y(
|
| 30 |
-
"temp_max:Q",
|
| 31 |
-
title="Maximum Daily Temperature (C)",
|
| 32 |
-
scale=alt.Scale(domain=[-5, 40]),
|
| 33 |
-
),
|
| 34 |
-
color=alt.condition(brush, color, alt.value("lightgray")),
|
| 35 |
-
size=alt.Size("precipitation:Q", scale=alt.Scale(range=[5, 200])),
|
| 36 |
-
)
|
| 37 |
-
.properties(width=550, height=300)
|
| 38 |
-
.add_params(brush)
|
| 39 |
-
.transform_filter(click)
|
| 40 |
-
)
|
| 41 |
-
|
| 42 |
-
# Bottom panel is a bar chart of weather type
|
| 43 |
-
bars = (
|
| 44 |
-
alt.Chart()
|
| 45 |
.mark_bar()
|
| 46 |
.encode(
|
| 47 |
-
x="count()",
|
| 48 |
-
y="
|
| 49 |
-
color=alt.
|
| 50 |
-
)
|
| 51 |
-
.transform_filter(brush)
|
| 52 |
-
.properties(
|
| 53 |
-
width=550,
|
| 54 |
)
|
| 55 |
-
.
|
| 56 |
)
|
| 57 |
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
tab1, tab2 = st.tabs(["Streamlit theme (default)", "Altair native theme"])
|
| 61 |
-
|
| 62 |
-
with tab1:
|
| 63 |
-
st.altair_chart(chart, theme="streamlit", use_container_width=True)
|
| 64 |
-
with tab2:
|
| 65 |
-
st.altair_chart(chart, theme=None, use_container_width=True)
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
import altair as alt
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
+
data = pd.read_csv('https://raw.githubusercontent.com/UIUC-iSchool-DataViz/is445_data/main/licenses_fall2022.csv')
|
| 6 |
|
| 7 |
+
st.title("Licenses Dataset Analysis")
|
| 8 |
+
st.header("Vizualization 1: License Type")
|
| 9 |
|
| 10 |
+
viz1 = (
|
| 11 |
+
alt.Chart(data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
.mark_bar()
|
| 13 |
.encode(
|
| 14 |
+
x = alt.X("count()Q", title="Number of Licenses"),
|
| 15 |
+
y = alt.Y("Licenses Type:N", sort='-x', title="License Type"),
|
| 16 |
+
color = alt.Color("License Type:N", legend=None)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
)
|
| 18 |
+
.properties(width=600, height=400)
|
| 19 |
)
|
| 20 |
|
| 21 |
+
st.altair_chart(viz1, use_container_width=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|