SG-2025 commited on
Commit
33c20cc
·
verified ·
1 Parent(s): 57dbb8a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -11
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
- # Pie chart for income breakdown
150
- labels = ['Expense', 'Savings', 'Unallocated Income']
151
- sizes = [total_expense, allocated_savings, cash_in_hand]
152
- sizes = [0 if np.isnan(value) else value for value in sizes]
153
- colors = ['#ff9999','#66b3ff','#99ff99']
154
-
155
- fig, ax = plt.subplots()
156
- ax.pie(sizes, labels=labels, autopct='%1.1f%%', startangle=90, colors=colors)
157
- ax.axis('equal') # Equal aspect ratio ensures that pie chart is drawn as a circle.
158
- st.pyplot(fig)
 
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():