Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -804,33 +804,56 @@ with col1:
|
|
| 804 |
|
| 805 |
|
| 806 |
# =============== COL 2: Front — Temperature / Speed (Boxplot) ===============
|
|
|
|
| 807 |
with col2:
|
| 808 |
-
st.markdown('<h5 style="text-align:center; margin-top: 0;">Front Tyres: Temperature / Speed
|
| 809 |
|
| 810 |
if not front_df.empty:
|
| 811 |
-
#
|
| 812 |
front_df = front_df[front_df['Speed (km/h)'] > 0]
|
|
|
|
| 813 |
|
| 814 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 815 |
|
| 816 |
-
valid_data = front_df.dropna(subset=['Temp_Speed_Ratio'])
|
| 817 |
if not valid_data.empty:
|
| 818 |
-
fig2 = px.
|
| 819 |
valid_data,
|
| 820 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 821 |
template="plotly_white",
|
| 822 |
-
labels={'Temp_Speed_Ratio': 'Temperature / Speed'}
|
| 823 |
)
|
| 824 |
|
| 825 |
fig2.update_traces(
|
| 826 |
-
|
| 827 |
-
|
| 828 |
)
|
| 829 |
|
| 830 |
fig2.update_layout(
|
| 831 |
margin=dict(t=40),
|
| 832 |
-
|
| 833 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 834 |
)
|
| 835 |
st.plotly_chart(fig2, use_container_width=True)
|
| 836 |
else:
|
|
@@ -918,33 +941,56 @@ with col3:
|
|
| 918 |
else:
|
| 919 |
st.warning("No rear tyre data.")
|
| 920 |
|
| 921 |
-
|
|
|
|
| 922 |
with col4:
|
| 923 |
-
st.markdown('<h5 style="text-align:center; margin-top: 0;">Rear Tyres: Temperature / Speed
|
| 924 |
|
| 925 |
if not rear_df.empty:
|
|
|
|
| 926 |
rear_df = rear_df[rear_df['Speed (km/h)'] > 0]
|
|
|
|
| 927 |
|
| 928 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 929 |
|
| 930 |
-
valid_data = rear_df.dropna(subset=['Temp_Speed_Ratio'])
|
| 931 |
if not valid_data.empty:
|
| 932 |
-
fig4 = px.
|
| 933 |
valid_data,
|
| 934 |
-
|
| 935 |
-
|
| 936 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 937 |
)
|
| 938 |
|
| 939 |
fig4.update_traces(
|
| 940 |
-
|
| 941 |
-
|
| 942 |
)
|
| 943 |
|
| 944 |
fig4.update_layout(
|
| 945 |
margin=dict(t=40),
|
| 946 |
-
|
| 947 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 948 |
)
|
| 949 |
st.plotly_chart(fig4, use_container_width=True)
|
| 950 |
else:
|
|
|
|
| 804 |
|
| 805 |
|
| 806 |
# =============== COL 2: Front — Temperature / Speed (Boxplot) ===============
|
| 807 |
+
# =============== COL 2: Front — Pressure vs (Temperature / Speed) ===============
|
| 808 |
with col2:
|
| 809 |
+
st.markdown('<h5 style="text-align:center; margin-top: 0;">Front Tyres: Pressure vs (Temperature / Speed)</h5>', unsafe_allow_html=True)
|
| 810 |
|
| 811 |
if not front_df.empty:
|
| 812 |
+
# Filter kecepatan > 0 untuk hindari pembagian dengan nol
|
| 813 |
front_df = front_df[front_df['Speed (km/h)'] > 0]
|
| 814 |
+
front_df['Temp_Speed_Ratio'] = front_df['Temperature (°C)'] / front_df['Speed (km/h)']
|
| 815 |
|
| 816 |
+
# Tambahkan kategori alarm status
|
| 817 |
+
front_df['Category'] = front_df.apply(
|
| 818 |
+
lambda row: f"Normal Front Tyre" if row['Alarm Status'] == 'No Alarm'
|
| 819 |
+
else f"Amber Pressure Front Tyre" if 'Amber' in row['Alarm Status']
|
| 820 |
+
else f"Red Pressure Front Tyre", axis=1
|
| 821 |
+
)
|
| 822 |
+
categories = ["Normal Front Tyre", "Amber Pressure Front Tyre", "Red Pressure Front Tyre"]
|
| 823 |
+
front_df['Category'] = pd.Categorical(front_df['Category'], categories=categories, ordered=True)
|
| 824 |
|
| 825 |
+
valid_data = front_df.dropna(subset=['Temp_Speed_Ratio', 'Pressure (psi)'])
|
| 826 |
if not valid_data.empty:
|
| 827 |
+
fig2 = px.scatter(
|
| 828 |
valid_data,
|
| 829 |
+
x='Temp_Speed_Ratio',
|
| 830 |
+
y='Pressure (psi)',
|
| 831 |
+
color='Category',
|
| 832 |
+
color_discrete_map={
|
| 833 |
+
"Normal Front Tyre": "#2E7D32", # Hijau
|
| 834 |
+
"Amber Pressure Front Tyre": "#FFC107", # Kuning
|
| 835 |
+
"Red Pressure Front Tyre": "#D32F2F" # Merah
|
| 836 |
+
},
|
| 837 |
+
category_orders={'Category': categories},
|
| 838 |
template="plotly_white",
|
| 839 |
+
labels={'Temp_Speed_Ratio': 'Temperature / Speed', 'Pressure (psi)': 'Pressure (psi)'}
|
| 840 |
)
|
| 841 |
|
| 842 |
fig2.update_traces(
|
| 843 |
+
hovertemplate="<b>%{marker.color}</b><br>T/S: %{x:.2f}<br>Pressure: %{y:.1f} psi<extra></extra>",
|
| 844 |
+
marker=dict(size=6)
|
| 845 |
)
|
| 846 |
|
| 847 |
fig2.update_layout(
|
| 848 |
margin=dict(t=40),
|
| 849 |
+
legend=dict(
|
| 850 |
+
title_text='Tyre Status',
|
| 851 |
+
bgcolor="white",
|
| 852 |
+
bordercolor="lightgray",
|
| 853 |
+
borderwidth=1,
|
| 854 |
+
itemclick=False,
|
| 855 |
+
itemdoubleclick=False
|
| 856 |
+
)
|
| 857 |
)
|
| 858 |
st.plotly_chart(fig2, use_container_width=True)
|
| 859 |
else:
|
|
|
|
| 941 |
else:
|
| 942 |
st.warning("No rear tyre data.")
|
| 943 |
|
| 944 |
+
|
| 945 |
+
# =============== COL 4: Rear — Pressure vs (Temperature / Speed) ===============
|
| 946 |
with col4:
|
| 947 |
+
st.markdown('<h5 style="text-align:center; margin-top: 0;">Rear Tyres: Pressure vs (Temperature / Speed)</h5>', unsafe_allow_html=True)
|
| 948 |
|
| 949 |
if not rear_df.empty:
|
| 950 |
+
# Filter kecepatan > 0 untuk hindari pembagian dengan nol
|
| 951 |
rear_df = rear_df[rear_df['Speed (km/h)'] > 0]
|
| 952 |
+
rear_df['Temp_Speed_Ratio'] = rear_df['Temperature (°C)'] / rear_df['Speed (km/h)']
|
| 953 |
|
| 954 |
+
# Tambahkan kategori alarm status
|
| 955 |
+
rear_df['Category'] = rear_df.apply(
|
| 956 |
+
lambda row: f"Normal Rear Tyre" if row['Alarm Status'] == 'No Alarm'
|
| 957 |
+
else f"Amber Pressure Rear Tyre" if 'Amber' in row['Alarm Status']
|
| 958 |
+
else f"Red Pressure Rear Tyre", axis=1
|
| 959 |
+
)
|
| 960 |
+
categories = ["Normal Rear Tyre", "Amber Pressure Rear Tyre", "Red Pressure Rear Tyre"]
|
| 961 |
+
rear_df['Category'] = pd.Categorical(rear_df['Category'], categories=categories, ordered=True)
|
| 962 |
|
| 963 |
+
valid_data = rear_df.dropna(subset=['Temp_Speed_Ratio', 'Pressure (psi)'])
|
| 964 |
if not valid_data.empty:
|
| 965 |
+
fig4 = px.scatter(
|
| 966 |
valid_data,
|
| 967 |
+
x='Temp_Speed_Ratio',
|
| 968 |
+
y='Pressure (psi)',
|
| 969 |
+
color='Category',
|
| 970 |
+
color_discrete_map={
|
| 971 |
+
"Normal Rear Tyre": "#2E7D32",
|
| 972 |
+
"Amber Pressure Rear Tyre": "#FFC107",
|
| 973 |
+
"Red Pressure Rear Tyre": "#D32F2F"
|
| 974 |
+
},
|
| 975 |
+
category_orders={'Category': categories},
|
| 976 |
+
template="plotly_white"
|
| 977 |
)
|
| 978 |
|
| 979 |
fig4.update_traces(
|
| 980 |
+
hovertemplate="<b>%{marker.color}</b><br>T/S: %{x:.2f}<br>Pressure: %{y:.1f} psi<extra></extra>",
|
| 981 |
+
marker=dict(size=6)
|
| 982 |
)
|
| 983 |
|
| 984 |
fig4.update_layout(
|
| 985 |
margin=dict(t=40),
|
| 986 |
+
legend=dict(
|
| 987 |
+
title_text='Tyre Status',
|
| 988 |
+
bgcolor="white",
|
| 989 |
+
bordercolor="lightgray",
|
| 990 |
+
borderwidth=1,
|
| 991 |
+
itemclick=False,
|
| 992 |
+
itemdoubleclick=False
|
| 993 |
+
)
|
| 994 |
)
|
| 995 |
st.plotly_chart(fig4, use_container_width=True)
|
| 996 |
else:
|