Update src/streamlit_app.py
Browse files- src/streamlit_app.py +151 -164
src/streamlit_app.py
CHANGED
|
@@ -4,7 +4,7 @@ import plotly.express as px
|
|
| 4 |
import plotly.graph_objects as go
|
| 5 |
from datetime import datetime, timedelta
|
| 6 |
|
| 7 |
-
# Page config
|
| 8 |
st.set_page_config(
|
| 9 |
page_title="Supply Chain Intelligence",
|
| 10 |
page_icon="π",
|
|
@@ -12,7 +12,7 @@ st.set_page_config(
|
|
| 12 |
initial_sidebar_state="expanded"
|
| 13 |
)
|
| 14 |
|
| 15 |
-
#
|
| 16 |
st.markdown("""
|
| 17 |
<style>
|
| 18 |
/* Import modern font */
|
|
@@ -21,152 +21,133 @@ st.markdown("""
|
|
| 21 |
/* Global styling */
|
| 22 |
.stApp {
|
| 23 |
font-family: 'Inter', sans-serif;
|
| 24 |
-
background:
|
| 25 |
}
|
| 26 |
|
| 27 |
/* Main container */
|
| 28 |
.main-container {
|
| 29 |
-
background:
|
| 30 |
-
|
| 31 |
-
border-radius: 20px;
|
| 32 |
padding: 2rem;
|
| 33 |
-
margin: 1rem;
|
| 34 |
-
box-shadow: 0
|
|
|
|
| 35 |
}
|
| 36 |
|
| 37 |
-
/*
|
| 38 |
.modern-header {
|
| 39 |
-
background:
|
| 40 |
color: white;
|
| 41 |
padding: 2rem;
|
| 42 |
-
border-radius:
|
| 43 |
margin-bottom: 2rem;
|
| 44 |
-
|
| 45 |
-
position: relative;
|
| 46 |
-
overflow: hidden;
|
| 47 |
-
}
|
| 48 |
-
|
| 49 |
-
.modern-header::before {
|
| 50 |
-
content: '';
|
| 51 |
-
position: absolute;
|
| 52 |
-
top: -50%;
|
| 53 |
-
right: -50%;
|
| 54 |
-
width: 100%;
|
| 55 |
-
height: 200%;
|
| 56 |
-
background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
|
| 57 |
-
transform: rotate(45deg);
|
| 58 |
}
|
| 59 |
|
| 60 |
.header-title {
|
| 61 |
-
font-size:
|
| 62 |
-
font-weight:
|
| 63 |
margin-bottom: 0.5rem;
|
| 64 |
-
|
| 65 |
-
z-index: 1;
|
| 66 |
}
|
| 67 |
|
| 68 |
.header-subtitle {
|
| 69 |
-
font-size:
|
| 70 |
font-weight: 400;
|
| 71 |
-
color: #
|
| 72 |
-
position: relative;
|
| 73 |
-
z-index: 1;
|
| 74 |
}
|
| 75 |
|
| 76 |
-
/*
|
| 77 |
.metric-card {
|
| 78 |
-
background:
|
| 79 |
padding: 1.5rem;
|
| 80 |
-
border-radius:
|
| 81 |
-
border: 1px solid
|
| 82 |
-
box-shadow: 0
|
| 83 |
-
transition: all 0.3s ease;
|
| 84 |
margin-bottom: 1rem;
|
|
|
|
| 85 |
}
|
| 86 |
|
| 87 |
.metric-card:hover {
|
| 88 |
-
|
| 89 |
-
|
| 90 |
}
|
| 91 |
|
| 92 |
.metric-number {
|
| 93 |
font-size: 2.5rem;
|
| 94 |
font-weight: 700;
|
| 95 |
-
|
| 96 |
-
-webkit-background-clip: text;
|
| 97 |
-
-webkit-text-fill-color: transparent;
|
| 98 |
-
background-clip: text;
|
| 99 |
margin-bottom: 0.5rem;
|
| 100 |
}
|
| 101 |
|
| 102 |
.metric-label {
|
| 103 |
color: #64748b;
|
| 104 |
-
font-size: 0.
|
| 105 |
font-weight: 500;
|
| 106 |
text-transform: uppercase;
|
| 107 |
letter-spacing: 0.05em;
|
|
|
|
| 108 |
}
|
| 109 |
|
| 110 |
.metric-change {
|
| 111 |
-
font-size: 0.
|
| 112 |
font-weight: 600;
|
| 113 |
-
padding: 0.
|
| 114 |
-
border-radius:
|
| 115 |
-
margin-top: 0.5rem;
|
| 116 |
display: inline-block;
|
| 117 |
}
|
| 118 |
|
| 119 |
.metric-positive {
|
| 120 |
-
background:
|
| 121 |
-
color: #
|
| 122 |
}
|
| 123 |
|
| 124 |
.metric-negative {
|
| 125 |
-
background:
|
| 126 |
-
color: #
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
}
|
| 128 |
|
| 129 |
-
/*
|
| 130 |
.sidebar-content {
|
| 131 |
-
background:
|
| 132 |
-
color:
|
| 133 |
-
border-radius:
|
| 134 |
padding: 1.5rem;
|
| 135 |
margin-bottom: 1rem;
|
|
|
|
|
|
|
| 136 |
}
|
| 137 |
|
| 138 |
-
/* Filter
|
| 139 |
.filter-container {
|
| 140 |
-
background:
|
| 141 |
padding: 1.5rem;
|
| 142 |
-
border-radius:
|
| 143 |
margin-bottom: 2rem;
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
/* Data table styling */
|
| 148 |
-
.dataframe {
|
| 149 |
-
border-radius: 15px;
|
| 150 |
-
overflow: hidden;
|
| 151 |
-
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
|
| 152 |
}
|
| 153 |
|
| 154 |
/* Section headers */
|
| 155 |
.section-header {
|
| 156 |
-
font-size: 1.
|
| 157 |
font-weight: 600;
|
| 158 |
color: #1e293b;
|
| 159 |
margin-bottom: 1.5rem;
|
| 160 |
-
padding-bottom: 0.
|
| 161 |
-
border-bottom:
|
| 162 |
-
border-image: linear-gradient(135deg, #667eea 0%, #764ba2 100%) 1;
|
| 163 |
}
|
| 164 |
|
| 165 |
/* Status indicators */
|
| 166 |
.status-indicator {
|
| 167 |
display: inline-block;
|
| 168 |
-
width:
|
| 169 |
-
height:
|
| 170 |
border-radius: 50%;
|
| 171 |
margin-right: 8px;
|
| 172 |
}
|
|
@@ -175,25 +156,51 @@ st.markdown("""
|
|
| 175 |
.status-warning { background-color: #f59e0b; }
|
| 176 |
.status-critical { background-color: #ef4444; }
|
| 177 |
|
| 178 |
-
/*
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 188 |
}
|
| 189 |
|
| 190 |
-
.
|
| 191 |
-
|
|
|
|
| 192 |
}
|
| 193 |
</style>
|
| 194 |
""", unsafe_allow_html=True)
|
| 195 |
|
| 196 |
-
# Sample data functions
|
| 197 |
@st.cache_data
|
| 198 |
def get_material_data():
|
| 199 |
return pd.DataFrame({
|
|
@@ -222,48 +229,48 @@ def get_enhanced_metrics():
|
|
| 222 |
'on_time_delivery': 94.2
|
| 223 |
}
|
| 224 |
|
| 225 |
-
#
|
| 226 |
st.markdown("""
|
| 227 |
-
<div class="modern-header
|
| 228 |
-
<div class="header-title"
|
| 229 |
<div class="header-subtitle">Real-time Supply Chain Resilience Dashboard β’ Control Tower Analytics</div>
|
| 230 |
</div>
|
| 231 |
""", unsafe_allow_html=True)
|
| 232 |
|
| 233 |
-
#
|
| 234 |
with st.sidebar:
|
| 235 |
st.markdown("""
|
| 236 |
<div class="sidebar-content">
|
| 237 |
-
<h3 style="margin-top: 0;"
|
| 238 |
-
<p style="
|
| 239 |
</div>
|
| 240 |
""", unsafe_allow_html=True)
|
| 241 |
|
| 242 |
nav_options = [
|
| 243 |
-
"
|
| 244 |
-
"
|
| 245 |
-
"
|
| 246 |
-
"
|
| 247 |
-
"
|
| 248 |
-
"
|
| 249 |
-
"
|
| 250 |
-
"
|
| 251 |
-
"
|
| 252 |
]
|
| 253 |
|
| 254 |
selected_nav = st.selectbox("", nav_options, index=1)
|
| 255 |
|
| 256 |
-
#
|
| 257 |
st.markdown("---")
|
| 258 |
-
st.markdown("
|
| 259 |
-
st.error("β οΈ 3
|
| 260 |
st.warning("π 12 SKUs below safety stock")
|
| 261 |
-
st.success("β
94% on-time delivery
|
| 262 |
|
| 263 |
-
#
|
| 264 |
st.markdown("""
|
| 265 |
-
<div class="filter-container
|
| 266 |
-
<div class="section-header"
|
| 267 |
</div>
|
| 268 |
""", unsafe_allow_html=True)
|
| 269 |
|
|
@@ -271,40 +278,35 @@ col1, col2, col3, col4 = st.columns(4)
|
|
| 271 |
col5, col6, col7, col8 = st.columns(4)
|
| 272 |
|
| 273 |
with col1:
|
| 274 |
-
plant_location = st.selectbox("
|
| 275 |
|
| 276 |
with col2:
|
| 277 |
-
material_group = st.selectbox("
|
| 278 |
|
| 279 |
with col3:
|
| 280 |
-
time_period = st.selectbox("
|
| 281 |
|
| 282 |
with col4:
|
| 283 |
-
supplier_tier = st.selectbox("
|
| 284 |
|
| 285 |
with col5:
|
| 286 |
-
risk_level = st.selectbox("
|
| 287 |
|
| 288 |
with col6:
|
| 289 |
-
performance = st.selectbox("
|
| 290 |
|
| 291 |
with col7:
|
| 292 |
-
geography = st.selectbox("
|
| 293 |
|
| 294 |
with col8:
|
| 295 |
-
update_freq = st.selectbox("
|
| 296 |
|
| 297 |
-
# Get
|
| 298 |
material_df = get_material_data()
|
| 299 |
metrics = get_enhanced_metrics()
|
| 300 |
|
| 301 |
-
#
|
| 302 |
-
st.markdown(""
|
| 303 |
-
<div class="main-container fade-in">
|
| 304 |
-
""", unsafe_allow_html=True)
|
| 305 |
-
|
| 306 |
-
# Key metrics section with modern cards
|
| 307 |
-
st.markdown('<div class="section-header">π Executive Dashboard</div>', unsafe_allow_html=True)
|
| 308 |
|
| 309 |
col1, col2, col3, col4 = st.columns(4)
|
| 310 |
|
|
@@ -340,85 +342,70 @@ with col4:
|
|
| 340 |
<div class="metric-card">
|
| 341 |
<div class="metric-number">{metrics['active_suppliers']:,}</div>
|
| 342 |
<div class="metric-label">Active Suppliers</div>
|
| 343 |
-
<div class="metric-change metric-
|
| 344 |
</div>
|
| 345 |
""", unsafe_allow_html=True)
|
| 346 |
|
| 347 |
-
#
|
| 348 |
-
st.markdown('<div class="section-header"
|
| 349 |
|
| 350 |
-
#
|
| 351 |
-
|
| 352 |
-
def get_status_html(risk_level):
|
| 353 |
-
if risk_level == 'Low':
|
| 354 |
-
return '<span class="status-indicator status-good"></span>Low Risk'
|
| 355 |
-
elif risk_level == 'Medium':
|
| 356 |
-
return '<span class="status-indicator status-warning"></span>Medium Risk'
|
| 357 |
-
else:
|
| 358 |
-
return '<span class="status-indicator status-critical"></span>High Risk'
|
| 359 |
-
|
| 360 |
-
df['Risk Status'] = df['Risk Level'].apply(get_status_html)
|
| 361 |
-
return df
|
| 362 |
|
| 363 |
-
#
|
| 364 |
-
|
| 365 |
-
st.markdown(enhanced_df.to_html(escape=False, index=False), unsafe_allow_html=True)
|
| 366 |
-
|
| 367 |
-
# Modern charts section
|
| 368 |
-
st.markdown('<div class="section-header">π Performance Analytics</div>', unsafe_allow_html=True)
|
| 369 |
|
| 370 |
col1, col2 = st.columns(2)
|
| 371 |
|
| 372 |
with col1:
|
| 373 |
-
#
|
| 374 |
fig1 = px.bar(
|
| 375 |
material_df,
|
| 376 |
x='Material Group',
|
| 377 |
y=['Current Rate', 'Target Rate'],
|
| 378 |
-
title="Current vs Target
|
| 379 |
-
color_discrete_sequence=['#
|
| 380 |
)
|
| 381 |
|
| 382 |
fig1.update_layout(
|
| 383 |
-
plot_bgcolor='
|
| 384 |
-
paper_bgcolor='
|
| 385 |
font_family="Inter",
|
| 386 |
-
title_font_size=
|
| 387 |
title_font_color="#1e293b",
|
| 388 |
xaxis_tickangle=-45,
|
| 389 |
height=400,
|
| 390 |
-
|
|
|
|
| 391 |
)
|
| 392 |
|
| 393 |
st.plotly_chart(fig1, use_container_width=True)
|
| 394 |
|
| 395 |
with col2:
|
| 396 |
-
#
|
| 397 |
risk_counts = material_df['Risk Level'].value_counts()
|
| 398 |
|
| 399 |
fig2 = px.pie(
|
| 400 |
values=risk_counts.values,
|
| 401 |
names=risk_counts.index,
|
| 402 |
-
title="Risk Distribution
|
| 403 |
color_discrete_sequence=['#22c55e', '#f59e0b', '#ef4444']
|
| 404 |
)
|
| 405 |
|
| 406 |
fig2.update_layout(
|
| 407 |
-
plot_bgcolor='
|
| 408 |
-
paper_bgcolor='
|
| 409 |
font_family="Inter",
|
| 410 |
-
title_font_size=
|
| 411 |
title_font_color="#1e293b",
|
| 412 |
height=400
|
| 413 |
)
|
| 414 |
|
| 415 |
st.plotly_chart(fig2, use_container_width=True)
|
| 416 |
|
| 417 |
-
|
| 418 |
-
|
| 419 |
-
# Footer with last update info
|
| 420 |
st.markdown("""
|
| 421 |
-
<div style="text-align: center; padding:
|
| 422 |
-
|
| 423 |
</div>
|
| 424 |
""".format(timestamp=datetime.now().strftime("%B %d, %Y at %I:%M %p")), unsafe_allow_html=True)
|
|
|
|
| 4 |
import plotly.graph_objects as go
|
| 5 |
from datetime import datetime, timedelta
|
| 6 |
|
| 7 |
+
# Page config
|
| 8 |
st.set_page_config(
|
| 9 |
page_title="Supply Chain Intelligence",
|
| 10 |
page_icon="π",
|
|
|
|
| 12 |
initial_sidebar_state="expanded"
|
| 13 |
)
|
| 14 |
|
| 15 |
+
# Clean, professional CSS styling
|
| 16 |
st.markdown("""
|
| 17 |
<style>
|
| 18 |
/* Import modern font */
|
|
|
|
| 21 |
/* Global styling */
|
| 22 |
.stApp {
|
| 23 |
font-family: 'Inter', sans-serif;
|
| 24 |
+
background-color: #f8fafc;
|
| 25 |
}
|
| 26 |
|
| 27 |
/* Main container */
|
| 28 |
.main-container {
|
| 29 |
+
background: white;
|
| 30 |
+
border-radius: 12px;
|
|
|
|
| 31 |
padding: 2rem;
|
| 32 |
+
margin: 1rem 0;
|
| 33 |
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
| 34 |
+
border: 1px solid #e2e8f0;
|
| 35 |
}
|
| 36 |
|
| 37 |
+
/* Clean header */
|
| 38 |
.modern-header {
|
| 39 |
+
background: #1e293b;
|
| 40 |
color: white;
|
| 41 |
padding: 2rem;
|
| 42 |
+
border-radius: 12px;
|
| 43 |
margin-bottom: 2rem;
|
| 44 |
+
border-left: 4px solid #3b82f6;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
}
|
| 46 |
|
| 47 |
.header-title {
|
| 48 |
+
font-size: 2rem;
|
| 49 |
+
font-weight: 600;
|
| 50 |
margin-bottom: 0.5rem;
|
| 51 |
+
color: white;
|
|
|
|
| 52 |
}
|
| 53 |
|
| 54 |
.header-subtitle {
|
| 55 |
+
font-size: 1rem;
|
| 56 |
font-weight: 400;
|
| 57 |
+
color: #94a3b8;
|
|
|
|
|
|
|
| 58 |
}
|
| 59 |
|
| 60 |
+
/* Clean metric cards */
|
| 61 |
.metric-card {
|
| 62 |
+
background: white;
|
| 63 |
padding: 1.5rem;
|
| 64 |
+
border-radius: 12px;
|
| 65 |
+
border: 1px solid #e2e8f0;
|
| 66 |
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
|
|
| 67 |
margin-bottom: 1rem;
|
| 68 |
+
transition: all 0.2s ease;
|
| 69 |
}
|
| 70 |
|
| 71 |
.metric-card:hover {
|
| 72 |
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
| 73 |
+
border-color: #cbd5e1;
|
| 74 |
}
|
| 75 |
|
| 76 |
.metric-number {
|
| 77 |
font-size: 2.5rem;
|
| 78 |
font-weight: 700;
|
| 79 |
+
color: #1e293b;
|
|
|
|
|
|
|
|
|
|
| 80 |
margin-bottom: 0.5rem;
|
| 81 |
}
|
| 82 |
|
| 83 |
.metric-label {
|
| 84 |
color: #64748b;
|
| 85 |
+
font-size: 0.875rem;
|
| 86 |
font-weight: 500;
|
| 87 |
text-transform: uppercase;
|
| 88 |
letter-spacing: 0.05em;
|
| 89 |
+
margin-bottom: 0.5rem;
|
| 90 |
}
|
| 91 |
|
| 92 |
.metric-change {
|
| 93 |
+
font-size: 0.875rem;
|
| 94 |
font-weight: 600;
|
| 95 |
+
padding: 0.25rem 0.75rem;
|
| 96 |
+
border-radius: 6px;
|
|
|
|
| 97 |
display: inline-block;
|
| 98 |
}
|
| 99 |
|
| 100 |
.metric-positive {
|
| 101 |
+
background-color: #dcfce7;
|
| 102 |
+
color: #166534;
|
| 103 |
}
|
| 104 |
|
| 105 |
.metric-negative {
|
| 106 |
+
background-color: #fef2f2;
|
| 107 |
+
color: #dc2626;
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
.metric-neutral {
|
| 111 |
+
background-color: #f1f5f9;
|
| 112 |
+
color: #475569;
|
| 113 |
}
|
| 114 |
|
| 115 |
+
/* Clean sidebar */
|
| 116 |
.sidebar-content {
|
| 117 |
+
background: white;
|
| 118 |
+
color: #1e293b;
|
| 119 |
+
border-radius: 12px;
|
| 120 |
padding: 1.5rem;
|
| 121 |
margin-bottom: 1rem;
|
| 122 |
+
border: 1px solid #e2e8f0;
|
| 123 |
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
| 124 |
}
|
| 125 |
|
| 126 |
+
/* Filter section */
|
| 127 |
.filter-container {
|
| 128 |
+
background: white;
|
| 129 |
padding: 1.5rem;
|
| 130 |
+
border-radius: 12px;
|
| 131 |
margin-bottom: 2rem;
|
| 132 |
+
border: 1px solid #e2e8f0;
|
| 133 |
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
}
|
| 135 |
|
| 136 |
/* Section headers */
|
| 137 |
.section-header {
|
| 138 |
+
font-size: 1.25rem;
|
| 139 |
font-weight: 600;
|
| 140 |
color: #1e293b;
|
| 141 |
margin-bottom: 1.5rem;
|
| 142 |
+
padding-bottom: 0.75rem;
|
| 143 |
+
border-bottom: 2px solid #e2e8f0;
|
|
|
|
| 144 |
}
|
| 145 |
|
| 146 |
/* Status indicators */
|
| 147 |
.status-indicator {
|
| 148 |
display: inline-block;
|
| 149 |
+
width: 8px;
|
| 150 |
+
height: 8px;
|
| 151 |
border-radius: 50%;
|
| 152 |
margin-right: 8px;
|
| 153 |
}
|
|
|
|
| 156 |
.status-warning { background-color: #f59e0b; }
|
| 157 |
.status-critical { background-color: #ef4444; }
|
| 158 |
|
| 159 |
+
/* Clean table styling */
|
| 160 |
+
.dataframe table {
|
| 161 |
+
border-collapse: collapse;
|
| 162 |
+
margin: 0;
|
| 163 |
+
font-size: 0.875rem;
|
| 164 |
+
width: 100%;
|
| 165 |
+
background: white;
|
| 166 |
+
border-radius: 8px;
|
| 167 |
+
overflow: hidden;
|
| 168 |
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
.dataframe th {
|
| 172 |
+
background-color: #f8fafc;
|
| 173 |
+
color: #374151;
|
| 174 |
+
font-weight: 600;
|
| 175 |
+
padding: 12px;
|
| 176 |
+
text-align: left;
|
| 177 |
+
border-bottom: 1px solid #e5e7eb;
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
.dataframe td {
|
| 181 |
+
padding: 12px;
|
| 182 |
+
border-bottom: 1px solid #f3f4f6;
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
.dataframe tr:hover {
|
| 186 |
+
background-color: #f9fafb;
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
/* Remove default streamlit styling */
|
| 190 |
+
.stSelectbox > div > div {
|
| 191 |
+
background-color: white;
|
| 192 |
+
border: 1px solid #d1d5db;
|
| 193 |
+
border-radius: 6px;
|
| 194 |
}
|
| 195 |
|
| 196 |
+
.stSelectbox > div > div:focus-within {
|
| 197 |
+
border-color: #3b82f6;
|
| 198 |
+
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
|
| 199 |
}
|
| 200 |
</style>
|
| 201 |
""", unsafe_allow_html=True)
|
| 202 |
|
| 203 |
+
# Sample data functions (same as before)
|
| 204 |
@st.cache_data
|
| 205 |
def get_material_data():
|
| 206 |
return pd.DataFrame({
|
|
|
|
| 229 |
'on_time_delivery': 94.2
|
| 230 |
}
|
| 231 |
|
| 232 |
+
# Clean, professional header
|
| 233 |
st.markdown("""
|
| 234 |
+
<div class="modern-header">
|
| 235 |
+
<div class="header-title">Supply Chain Intelligence Hub</div>
|
| 236 |
<div class="header-subtitle">Real-time Supply Chain Resilience Dashboard β’ Control Tower Analytics</div>
|
| 237 |
</div>
|
| 238 |
""", unsafe_allow_html=True)
|
| 239 |
|
| 240 |
+
# Professional sidebar
|
| 241 |
with st.sidebar:
|
| 242 |
st.markdown("""
|
| 243 |
<div class="sidebar-content">
|
| 244 |
+
<h3 style="margin-top: 0; color: #1e293b;">Navigation</h3>
|
| 245 |
+
<p style="color: #64748b; font-size: 0.875rem;">Select your workspace</p>
|
| 246 |
</div>
|
| 247 |
""", unsafe_allow_html=True)
|
| 248 |
|
| 249 |
nav_options = [
|
| 250 |
+
"Dashboard Home",
|
| 251 |
+
"Supply Chain Resilience",
|
| 252 |
+
"Control Tower",
|
| 253 |
+
"Material Groups",
|
| 254 |
+
"Supplier Analytics",
|
| 255 |
+
"Demand Planning",
|
| 256 |
+
"Insights & Trends",
|
| 257 |
+
"Real-time Alerts",
|
| 258 |
+
"Reports Center"
|
| 259 |
]
|
| 260 |
|
| 261 |
selected_nav = st.selectbox("", nav_options, index=1)
|
| 262 |
|
| 263 |
+
# Clean alerts section
|
| 264 |
st.markdown("---")
|
| 265 |
+
st.markdown("**System Status**")
|
| 266 |
+
st.error("β οΈ 3 suppliers need attention")
|
| 267 |
st.warning("π 12 SKUs below safety stock")
|
| 268 |
+
st.success("β
94% on-time delivery")
|
| 269 |
|
| 270 |
+
# Clean filters section
|
| 271 |
st.markdown("""
|
| 272 |
+
<div class="filter-container">
|
| 273 |
+
<div class="section-header">Filters & Controls</div>
|
| 274 |
</div>
|
| 275 |
""", unsafe_allow_html=True)
|
| 276 |
|
|
|
|
| 278 |
col5, col6, col7, col8 = st.columns(4)
|
| 279 |
|
| 280 |
with col1:
|
| 281 |
+
plant_location = st.selectbox("Plant Location", ["Chennai Hub", "Mumbai Center", "Delhi North", "Bangalore Tech"], index=0)
|
| 282 |
|
| 283 |
with col2:
|
| 284 |
+
material_group = st.selectbox("Material Category", ["All Categories", "Critical Components", "Standard Parts"], index=0)
|
| 285 |
|
| 286 |
with col3:
|
| 287 |
+
time_period = st.selectbox("Time Period", ["Current Quarter", "FY2025", "Last 6 Months"], index=0)
|
| 288 |
|
| 289 |
with col4:
|
| 290 |
+
supplier_tier = st.selectbox("Supplier Tier", ["All Tiers", "Tier 1 Strategic", "Tier 2 Operational"], index=0)
|
| 291 |
|
| 292 |
with col5:
|
| 293 |
+
risk_level = st.selectbox("Risk Level", ["All Levels", "High Risk Only", "Medium Risk", "Low Risk"], index=0)
|
| 294 |
|
| 295 |
with col6:
|
| 296 |
+
performance = st.selectbox("Performance", ["All Performance", "Above Target", "Below Target"], index=0)
|
| 297 |
|
| 298 |
with col7:
|
| 299 |
+
geography = st.selectbox("Geography", ["Global View", "Asia Pacific", "Americas", "Europe"], index=0)
|
| 300 |
|
| 301 |
with col8:
|
| 302 |
+
update_freq = st.selectbox("Update Frequency", ["Real-time", "Hourly", "Daily"], index=0)
|
| 303 |
|
| 304 |
+
# Get data
|
| 305 |
material_df = get_material_data()
|
| 306 |
metrics = get_enhanced_metrics()
|
| 307 |
|
| 308 |
+
# Clean metrics section
|
| 309 |
+
st.markdown('<div class="section-header">Key Performance Indicators</div>', unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 310 |
|
| 311 |
col1, col2, col3, col4 = st.columns(4)
|
| 312 |
|
|
|
|
| 342 |
<div class="metric-card">
|
| 343 |
<div class="metric-number">{metrics['active_suppliers']:,}</div>
|
| 344 |
<div class="metric-label">Active Suppliers</div>
|
| 345 |
+
<div class="metric-change metric-neutral">+15 new</div>
|
| 346 |
</div>
|
| 347 |
""", unsafe_allow_html=True)
|
| 348 |
|
| 349 |
+
# Clean data table
|
| 350 |
+
st.markdown('<div class="section-header">Material Group Performance</div>', unsafe_allow_html=True)
|
| 351 |
|
| 352 |
+
# Display clean table
|
| 353 |
+
st.dataframe(material_df, use_container_width=True, hide_index=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 354 |
|
| 355 |
+
# Professional charts
|
| 356 |
+
st.markdown('<div class="section-header">Performance Analytics</div>', unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 357 |
|
| 358 |
col1, col2 = st.columns(2)
|
| 359 |
|
| 360 |
with col1:
|
| 361 |
+
# Clean bar chart
|
| 362 |
fig1 = px.bar(
|
| 363 |
material_df,
|
| 364 |
x='Material Group',
|
| 365 |
y=['Current Rate', 'Target Rate'],
|
| 366 |
+
title="Fulfillment Rates: Current vs Target",
|
| 367 |
+
color_discrete_sequence=['#3b82f6', '#64748b']
|
| 368 |
)
|
| 369 |
|
| 370 |
fig1.update_layout(
|
| 371 |
+
plot_bgcolor='white',
|
| 372 |
+
paper_bgcolor='white',
|
| 373 |
font_family="Inter",
|
| 374 |
+
title_font_size=14,
|
| 375 |
title_font_color="#1e293b",
|
| 376 |
xaxis_tickangle=-45,
|
| 377 |
height=400,
|
| 378 |
+
showlegend=True,
|
| 379 |
+
legend=dict(orientation="h", yanchor="bottom", y=1.02, xanchor="right", x=1)
|
| 380 |
)
|
| 381 |
|
| 382 |
st.plotly_chart(fig1, use_container_width=True)
|
| 383 |
|
| 384 |
with col2:
|
| 385 |
+
# Clean pie chart
|
| 386 |
risk_counts = material_df['Risk Level'].value_counts()
|
| 387 |
|
| 388 |
fig2 = px.pie(
|
| 389 |
values=risk_counts.values,
|
| 390 |
names=risk_counts.index,
|
| 391 |
+
title="Risk Distribution",
|
| 392 |
color_discrete_sequence=['#22c55e', '#f59e0b', '#ef4444']
|
| 393 |
)
|
| 394 |
|
| 395 |
fig2.update_layout(
|
| 396 |
+
plot_bgcolor='white',
|
| 397 |
+
paper_bgcolor='white',
|
| 398 |
font_family="Inter",
|
| 399 |
+
title_font_size=14,
|
| 400 |
title_font_color="#1e293b",
|
| 401 |
height=400
|
| 402 |
)
|
| 403 |
|
| 404 |
st.plotly_chart(fig2, use_container_width=True)
|
| 405 |
|
| 406 |
+
# Clean footer
|
|
|
|
|
|
|
| 407 |
st.markdown("""
|
| 408 |
+
<div style="text-align: center; padding: 1.5rem; color: #64748b; border-top: 1px solid #e2e8f0; margin-top: 2rem; font-size: 0.875rem;">
|
| 409 |
+
Dashboard last updated: {timestamp} β’ Auto-refresh: Every 15 minutes β’ Data accuracy: 99.7%
|
| 410 |
</div>
|
| 411 |
""".format(timestamp=datetime.now().strftime("%B %d, %Y at %I:%M %p")), unsafe_allow_html=True)
|