utrecht-pollution-prediction / src /helper_functions.py
akseljoonas's picture
Update .gitlab-ci.yml file
359c749
raw
history blame
2.06 kB
import streamlit as st
# Custom function to create styled metric boxes with compact layout
def custom_metric_box(label, value):
st.markdown(f"""
<div style="
padding: 5px;
margin-bottom: 5px;
width: 100%; /* Full width */
display: flex;
flex-direction: column; /* Align items vertically */
align-items: flex-start; /* Align all content to the left */
">
<div>
<h4 style="font-size: 14px; font-weight: normal; margin: 0;">{label}</h4> <!-- Smaller label -->
</div>
<div>
<p style="font-size: 18px; font-weight: bold; margin: 0;">{value}</p> <!-- Smaller metric -->
</div>
</div>
""", unsafe_allow_html=True)
# Custom function to create pollution metric boxes with side-by-side layout for label and value
# Custom function to create pollution metric boxes with side-by-side layout and fixed width
def pollution_box(label, value, delta, threshold):
# Determine if the pollution level is "Good" or "Bad"
status = "Good" if float(value.split()[0]) < threshold else "Bad"
status_color = "#77C124" if status == "Good" else "#E68B0A"
# Render the pollution box
st.markdown(f"""
<div style="
background: rgba(255, 255, 255, 0.05);
border-radius: 16px;
box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
backdrop-filter: blur(5px);
-webkit-backdrop-filter: blur(5px);
border: 1px solid rgba(255, 255, 255, 0.15);
padding: 15px;
margin-bottom: 10px;
">
<h4 style="font-size: 24px; font-weight: bold; margin: 0;">{label}</h4> <!-- Bigger label -->
<p style="font-size: 36px; font-weight: bold; color: {status_color}; margin: 0;">{status}</p> <!-- Good/Bad with color -->
<p style="font-size: 18px; margin: 0;">{value}</p> <!-- Smaller value where delta used to be -->
</div>
""", unsafe_allow_html=True)