Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -870,27 +870,52 @@ def main():
|
|
| 870 |
if df is not None and stats is not None:
|
| 871 |
st.markdown('<div class="section-header">📋 Material Overview</div>', unsafe_allow_html=True)
|
| 872 |
materials = [k for k in stats.keys() if k != '_total_']
|
|
|
|
| 873 |
|
| 874 |
-
|
|
|
|
|
|
|
|
|
|
| 875 |
|
| 876 |
-
|
| 877 |
-
info = stats[material]
|
| 878 |
-
with cols[i]:
|
| 879 |
-
st.metric(
|
| 880 |
-
label=material.replace('_', ' ').title(),
|
| 881 |
-
value=f"{info['total']:,.0f} kg",
|
| 882 |
-
delta=f"{info['percentage']:.1f}% of total"
|
| 883 |
-
)
|
| 884 |
-
st.caption(f"Daily avg: {info['daily_avg']:,.0f} kg")
|
| 885 |
|
| 886 |
-
|
| 887 |
-
|
| 888 |
-
|
| 889 |
-
|
| 890 |
-
|
| 891 |
-
|
| 892 |
-
|
| 893 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 894 |
|
| 895 |
st.markdown('<div class="section-header">📊 Production Trends</div>', unsafe_allow_html=True)
|
| 896 |
col1, col2 = st.columns([3, 1])
|
|
|
|
| 870 |
if df is not None and stats is not None:
|
| 871 |
st.markdown('<div class="section-header">📋 Material Overview</div>', unsafe_allow_html=True)
|
| 872 |
materials = [k for k in stats.keys() if k != '_total_']
|
| 873 |
+
all_metrics = materials + ['_total_']
|
| 874 |
|
| 875 |
+
# Split metrics into two columns
|
| 876 |
+
mid_point = min(4, len(all_metrics))
|
| 877 |
+
left_metrics = all_metrics[:mid_point]
|
| 878 |
+
right_metrics = all_metrics[mid_point:]
|
| 879 |
|
| 880 |
+
col1, col2 = st.columns(2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 881 |
|
| 882 |
+
with col1:
|
| 883 |
+
for item in left_metrics:
|
| 884 |
+
if item == '_total_':
|
| 885 |
+
info = stats['_total_']
|
| 886 |
+
st.metric(
|
| 887 |
+
label="Total Production",
|
| 888 |
+
value=f"{info['total']:,.0f} kg",
|
| 889 |
+
delta="100% of total"
|
| 890 |
+
)
|
| 891 |
+
st.caption(f"Daily avg: {info['daily_avg']:,.0f} kg")
|
| 892 |
+
else:
|
| 893 |
+
info = stats[item]
|
| 894 |
+
st.metric(
|
| 895 |
+
label=item.replace('_', ' ').title(),
|
| 896 |
+
value=f"{info['total']:,.0f} kg",
|
| 897 |
+
delta=f"{info['percentage']:.1f}% of total"
|
| 898 |
+
)
|
| 899 |
+
st.caption(f"Daily avg: {info['daily_avg']:,.0f} kg")
|
| 900 |
+
|
| 901 |
+
with col2:
|
| 902 |
+
for item in right_metrics:
|
| 903 |
+
if item == '_total_':
|
| 904 |
+
info = stats['_total_']
|
| 905 |
+
st.metric(
|
| 906 |
+
label="Total Production",
|
| 907 |
+
value=f"{info['total']:,.0f} kg",
|
| 908 |
+
delta="100% of total"
|
| 909 |
+
)
|
| 910 |
+
st.caption(f"Daily avg: {info['daily_avg']:,.0f} kg")
|
| 911 |
+
else:
|
| 912 |
+
info = stats[item]
|
| 913 |
+
st.metric(
|
| 914 |
+
label=item.replace('_', ' ').title(),
|
| 915 |
+
value=f"{info['total']:,.0f} kg",
|
| 916 |
+
delta=f"{info['percentage']:.1f}% of total"
|
| 917 |
+
)
|
| 918 |
+
st.caption(f"Daily avg: {info['daily_avg']:,.0f} kg")
|
| 919 |
|
| 920 |
st.markdown('<div class="section-header">📊 Production Trends</div>', unsafe_allow_html=True)
|
| 921 |
col1, col2 = st.columns([3, 1])
|