lynn-twinkl
commited on
Commit
·
147f63f
1
Parent(s):
9168705
Added color coding to necessity index chart
Browse files
app.py
CHANGED
|
@@ -4,6 +4,7 @@
|
|
| 4 |
|
| 5 |
import streamlit as st
|
| 6 |
import pandas as pd
|
|
|
|
| 7 |
from io import BytesIO
|
| 8 |
from streamlit_extras.metric_cards import style_metric_cards
|
| 9 |
|
|
@@ -127,5 +128,18 @@ if uploaded_file is not None:
|
|
| 127 |
st.subheader("Necessity Index Distribution")
|
| 128 |
st.write("")
|
| 129 |
st.write("")
|
| 130 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
st.dataframe(df, hide_index=True)
|
|
|
|
| 4 |
|
| 5 |
import streamlit as st
|
| 6 |
import pandas as pd
|
| 7 |
+
import altair as alt
|
| 8 |
from io import BytesIO
|
| 9 |
from streamlit_extras.metric_cards import style_metric_cards
|
| 10 |
|
|
|
|
| 128 |
st.subheader("Necessity Index Distribution")
|
| 129 |
st.write("")
|
| 130 |
st.write("")
|
| 131 |
+
# Histogram of necessity index colored by priority labels
|
| 132 |
+
chart = alt.Chart(df).mark_bar().encode(
|
| 133 |
+
x=alt.X('necessity_index:Q', bin=alt.Bin(maxbins=20), title='Necessity Index'),
|
| 134 |
+
y='count()',
|
| 135 |
+
color=alt.Color(
|
| 136 |
+
'priority:N',
|
| 137 |
+
scale=alt.Scale(
|
| 138 |
+
domain=['low', 'medium', 'high', 'priority'],
|
| 139 |
+
range=['#a7d6fd', '#FFA500', '#FF5733', '#FF0000']
|
| 140 |
+
),
|
| 141 |
+
legend=alt.Legend(title='Priority')
|
| 142 |
+
)
|
| 143 |
+
)
|
| 144 |
+
st.altair_chart(chart, use_container_width=True)
|
| 145 |
st.dataframe(df, hide_index=True)
|