Update app.py
Browse files
app.py
CHANGED
|
@@ -145,17 +145,18 @@ def main_app():
|
|
| 145 |
|
| 146 |
# Display label for the nearest goal
|
| 147 |
st.write(f"Amount needed to reach goal '{closest_goal_name}': {closest_goal_amount:,} (Deadline: {closest_goal_deadline})")
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
|
|
|
| 159 |
|
| 160 |
# Progress bar for each goal
|
| 161 |
for idx, goal in st.session_state["saving_goals"].iterrows():
|
|
|
|
| 145 |
|
| 146 |
# Display label for the nearest goal
|
| 147 |
st.write(f"Amount needed to reach goal '{closest_goal_name}': {closest_goal_amount:,} (Deadline: {closest_goal_deadline})")
|
| 148 |
+
|
| 149 |
+
if total_income > 0 and total_expense > 0:
|
| 150 |
+
# Pie chart for income breakdown
|
| 151 |
+
labels = ['Expense', 'Savings', 'Unallocated Income']
|
| 152 |
+
sizes = [total_expense, allocated_savings, cash_in_hand]
|
| 153 |
+
sizes = [0 if np.isnan(value) else value for value in sizes]
|
| 154 |
+
colors = ['#ff9999','#66b3ff','#99ff99']
|
| 155 |
+
|
| 156 |
+
fig, ax = plt.subplots()
|
| 157 |
+
ax.pie(sizes, labels=labels, autopct='%1.1f%%', startangle=90, colors=colors)
|
| 158 |
+
ax.axis('equal') # Equal aspect ratio ensures that pie chart is drawn as a circle.
|
| 159 |
+
st.pyplot(fig)
|
| 160 |
|
| 161 |
# Progress bar for each goal
|
| 162 |
for idx, goal in st.session_state["saving_goals"].iterrows():
|