Anisha Bhatnagar
commited on
Commit
Β·
ab8b2e5
1
Parent(s):
f6912cd
reverting to original scale when selected zoom region is None
Browse files
app.py
CHANGED
@@ -501,41 +501,56 @@ def app(share=False):
|
|
501 |
console.log('Plot element exists');
|
502 |
}
|
503 |
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
514 |
|
515 |
-
if (
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
'xaxis.range': [bbox.xaxis[0], bbox.xaxis[1]],
|
520 |
-
'yaxis.range': [bbox.yaxis[0], bbox.yaxis[1]],
|
521 |
-
'xaxis.autorange': false,
|
522 |
-
'yaxis.autorange': false
|
523 |
-
};
|
524 |
-
console.log('Update object:', update);
|
525 |
|
526 |
-
window.Plotly
|
527 |
-
|
528 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
529 |
} else {
|
530 |
-
console.log('
|
531 |
}
|
532 |
-
}
|
533 |
-
console.log('
|
534 |
}
|
535 |
-
} catch(e) {
|
536 |
-
console.log('Error in region processing:', e);
|
537 |
}
|
538 |
-
|
539 |
console.log('=== ZOOM DEBUG END ===');
|
540 |
return [region_name, regions_json_str];
|
541 |
}
|
|
|
501 |
console.log('Plot element exists');
|
502 |
}
|
503 |
|
504 |
+
if (region_name === "None") {
|
505 |
+
// Reset to original zoom when None is selected
|
506 |
+
console.log('Resetting zoom to original view...');
|
507 |
+
if (window.Plotly && plotDiv) {
|
508 |
+
window.Plotly.relayout(plotDiv, {
|
509 |
+
'xaxis.autorange': true,
|
510 |
+
'yaxis.autorange': true
|
511 |
+
}).then(() => {
|
512 |
+
console.log('β Reset to auto-range completed successfully');
|
513 |
+
}).catch(err => {
|
514 |
+
console.log('β Reset failed:', err);
|
515 |
+
});
|
516 |
+
}
|
517 |
+
}
|
518 |
+
else{// Try to parse regions
|
519 |
+
try {
|
520 |
+
const precomputed_regions = JSON.parse(regions_json_str);
|
521 |
+
console.log('Regions parsed successfully');
|
522 |
+
console.log('Available regions:', Object.keys(precomputed_regions));
|
523 |
|
524 |
+
if (region_name !== "None" && precomputed_regions[region_name]) {
|
525 |
+
const region = precomputed_regions[region_name];
|
526 |
+
const bbox = region.bbox;
|
527 |
+
console.log('Bbox to apply:', bbox);
|
|
|
|
|
|
|
|
|
|
|
|
|
528 |
|
529 |
+
if (window.Plotly && plotDiv) {
|
530 |
+
console.log('Calling Plotly.relayout...');
|
531 |
+
|
532 |
+
const update = {
|
533 |
+
'xaxis.range': [bbox.xaxis[0], bbox.xaxis[1]],
|
534 |
+
'yaxis.range': [bbox.yaxis[0], bbox.yaxis[1]],
|
535 |
+
'xaxis.autorange': false,
|
536 |
+
'yaxis.autorange': false
|
537 |
+
};
|
538 |
+
console.log('Update object:', update);
|
539 |
+
|
540 |
+
window.Plotly.relayout(plotDiv, update)
|
541 |
+
.then(() => console.log('β Relayout completed successfully'))
|
542 |
+
.catch(err => console.log('β Relayout failed:', err));
|
543 |
+
} else {
|
544 |
+
console.log('Missing requirements - Plotly:', !!window.Plotly, 'PlotDiv:', !!plotDiv);
|
545 |
+
}
|
546 |
} else {
|
547 |
+
console.log('Region not found or None selected');
|
548 |
}
|
549 |
+
} catch(e) {
|
550 |
+
console.log('Error in region processing:', e);
|
551 |
}
|
|
|
|
|
552 |
}
|
553 |
+
|
554 |
console.log('=== ZOOM DEBUG END ===');
|
555 |
return [region_name, regions_json_str];
|
556 |
}
|