Spaces:
Running
Running
Update modular_graph_and_candidates.py
Browse files
modular_graph_and_candidates.py
CHANGED
|
@@ -1269,11 +1269,27 @@ function dragEnd(e, d) {
|
|
| 1269 |
// Initialize
|
| 1270 |
updateVisibility();
|
| 1271 |
|
| 1272 |
-
// Auto-fit timeline view
|
| 1273 |
setTimeout(() => {
|
| 1274 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1275 |
const timeWidth = timeScale.range()[1] - timeScale.range()[0];
|
| 1276 |
-
const scale =
|
| 1277 |
const translateX = (W - timeWidth * scale) / 2;
|
| 1278 |
const translateY = 0;
|
| 1279 |
|
|
@@ -1282,6 +1298,7 @@ setTimeout(() => {
|
|
| 1282 |
.call(zoomBehavior.transform,
|
| 1283 |
d3.zoomIdentity.translate(translateX, translateY).scale(scale));
|
| 1284 |
}
|
|
|
|
| 1285 |
}, 1500);
|
| 1286 |
"""
|
| 1287 |
|
|
|
|
| 1269 |
// Initialize
|
| 1270 |
updateVisibility();
|
| 1271 |
|
| 1272 |
+
// Auto-fit timeline view - slightly zoomed out, centered on llama cluster
|
| 1273 |
setTimeout(() => {
|
| 1274 |
+
if (timeScale && timeExtent[0] && timeExtent[1]) {
|
| 1275 |
+
// Find llama node position
|
| 1276 |
+
const llamaNode = timeline.nodes.find(n => n.id === 'llama');
|
| 1277 |
+
|
| 1278 |
+
if (llamaNode && llamaNode.timestamp > 0) {
|
| 1279 |
+
// Center on llama's chronological position with slight zoom out
|
| 1280 |
+
const llamaX = timeScale(new Date(llamaNode.timestamp * 1000));
|
| 1281 |
+
const scale = 0.3; // Slightly zoomed out (was calculating much higher values)
|
| 1282 |
+
const translateX = W / 2 - llamaX * scale;
|
| 1283 |
+
const translateY = H / 2 - (H / 2 - 100) * scale; // Center vertically on content area
|
| 1284 |
+
|
| 1285 |
+
svg.transition()
|
| 1286 |
+
.duration(2000)
|
| 1287 |
+
.call(zoomBehavior.transform,
|
| 1288 |
+
d3.zoomIdentity.translate(translateX, translateY).scale(scale));
|
| 1289 |
+
} else {
|
| 1290 |
+
// Fallback: gentle zoom out on full timeline
|
| 1291 |
const timeWidth = timeScale.range()[1] - timeScale.range()[0];
|
| 1292 |
+
const scale = 0.25; // Fixed gentle zoom instead of calculated tight fit
|
| 1293 |
const translateX = (W - timeWidth * scale) / 2;
|
| 1294 |
const translateY = 0;
|
| 1295 |
|
|
|
|
| 1298 |
.call(zoomBehavior.transform,
|
| 1299 |
d3.zoomIdentity.translate(translateX, translateY).scale(scale));
|
| 1300 |
}
|
| 1301 |
+
}
|
| 1302 |
}, 1500);
|
| 1303 |
"""
|
| 1304 |
|