DivYonko commited on
Commit
ec9211d
·
1 Parent(s): 5ada189

Change sentiment heatmap from stacked bar to multi-line chart

Browse files
Files changed (2) hide show
  1. frontend/streamlit_app.py +4 -4
  2. pages/stats.py +6 -4
frontend/streamlit_app.py CHANGED
@@ -1453,17 +1453,17 @@ if not heatmap_data.empty:
1453
 
1454
  fig_heat = go.Figure()
1455
  for sent, color in [("Positive", "#22c55e"), ("Neutral", "#eab308"), ("Negative", "#ef4444")]:
1456
- fig_heat.add_trace(go.Bar(
1457
  x=heatmap_data["bucket"],
1458
  y=heatmap_data[sent],
1459
  name=sent,
1460
- marker_color=color,
1461
- opacity=0.85,
 
1462
  hovertemplate=f"<b>{sent}</b><br>%{{x}}<br>Count: %{{y}}<extra></extra>",
1463
  ))
1464
 
1465
  layout = plotly_layout(220)
1466
- layout["barmode"] = "stack"
1467
  layout["showlegend"] = True
1468
  layout["legend"] = dict(orientation="h", y=1.08, font=dict(size=11))
1469
  layout["xaxis"]["tickformat"] = "%H:%M"
 
1453
 
1454
  fig_heat = go.Figure()
1455
  for sent, color in [("Positive", "#22c55e"), ("Neutral", "#eab308"), ("Negative", "#ef4444")]:
1456
+ fig_heat.add_trace(go.Scatter(
1457
  x=heatmap_data["bucket"],
1458
  y=heatmap_data[sent],
1459
  name=sent,
1460
+ mode="lines+markers",
1461
+ line=dict(color=color, width=2),
1462
+ marker=dict(size=4),
1463
  hovertemplate=f"<b>{sent}</b><br>%{{x}}<br>Count: %{{y}}<extra></extra>",
1464
  ))
1465
 
1466
  layout = plotly_layout(220)
 
1467
  layout["showlegend"] = True
1468
  layout["legend"] = dict(orientation="h", y=1.08, font=dict(size=11))
1469
  layout["xaxis"]["tickformat"] = "%H:%M"
pages/stats.py CHANGED
@@ -340,17 +340,19 @@ if not heatmap_data.empty:
340
 
341
  fig_heat = go.Figure()
342
  for sent, color in [("Positive", "#22c55e"), ("Neutral", "#eab308"), ("Negative", "#ef4444")]:
343
- fig_heat.add_trace(go.Bar(
344
  x=heatmap_data["bucket"],
345
  y=heatmap_data[sent],
346
  name=sent,
347
- marker_color=color,
348
- opacity=0.85,
 
 
 
349
  hovertemplate=f"<b>{sent}</b><br>%{{x}}<br>Count: %{{y}}<extra></extra>",
350
  ))
351
 
352
  layout = plotly_layout(220)
353
- layout["barmode"] = "stack"
354
  layout["showlegend"] = True
355
  layout["legend"] = dict(orientation="h", y=1.08, font=dict(size=11))
356
  layout["xaxis"]["tickformat"] = "%H:%M"
 
340
 
341
  fig_heat = go.Figure()
342
  for sent, color in [("Positive", "#22c55e"), ("Neutral", "#eab308"), ("Negative", "#ef4444")]:
343
+ fig_heat.add_trace(go.Scatter(
344
  x=heatmap_data["bucket"],
345
  y=heatmap_data[sent],
346
  name=sent,
347
+ mode="lines+markers",
348
+ line=dict(color=color, width=2),
349
+ marker=dict(size=4),
350
+ fill="tozeroy" if sent == "Negative" else None,
351
+ fillcolor=color.replace(")", ",0.08)").replace("rgb", "rgba") if sent == "Negative" else None,
352
  hovertemplate=f"<b>{sent}</b><br>%{{x}}<br>Count: %{{y}}<extra></extra>",
353
  ))
354
 
355
  layout = plotly_layout(220)
 
356
  layout["showlegend"] = True
357
  layout["legend"] = dict(orientation="h", y=1.08, font=dict(size=11))
358
  layout["xaxis"]["tickformat"] = "%H:%M"