thinkwee
commited on
Commit
·
ef5609e
1
Parent(s):
e77058f
fix display
Browse files
charts.js
CHANGED
|
@@ -211,6 +211,16 @@ function initScalingCharts() {
|
|
| 211 |
});
|
| 212 |
}
|
| 213 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
function updateScalingCharts(dimension) {
|
| 215 |
const scenarios = ['mimic', '10k', 'globem'];
|
| 216 |
const xLabels = {
|
|
@@ -248,7 +258,7 @@ function updateScalingCharts(dimension) {
|
|
| 248 |
const hoverFormat = dimension === 'token' ? (v) => v.toLocaleString() : (dimension === 'cost' ? (v) => '$' + v.toFixed(4) : (v) => v);
|
| 249 |
|
| 250 |
models.forEach((model, i) => {
|
| 251 |
-
const len = data[model].turns.length;
|
| 252 |
const modelNormX = allNormX.slice(offset, offset + len);
|
| 253 |
|
| 254 |
// Get raw values for customdata (hover)
|
|
@@ -264,12 +274,12 @@ function updateScalingCharts(dimension) {
|
|
| 264 |
x: modelNormX,
|
| 265 |
y: data[model].accuracy,
|
| 266 |
customdata: rawValues,
|
|
|
|
| 267 |
hovertemplate: `<b>${model}</b><br>${hoverLabels[dimension]}: %{customdata}<br>Accuracy: %{y:.2f}%<extra></extra>`
|
| 268 |
});
|
| 269 |
});
|
| 270 |
|
| 271 |
-
// 4. Animate
|
| 272 |
-
// Since axis range is fixed [-0.05, 1.05], we only animate points and update tick labels
|
| 273 |
Plotly.animate(`scaling-${scenario}`, {
|
| 274 |
data: newTraces,
|
| 275 |
layout: {
|
|
@@ -286,6 +296,31 @@ function updateScalingCharts(dimension) {
|
|
| 286 |
duration: 800,
|
| 287 |
redraw: true
|
| 288 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 289 |
});
|
| 290 |
});
|
| 291 |
}
|
|
|
|
| 211 |
});
|
| 212 |
}
|
| 213 |
|
| 214 |
+
|
| 215 |
+
// Inject CSS for line drawing animation
|
| 216 |
+
const style = document.createElement('style');
|
| 217 |
+
style.textContent = `
|
| 218 |
+
.js-line path {
|
| 219 |
+
transition: stroke-dashoffset 1s ease-out;
|
| 220 |
+
}
|
| 221 |
+
`;
|
| 222 |
+
document.head.appendChild(style);
|
| 223 |
+
|
| 224 |
function updateScalingCharts(dimension) {
|
| 225 |
const scenarios = ['mimic', '10k', 'globem'];
|
| 226 |
const xLabels = {
|
|
|
|
| 258 |
const hoverFormat = dimension === 'token' ? (v) => v.toLocaleString() : (dimension === 'cost' ? (v) => '$' + v.toFixed(4) : (v) => v);
|
| 259 |
|
| 260 |
models.forEach((model, i) => {
|
| 261 |
+
const len = data[model].turns.length;
|
| 262 |
const modelNormX = allNormX.slice(offset, offset + len);
|
| 263 |
|
| 264 |
// Get raw values for customdata (hover)
|
|
|
|
| 274 |
x: modelNormX,
|
| 275 |
y: data[model].accuracy,
|
| 276 |
customdata: rawValues,
|
| 277 |
+
mode: 'markers', // Hide lines during transition
|
| 278 |
hovertemplate: `<b>${model}</b><br>${hoverLabels[dimension]}: %{customdata}<br>Accuracy: %{y:.2f}%<extra></extra>`
|
| 279 |
});
|
| 280 |
});
|
| 281 |
|
| 282 |
+
// 4. Animate Points (Lines Hidden)
|
|
|
|
| 283 |
Plotly.animate(`scaling-${scenario}`, {
|
| 284 |
data: newTraces,
|
| 285 |
layout: {
|
|
|
|
| 296 |
duration: 800,
|
| 297 |
redraw: true
|
| 298 |
}
|
| 299 |
+
}).then(() => {
|
| 300 |
+
// 5. After points arrive, Draw Lines
|
| 301 |
+
// First, enable lines mode
|
| 302 |
+
Plotly.restyle(`scaling-${scenario}`, { mode: 'lines+markers' });
|
| 303 |
+
|
| 304 |
+
// Then, animate the SVG paths
|
| 305 |
+
requestAnimationFrame(() => {
|
| 306 |
+
const graphDiv = document.getElementById(`scaling-${scenario}`);
|
| 307 |
+
const paths = graphDiv.querySelectorAll('.js-line path');
|
| 308 |
+
|
| 309 |
+
paths.forEach(path => {
|
| 310 |
+
const len = path.getTotalLength();
|
| 311 |
+
// Set initial state (hidden)
|
| 312 |
+
path.style.transition = 'none';
|
| 313 |
+
path.style.strokeDasharray = len;
|
| 314 |
+
path.style.strokeDashoffset = len;
|
| 315 |
+
|
| 316 |
+
// Force reflow
|
| 317 |
+
path.getBoundingClientRect();
|
| 318 |
+
|
| 319 |
+
// Animate to visible
|
| 320 |
+
path.style.transition = 'stroke-dashoffset 1s ease-out';
|
| 321 |
+
path.style.strokeDashoffset = '0';
|
| 322 |
+
});
|
| 323 |
+
});
|
| 324 |
});
|
| 325 |
});
|
| 326 |
}
|