lcjln commited on
Commit
56fb153
Β·
verified Β·
1 Parent(s): 44acdb2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -10
app.py CHANGED
@@ -115,12 +115,10 @@ def crawl_chats(vod_url):
115
 
116
  return "\n".join(chat_logs), chat_counts, laugh_counts
117
 
118
- # ν΄λ¦­ν•œ μ‹œκ°„λŒ€λ₯Ό 선택 및 좜λ ₯
119
- def handle_time_selection(click_data):
120
- if click_data:
121
- selected_time = click_data['points'][0]['x']
122
- if selected_time not in st.session_state['selected_times']:
123
- st.session_state['selected_times'].append(selected_time)
124
 
125
  # μ„ νƒλœ μ‹œκ°„λŒ€λ₯Ό ν‘œμ‹œ 및 μ‚­μ œ κΈ°λŠ₯
126
  def display_selected_times():
@@ -198,7 +196,7 @@ if st.session_state['chat_logs']:
198
  # Plotly μ„  κ·Έλž˜ν”„ 그리기
199
  fig = go.Figure()
200
 
201
- # 전체 μ±„νŒ… κ°œμˆ˜μ™€ γ…‹γ…‹γ…‹γ…‹ μ±„νŒ… 개수λ₯Ό ν•œ κ·Έλž˜ν”„μ— μΆ”κ°€
202
  fig.add_trace(go.Scatter(
203
  x=df['μ‹œκ°„'],
204
  y=df['전체 μ±„νŒ… 개수'],
@@ -208,6 +206,7 @@ if st.session_state['chat_logs']:
208
  hovertemplate='%{x} - 전체 μ±„νŒ… 개수: %{y}<extra></extra>'
209
  ))
210
 
 
211
  fig.add_trace(go.Scatter(
212
  x=df['μ‹œκ°„'],
213
  y=df['γ…‹γ…‹γ…‹γ…‹ μ±„νŒ… 개수'],
@@ -228,9 +227,12 @@ if st.session_state['chat_logs']:
228
  margin=dict(l=50, r=50, t=100, b=100)
229
  )
230
 
231
- # κ·Έλž˜ν”„ 좜λ ₯ 및 클릭 이벀트 처리
232
- click_data = st.plotly_chart(fig, use_container_width=True).get_current_click()
233
- handle_time_selection(click_data)
 
 
 
234
 
235
  # μ„ νƒλœ μ‹œκ°„λŒ€ ν‘œμ‹œ
236
  display_selected_times()
 
115
 
116
  return "\n".join(chat_logs), chat_counts, laugh_counts
117
 
118
+ # μ„ νƒν•œ μ‹œκ°„λŒ€λ₯Ό μΆ”κ°€
119
+ def add_selected_time(time):
120
+ if time not in st.session_state['selected_times']:
121
+ st.session_state['selected_times'].append(time)
 
 
122
 
123
  # μ„ νƒλœ μ‹œκ°„λŒ€λ₯Ό ν‘œμ‹œ 및 μ‚­μ œ κΈ°λŠ₯
124
  def display_selected_times():
 
196
  # Plotly μ„  κ·Έλž˜ν”„ 그리기
197
  fig = go.Figure()
198
 
199
+ # 전체 μ±„νŒ… 개수 μ„  κ·Έλž˜ν”„ μΆ”κ°€
200
  fig.add_trace(go.Scatter(
201
  x=df['μ‹œκ°„'],
202
  y=df['전체 μ±„νŒ… 개수'],
 
206
  hovertemplate='%{x} - 전체 μ±„νŒ… 개수: %{y}<extra></extra>'
207
  ))
208
 
209
+ # γ…‹γ…‹γ…‹γ…‹ μ±„νŒ… 개수 μ„  κ·Έλž˜ν”„ μΆ”κ°€
210
  fig.add_trace(go.Scatter(
211
  x=df['μ‹œκ°„'],
212
  y=df['γ…‹γ…‹γ…‹γ…‹ μ±„νŒ… 개수'],
 
227
  margin=dict(l=50, r=50, t=100, b=100)
228
  )
229
 
230
+ # κ·Έλž˜ν”„ 좜λ ₯
231
+ click_data = st.plotly_chart(fig, use_container_width=True)
232
+
233
+ # ν΄λ¦­ν•œ μ‹œκ°„λŒ€κ°€ 있으면 처리
234
+ if click_data:
235
+ add_selected_time(click_data['points'][0]['x'])
236
 
237
  # μ„ νƒλœ μ‹œκ°„λŒ€ ν‘œμ‹œ
238
  display_selected_times()