thinkwee commited on
Commit ·
40e7624
1
Parent(s): af678b1
fix display
Browse files
charts.js
CHANGED
|
@@ -311,35 +311,55 @@ function updateScalingCharts(dimension) {
|
|
| 311 |
}
|
| 312 |
}).then(() => {
|
| 313 |
// Phase 2: Add lines back and animate them drawing
|
| 314 |
-
// First, update to lines+markers mode
|
| 315 |
const linesAndMarkersTraces = newTraces.map(trace => ({
|
| 316 |
...trace,
|
| 317 |
mode: 'lines+markers'
|
| 318 |
}));
|
| 319 |
|
|
|
|
| 320 |
Plotly.react(`scaling-${scenario}`, linesAndMarkersTraces, {
|
| 321 |
...graphDiv.layout
|
| 322 |
-
}, plotlyConfig)
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 341 |
});
|
| 342 |
-
}
|
| 343 |
});
|
| 344 |
});
|
| 345 |
}
|
|
|
|
| 311 |
}
|
| 312 |
}).then(() => {
|
| 313 |
// Phase 2: Add lines back and animate them drawing
|
|
|
|
| 314 |
const linesAndMarkersTraces = newTraces.map(trace => ({
|
| 315 |
...trace,
|
| 316 |
mode: 'lines+markers'
|
| 317 |
}));
|
| 318 |
|
| 319 |
+
// Use Plotly.react and wait for it to complete
|
| 320 |
Plotly.react(`scaling-${scenario}`, linesAndMarkersTraces, {
|
| 321 |
...graphDiv.layout
|
| 322 |
+
}, plotlyConfig).then(() => {
|
| 323 |
+
// Give browser time to render
|
| 324 |
+
requestAnimationFrame(() => {
|
| 325 |
+
requestAnimationFrame(() => {
|
| 326 |
+
// Try multiple selectors to find the line paths
|
| 327 |
+
let paths = graphDiv.querySelectorAll('.scatterlayer .js-line path');
|
| 328 |
+
if (paths.length === 0) {
|
| 329 |
+
paths = graphDiv.querySelectorAll('.js-line path');
|
| 330 |
+
}
|
| 331 |
+
if (paths.length === 0) {
|
| 332 |
+
paths = graphDiv.querySelectorAll('path.js-line');
|
| 333 |
+
}
|
| 334 |
+
if (paths.length === 0) {
|
| 335 |
+
paths = graphDiv.querySelectorAll('.scatter path');
|
| 336 |
+
}
|
| 337 |
+
|
| 338 |
+
console.log(`Found ${paths.length} paths for ${scenario}`);
|
| 339 |
+
|
| 340 |
+
paths.forEach((path, idx) => {
|
| 341 |
+
const len = path.getTotalLength();
|
| 342 |
+
console.log(`Path ${idx}: length = ${len}`);
|
| 343 |
+
|
| 344 |
+
if (len > 0) {
|
| 345 |
+
// Reset any previous animation
|
| 346 |
+
path.style.transition = 'none';
|
| 347 |
+
path.style.strokeDasharray = len + ' ' + len;
|
| 348 |
+
path.style.strokeDashoffset = len;
|
| 349 |
+
|
| 350 |
+
// Force reflow
|
| 351 |
+
path.getBoundingClientRect();
|
| 352 |
+
|
| 353 |
+
// Start animation after a tiny delay
|
| 354 |
+
setTimeout(() => {
|
| 355 |
+
path.style.transition = 'stroke-dashoffset 2s ease-out';
|
| 356 |
+
path.style.strokeDashoffset = '0';
|
| 357 |
+
}, 10);
|
| 358 |
+
}
|
| 359 |
+
});
|
| 360 |
+
});
|
| 361 |
});
|
| 362 |
+
});
|
| 363 |
});
|
| 364 |
});
|
| 365 |
}
|