Syntrex commited on
Commit
466052d
·
verified ·
1 Parent(s): 7725cc4

Update visualization/edge_strip.py

Browse files
Files changed (1) hide show
  1. visualization/edge_strip.py +21 -2
visualization/edge_strip.py CHANGED
@@ -16,10 +16,29 @@ def _fmt_odds(value: Any) -> str:
16
 
17
 
18
  def _fmt_edge(value: Any) -> str:
 
 
 
19
  try:
20
- return f"{float(value):+.1%}"
21
  except Exception:
22
- return "—"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
 
25
  def render_live_edge_strip(edge: dict[str, Any]) -> None:
 
16
 
17
 
18
  def _fmt_edge(value: Any) -> str:
19
+ if value is None:
20
+ return ""
21
+
22
  try:
23
+ edge = float(value)
24
  except Exception:
25
+ return str(value)
26
+
27
+ pct = edge * 100
28
+
29
+ # Color gradient
30
+ if pct >= 5:
31
+ color = "#22c55e" # strong green
32
+ elif pct >= 2:
33
+ color = "#84cc16" # light green
34
+ elif pct >= 0:
35
+ color = "#eab308" # yellow
36
+ elif pct >= -3:
37
+ color = "#f97316" # orange
38
+ else:
39
+ color = "#ef4444" # red
40
+
41
+ return f'<span style="color:{color};font-weight:800;">{pct:.1f}%</span>'
42
 
43
 
44
  def render_live_edge_strip(edge: dict[str, Any]) -> None: