Update app.py
Browse files
app.py
CHANGED
|
@@ -14,19 +14,25 @@ def get_speed():
|
|
| 14 |
|
| 15 |
return download_speed, upload_speed
|
| 16 |
|
| 17 |
-
# Function to visualize the speed in a circular gauge
|
| 18 |
def plot_speedometer(speed, speed_type):
|
| 19 |
fig = go.Figure(go.Indicator(
|
| 20 |
mode="gauge+number",
|
| 21 |
value=speed,
|
| 22 |
title={'text': f"{speed_type} Speed (Mbps)"},
|
| 23 |
-
gauge={
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
}
|
| 31 |
))
|
| 32 |
fig.update_layout(height=300)
|
|
@@ -45,7 +51,7 @@ def main():
|
|
| 45 |
st.subheader(f"Download Speed: {download_speed:.2f} Mbps")
|
| 46 |
st.subheader(f"Upload Speed: {upload_speed:.2f} Mbps")
|
| 47 |
|
| 48 |
-
# Visualize the speeds with circular speedometers
|
| 49 |
plot_speedometer(download_speed, "Download")
|
| 50 |
plot_speedometer(upload_speed, "Upload")
|
| 51 |
|
|
|
|
| 14 |
|
| 15 |
return download_speed, upload_speed
|
| 16 |
|
| 17 |
+
# Function to visualize the speed in a circular gauge with a pointer
|
| 18 |
def plot_speedometer(speed, speed_type):
|
| 19 |
fig = go.Figure(go.Indicator(
|
| 20 |
mode="gauge+number",
|
| 21 |
value=speed,
|
| 22 |
title={'text': f"{speed_type} Speed (Mbps)"},
|
| 23 |
+
gauge={
|
| 24 |
+
'axis': {'range': [None, 100]}, # Range of 0 to 100 Mbps
|
| 25 |
+
'bar': {'color': "lightblue"},
|
| 26 |
+
'steps': [
|
| 27 |
+
{'range': [0, 20], 'color': "red"},
|
| 28 |
+
{'range': [20, 50], 'color': "yellow"},
|
| 29 |
+
{'range': [50, 100], 'color': "green"}
|
| 30 |
+
],
|
| 31 |
+
'threshold': {
|
| 32 |
+
'line': {'color': "black", 'width': 4}, # Pointer color and width
|
| 33 |
+
'thickness': 0.75, # Pointer thickness
|
| 34 |
+
'value': speed # Set the pointer to the current speed value
|
| 35 |
+
}
|
| 36 |
}
|
| 37 |
))
|
| 38 |
fig.update_layout(height=300)
|
|
|
|
| 51 |
st.subheader(f"Download Speed: {download_speed:.2f} Mbps")
|
| 52 |
st.subheader(f"Upload Speed: {upload_speed:.2f} Mbps")
|
| 53 |
|
| 54 |
+
# Visualize the speeds with circular speedometers including pointers
|
| 55 |
plot_speedometer(download_speed, "Download")
|
| 56 |
plot_speedometer(upload_speed, "Upload")
|
| 57 |
|