Update app.py
Browse files
app.py
CHANGED
@@ -211,7 +211,32 @@ if ticker_user!="":
|
|
211 |
with col1:
|
212 |
st.subheader("📝 Summary")
|
213 |
# st.write(analysis_summary.summary)
|
214 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
215 |
# Extract counts only
|
216 |
counts = {k: v for k, v in summary_dict.items() if k != "RECOMMENDATION"}
|
217 |
max_value = max(counts.values())
|
|
|
211 |
with col1:
|
212 |
st.subheader("📝 Summary")
|
213 |
# st.write(analysis_summary.summary)
|
214 |
+
summary= analysis_summary.summary
|
215 |
+
# Prepare data for stacked bar chart: each category with its count
|
216 |
+
data = pd.DataFrame({
|
217 |
+
'category': ['BUY', 'SELL', 'NEUTRAL'],
|
218 |
+
'count': [summary['BUY'], summary['SELL'], summary['NEUTRAL']]
|
219 |
+
})
|
220 |
+
|
221 |
+
# Add a constant key to create a single stacked bar
|
222 |
+
data['key'] = 'Recommendations'
|
223 |
+
chart = alt.Chart(data).mark_bar().encode(
|
224 |
+
y=alt.Y('key:N', axis=None), # single bar, no y axis
|
225 |
+
x=alt.X('count:Q'),
|
226 |
+
color=alt.Color('category:N', scale=alt.Scale(
|
227 |
+
domain=['BUY', 'SELL', 'NEUTRAL'],
|
228 |
+
range=['green', 'red', 'gold']
|
229 |
+
)),
|
230 |
+
tooltip=['category', 'count']
|
231 |
+
).properties(
|
232 |
+
width=600,
|
233 |
+
height=50
|
234 |
+
)
|
235 |
+
|
236 |
+
st.altair_chart(chart, use_container_width=True)
|
237 |
+
|
238 |
+
|
239 |
+
|
240 |
# Extract counts only
|
241 |
counts = {k: v for k, v in summary_dict.items() if k != "RECOMMENDATION"}
|
242 |
max_value = max(counts.values())
|