Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
|
| 3 |
# Constants
|
| 4 |
VOLTAGE_LEVELS = [220, 380, 440]
|
|
@@ -61,7 +62,21 @@ with col3:
|
|
| 61 |
|
| 62 |
with col4:
|
| 63 |
st.subheader("Load Distribution (kVA)")
|
| 64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
# Footer
|
| 67 |
st.sidebar.markdown("---")
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
import matplotlib.pyplot as plt
|
| 3 |
|
| 4 |
# Constants
|
| 5 |
VOLTAGE_LEVELS = [220, 380, 440]
|
|
|
|
| 62 |
|
| 63 |
with col4:
|
| 64 |
st.subheader("Load Distribution (kVA)")
|
| 65 |
+
if transformer_size:
|
| 66 |
+
# Pie chart with Matplotlib
|
| 67 |
+
labels = ["Used Load", "Remaining Capacity"]
|
| 68 |
+
sizes = [total_load_kva, max(transformer_size - total_load_kva, 0)]
|
| 69 |
+
colors = ["#FF9999", "#66B3FF"]
|
| 70 |
+
explode = (0.1, 0) # Highlight the "Used Load" slice
|
| 71 |
+
|
| 72 |
+
fig, ax = plt.subplots()
|
| 73 |
+
ax.pie(
|
| 74 |
+
sizes, explode=explode, labels=labels, colors=colors, autopct="%1.1f%%", startangle=140
|
| 75 |
+
)
|
| 76 |
+
ax.axis("equal") # Equal aspect ratio ensures the pie chart is circular.
|
| 77 |
+
st.pyplot(fig)
|
| 78 |
+
else:
|
| 79 |
+
st.warning("No transformer selected. Unable to display load distribution.")
|
| 80 |
|
| 81 |
# Footer
|
| 82 |
st.sidebar.markdown("---")
|