MarcosRodrigo commited on
Commit
a81a1a2
·
verified ·
1 Parent(s): 1ae5382

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -58
app.py CHANGED
@@ -236,63 +236,6 @@ elif menu == "History":
236
  else:
237
  st.write("No history records found.")
238
 
239
- # # Graph view to display a line chart of item selections over time
240
- # elif menu == "Graph":
241
- # st.title("Breakfast Poll History - Graph View")
242
-
243
- # # Load the history if not already loaded
244
- # if not st.session_state.history:
245
- # st.session_state.history = load_history()
246
-
247
- # # Prepare data for plotting
248
- # if st.session_state.history:
249
- # history_data = []
250
- # for record in st.session_state.history:
251
- # # Extract only the date part (YYYY-MM-DD) for display
252
- # date = record['Date'].split("_")[0] # Use only the YYYY-MM-DD portion of the date
253
- # for index, row in record['Summary'].iterrows():
254
- # for drink in row['Drinks'].split(', '):
255
- # history_data.append({'Date': date, 'Item': drink, 'Type': 'Drink'})
256
- # for food in row['Food'].split(', '):
257
- # history_data.append({'Date': date, 'Item': food, 'Type': 'Food'})
258
-
259
- # # Create a DataFrame from history data
260
- # history_df = pd.DataFrame(history_data)
261
-
262
- # # Count occurrences of each item per date
263
- # item_counts = history_df.groupby(['Date', 'Item']).size().reset_index(name='Count')
264
-
265
- # # Get a list of unique items (Drinks and Food)
266
- # unique_items = item_counts['Item'].unique()
267
-
268
- # # Create a dictionary to store the checkbox values for each item
269
- # item_visibility = {}
270
-
271
- # st.sidebar.header("Select Items to Display")
272
- # # Create a checkbox for each unique item in the sidebar
273
- # for item in unique_items:
274
- # item_visibility[item] = st.sidebar.checkbox(item, value=True)
275
-
276
- # # Filter the data based on selected items
277
- # selected_items = [item for item, visible in item_visibility.items() if visible]
278
- # filtered_item_counts = item_counts[item_counts['Item'].isin(selected_items)]
279
-
280
- # # Create a line plot for each selected item over time
281
- # plt.figure(figsize=(12, 6))
282
- # sns.lineplot(data=filtered_item_counts, x='Date', y='Count', hue='Item', marker='o')
283
-
284
- # # Customize the plot
285
- # plt.xticks(rotation=45)
286
- # plt.title('Item Selections Over Time')
287
- # plt.xlabel('Date')
288
- # plt.ylabel('Number of Selections')
289
- # plt.legend(loc='upper center', bbox_to_anchor=(0.5, -0.15), ncol=3)
290
-
291
- # # Display the plot
292
- # st.pyplot(plt.gcf())
293
- # else:
294
- # st.write("No historical data available to plot.")
295
-
296
  # Graph view to display a line chart of item selections over time
297
  elif menu == "Graph":
298
  st.title("Breakfast Poll History - Graph View")
@@ -306,7 +249,7 @@ elif menu == "Graph":
306
  history_data = []
307
  for record in st.session_state.history:
308
  # Extract only the date part (YYYY-MM-DD) for display
309
- date = record['Date'].split("_")[0] # Use only the YYYY-MM-DD portion of the date
310
  for index, row in record['Summary'].iterrows():
311
  for drink in row['Drinks'].split(', '):
312
  history_data.append({'Date': date, 'Item': drink, 'Type': 'Drink'})
 
236
  else:
237
  st.write("No history records found.")
238
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
239
  # Graph view to display a line chart of item selections over time
240
  elif menu == "Graph":
241
  st.title("Breakfast Poll History - Graph View")
 
249
  history_data = []
250
  for record in st.session_state.history:
251
  # Extract only the date part (YYYY-MM-DD) for display
252
+ date = record['Date']
253
  for index, row in record['Summary'].iterrows():
254
  for drink in row['Drinks'].split(', '):
255
  history_data.append({'Date': date, 'Item': drink, 'Type': 'Drink'})