duongthienz commited on
Commit
f9d6ba7
Β·
verified Β·
1 Parent(s): 100fd21

Fix an issue where selecting sort list causing an auto scroll downward

Browse files
Files changed (1) hide show
  1. ui.py +40 -43
ui.py CHANGED
@@ -411,24 +411,25 @@ def render_multifile_summary(plotly_config=None):
411
  "are only counted once."
412
  )
413
 
414
- sort_options = {
415
- "Single Voice (least β†’ most)": (["Single Voice", "Multi Voice"], True),
416
- "Multi Voice (least β†’ most)": (["Multi Voice", "Single Voice"], True),
417
- "No Voice (most β†’ least)": (["No Voice", "Multi Voice"], False),
418
- }
419
- selected_sort = st.selectbox(
420
- "Sort cross-file voice categories by:",
421
- options=list(sort_options.keys()),
422
- key="multifile_voice_sort",
423
- )
424
- sort_cols, ascending = sort_options[selected_sort]
425
- fig7 = px.bar(
426
- df7.sort_values(by=sort_cols, ascending=ascending),
427
- x="files", y=["Single Voice", "Multi Voice", "No Voice"],
428
- title=f"Cross-file Voice Categories sorted by {selected_sort}",
429
- )
430
- fig7.update_layout(yaxis_title="Proportion of File Duration")
431
- st.plotly_chart(fig7, use_container_width=True, config=cfg)
 
432
 
433
  st.divider()
434
 
@@ -438,28 +439,24 @@ def render_multifile_summary(plotly_config=None):
438
  st.session_state.categories, st.session_state.categorySelect,
439
  speakerRenames=st.session_state.speakerRenames,
440
  )
441
- # Build sort options dynamically from available columns
442
- role_sort_options = {}
443
- for col in role_voice_cols:
444
- if col in ("Multi Voice", "No Voice"):
445
- role_sort_options[f"{col} (most β†’ least)"] = ([col], False)
446
- else:
447
- role_sort_options[f"{col} (least β†’ most)"] = ([col], True)
448
-
449
- selected_role_sort = st.selectbox(
450
- "Sort cross-file role/voice breakdown by:",
451
- options=list(role_sort_options.keys()),
452
- key="multifile_role_voice_sort",
453
- )
454
- sort_cols8, ascending8 = role_sort_options[selected_role_sort]
455
- fig8 = px.bar(
456
- df8.sort_values(by=sort_cols8, ascending=ascending8),
457
- x="files", y=role_voice_cols,
458
- title=f"Cross-file Role & Voice Breakdown sorted by {selected_role_sort}",
459
- )
460
- fig8.update_layout(yaxis_title="Proportion of File Duration")
461
- st.plotly_chart(fig8, use_container_width=True, config=cfg)
462
- st.caption(
463
- "*Note: Role proportions use union of speaker segments (overlaps counted once). "
464
- "Multi Voice and No Voice are proportions of total file duration."
465
- )
 
411
  "are only counted once."
412
  )
413
 
414
+ with st.container():
415
+ sort_options = {
416
+ "Single Voice (least β†’ most)": (["Single Voice", "Multi Voice"], True),
417
+ "Multi Voice (least β†’ most)": (["Multi Voice", "Single Voice"], True),
418
+ "No Voice (most β†’ least)": (["No Voice", "Multi Voice"], False),
419
+ }
420
+ selected_sort = st.selectbox(
421
+ "Sort cross-file voice categories by:",
422
+ options=list(sort_options.keys()),
423
+ key="multifile_voice_sort",
424
+ )
425
+ sort_cols, ascending = sort_options[selected_sort]
426
+ fig7 = px.bar(
427
+ df7.sort_values(by=sort_cols, ascending=ascending),
428
+ x="files", y=["Single Voice", "Multi Voice", "No Voice"],
429
+ title=f"Cross-file Voice Categories sorted by {selected_sort}",
430
+ )
431
+ fig7.update_layout(yaxis_title="Proportion of File Duration")
432
+ st.plotly_chart(fig7, use_container_width=True, config=cfg)
433
 
434
  st.divider()
435
 
 
439
  st.session_state.categories, st.session_state.categorySelect,
440
  speakerRenames=st.session_state.speakerRenames,
441
  )
442
+ with st.container():
443
+ role_sort_options = {}
444
+ for col in role_voice_cols:
445
+ if col in ("Multi Voice", "No Voice"):
446
+ role_sort_options[f"{col} (most β†’ least)"] = ([col], False)
447
+ else:
448
+ role_sort_options[f"{col} (least β†’ most)"] = ([col], True)
449
+
450
+ selected_role_sort = st.selectbox(
451
+ "Sort cross-file role/voice breakdown by:",
452
+ options=list(role_sort_options.keys()),
453
+ key="multifile_role_voice_sort",
454
+ )
455
+ sort_cols8, ascending8 = role_sort_options[selected_role_sort]
456
+ fig8 = px.bar(
457
+ df8.sort_values(by=sort_cols8, ascending=ascending8),
458
+ x="files", y=role_voice_cols,
459
+ title=f"Cross-file Role & Voice Breakdown sorted by {selected_role_sort}",
460
+ )
461
+ fig8.update_layout(yaxis_title="Proportion of File Duration")
462
+ st.plotly_chart(fig8, use_container_width=True, config=cfg)