duongthienz commited on
Commit
394825c
·
verified ·
1 Parent(s): 4948296

Update utils.py

Browse files
Files changed (1) hide show
  1. utils.py +12 -24
utils.py CHANGED
@@ -538,31 +538,19 @@ def build_fig_timeline(speakers_dataFrame, currTotalTime, speaker_color_map, get
538
  )
539
  fig.update_yaxes(autorange="reversed")
540
 
541
- # Add vertical shading for multi-voice intervals as filled scatter shapes.
542
- # go.Scatter with fill="toself" supports hover; add_vrect does not.
543
- MV_COLOR = "#64A377"
544
- # We need the y-axis range — use a large span that covers all speaker rows
545
- y_speakers = df["Resource"].unique().tolist()
546
- y_min, y_max = -0.5, len(y_speakers) - 0.5
547
  for start_s, end_s in (mv_intervals or []):
548
- x0_dt = base + dt.timedelta(seconds=start_s)
549
- x1_dt = base + dt.timedelta(seconds=end_s)
550
- fig.add_trace(go.Scatter(
551
- x=[x0_dt, x1_dt, x1_dt, x0_dt, x0_dt],
552
- y=[y_min, y_min, y_max, y_max, y_min],
553
- fill="toself",
554
- fillcolor=f"rgba(100,163,119,0.25)",
555
- line=dict(width=0),
556
- mode="lines",
557
- showlegend=False,
558
- yaxis="y",
559
- hovertemplate=(
560
- f"<b>Multi Voice</b><br>"
561
- f"Start: {_seconds_to_hhmmss(start_s)}<br>"
562
- f"Finish: {_seconds_to_hhmmss(end_s)}"
563
- "<extra></extra>"
564
- ),
565
- ))
566
 
567
  h = int(currTotalTime // 3600)
568
  m = int(currTotalTime % 3600 // 60)
 
538
  )
539
  fig.update_yaxes(autorange="reversed")
540
 
541
+ # Add vertical shading for multi-voice intervals.
542
+ # Note: add_vrect does not support hover tooltips in Plotly — this is a
543
+ # known Plotly limitation. Hover on these bands cannot be added without
544
+ # introducing extra traces that corrupt the y-axis.
 
 
545
  for start_s, end_s in (mv_intervals or []):
546
+ fig.add_vrect(
547
+ x0=base + dt.timedelta(seconds=start_s),
548
+ x1=base + dt.timedelta(seconds=end_s),
549
+ fillcolor="#64A377",
550
+ opacity=0.25,
551
+ layer="below",
552
+ line_width=0,
553
+ )
 
 
 
 
 
 
 
 
 
 
554
 
555
  h = int(currTotalTime // 3600)
556
  m = int(currTotalTime % 3600 // 60)