Spaces:
Running
Running
openhands
openhands
commited on
Commit
·
88a8840
1
Parent(s):
1f75b60
Fix icon positioning for date-based charts
Browse filesUse data coordinates (xref='x', yref='y') for date axes instead of
domain coordinates. This matches the previous behavior where icons
were positioned using actual x/y values.
- Date charts: use data coordinates with sizex in milliseconds
- Log charts: continue using domain coordinates (0-1 range)
Co-authored-by: openhands <openhands@all-hands.dev>
- leaderboard_transformer.py +39 -27
leaderboard_transformer.py
CHANGED
|
@@ -458,34 +458,46 @@ def create_scatter_chart(
|
|
| 458 |
encoded_logo = base64.b64encode(f.read()).decode('utf-8')
|
| 459 |
logo_uri = f"data:image/svg+xml;base64,{encoded_logo}"
|
| 460 |
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 468 |
else:
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
|
| 473 |
-
|
| 474 |
-
|
| 475 |
-
|
| 476 |
-
|
| 477 |
-
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
|
| 484 |
-
|
| 485 |
-
|
| 486 |
-
|
| 487 |
-
|
| 488 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 489 |
except Exception:
|
| 490 |
pass
|
| 491 |
|
|
|
|
| 458 |
encoded_logo = base64.b64encode(f.read()).decode('utf-8')
|
| 459 |
logo_uri = f"data:image/svg+xml;base64,{encoded_logo}"
|
| 460 |
|
| 461 |
+
if x_type == "date":
|
| 462 |
+
# For date axes, use data coordinates directly
|
| 463 |
+
layout_images.append(dict(
|
| 464 |
+
source=logo_uri,
|
| 465 |
+
xref="x",
|
| 466 |
+
yref="y",
|
| 467 |
+
x=x_val,
|
| 468 |
+
y=y_val,
|
| 469 |
+
sizex=15 * 24 * 60 * 60 * 1000, # ~15 days in milliseconds
|
| 470 |
+
sizey=3, # score units
|
| 471 |
+
xanchor="center",
|
| 472 |
+
yanchor="middle",
|
| 473 |
+
layer="above"
|
| 474 |
+
))
|
| 475 |
else:
|
| 476 |
+
# For log axes, use domain coordinates (0-1 range)
|
| 477 |
+
if x_type == "log" and x_val > 0:
|
| 478 |
+
log_x = np.log10(x_val)
|
| 479 |
+
domain_x = (log_x - x_range_log[0]) / (x_range_log[1] - x_range_log[0])
|
| 480 |
+
else:
|
| 481 |
+
domain_x = 0.5
|
| 482 |
+
|
| 483 |
+
domain_y = (y_val - y_range[0]) / (y_range[1] - y_range[0]) if (y_range[1] - y_range[0]) > 0 else 0.5
|
| 484 |
+
|
| 485 |
+
# Clamp to valid range
|
| 486 |
+
domain_x = max(0, min(1, domain_x))
|
| 487 |
+
domain_y = max(0, min(1, domain_y))
|
| 488 |
+
|
| 489 |
+
layout_images.append(dict(
|
| 490 |
+
source=logo_uri,
|
| 491 |
+
xref="x domain",
|
| 492 |
+
yref="y domain",
|
| 493 |
+
x=domain_x,
|
| 494 |
+
y=domain_y,
|
| 495 |
+
sizex=0.04,
|
| 496 |
+
sizey=0.06,
|
| 497 |
+
xanchor="center",
|
| 498 |
+
yanchor="middle",
|
| 499 |
+
layer="above"
|
| 500 |
+
))
|
| 501 |
except Exception:
|
| 502 |
pass
|
| 503 |
|