MLDeveloper commited on
Commit
233f1db
·
verified ·
1 Parent(s): eaee169

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -11
app.py CHANGED
@@ -113,6 +113,7 @@ if submitted and location:
113
  system_size_kw = None
114
  monthly_savings_rs = None
115
  total_system_cost = None
 
116
 
117
  for point in estimated_data:
118
  if ":" in point:
@@ -129,26 +130,52 @@ if submitted and location:
129
  monthly_savings_rs = float(value.split()[0])
130
  if "Total system cost" in key:
131
  total_system_cost = float(value.split()[0])
 
 
132
 
133
  except ValueError:
134
  st.warning("There was an issue processing the response. Please try again.")
135
 
136
  # Show Graph if values are available
137
- if total_system_cost is not None and monthly_savings_rs is not None:
138
  st.subheader("📊 Visual Summary")
139
-
140
- fig = go.Figure(data=[
141
- go.Bar(
142
- x=["Total System Cost (₹)", "Monthly Savings (₹)"],
143
- y=[total_system_cost, monthly_savings_rs],
144
- marker_color=['#636EFA', '#00CC96']
145
- )
146
- ])
147
- fig.update_layout(title="Solar Project Financial Estimates", yaxis_title="Amount (₹)", xaxis_title="Parameters")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  st.plotly_chart(fig, use_container_width=True, key="solar_graph")
149
 
150
  else:
151
  st.error("Sorry, the location entered does not match any available data.")
152
  else:
153
  st.info("Please fill out all fields to get your solar project estimate.")
154
-
 
113
  system_size_kw = None
114
  monthly_savings_rs = None
115
  total_system_cost = None
116
+ payback_period_years = None
117
 
118
  for point in estimated_data:
119
  if ":" in point:
 
130
  monthly_savings_rs = float(value.split()[0])
131
  if "Total system cost" in key:
132
  total_system_cost = float(value.split()[0])
133
+ if "Payback period" in key:
134
+ payback_period_years = float(value.split()[0])
135
 
136
  except ValueError:
137
  st.warning("There was an issue processing the response. Please try again.")
138
 
139
  # Show Graph if values are available
140
+ if total_system_cost is not None and monthly_savings_rs is not None and payback_period_years is not None:
141
  st.subheader("📊 Visual Summary")
142
+
143
+ # Prepare data for Area Chart
144
+ months = int(payback_period_years * 12)
145
+ savings_cumulative = [monthly_savings_rs * month for month in range(1, months + 1)]
146
+
147
+ fig = go.Figure()
148
+
149
+ # Area plot
150
+ fig.add_trace(go.Scatter(
151
+ x=list(range(1, months + 1)),
152
+ y=savings_cumulative,
153
+ mode='lines',
154
+ fill='tozeroy',
155
+ name='Cumulative Savings (₹)',
156
+ line=dict(color='#00CC96')
157
+ ))
158
+
159
+ # Line for Total Cost
160
+ fig.add_trace(go.Scatter(
161
+ x=[1, months],
162
+ y=[total_system_cost, total_system_cost],
163
+ mode='lines',
164
+ name='Total System Cost (₹)',
165
+ line=dict(color='red', dash='dash')
166
+ ))
167
+
168
+ fig.update_layout(
169
+ title="Cumulative Savings vs Total System Cost Over Time",
170
+ xaxis_title="Months",
171
+ yaxis_title="Amount (₹)",
172
+ legend_title="Legend",
173
+ template="plotly_white"
174
+ )
175
+
176
  st.plotly_chart(fig, use_container_width=True, key="solar_graph")
177
 
178
  else:
179
  st.error("Sorry, the location entered does not match any available data.")
180
  else:
181
  st.info("Please fill out all fields to get your solar project estimate.")