Anisha Bhatnagar commited on
Commit
ab8b2e5
Β·
1 Parent(s): f6912cd

reverting to original scale when selected zoom region is None

Browse files
Files changed (1) hide show
  1. app.py +44 -29
app.py CHANGED
@@ -501,41 +501,56 @@ def app(share=False):
501
  console.log('Plot element exists');
502
  }
503
 
504
- // Try to parse regions
505
- try {
506
- const precomputed_regions = JSON.parse(regions_json_str);
507
- console.log('Regions parsed successfully');
508
- console.log('Available regions:', Object.keys(precomputed_regions));
509
-
510
- if (region_name !== "None" && precomputed_regions[region_name]) {
511
- const region = precomputed_regions[region_name];
512
- const bbox = region.bbox;
513
- console.log('Bbox to apply:', bbox);
 
 
 
 
 
 
 
 
 
514
 
515
- if (window.Plotly && plotDiv) {
516
- console.log('Calling Plotly.relayout...');
517
-
518
- const update = {
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.relayout(plotDiv, update)
527
- .then(() => console.log('βœ“ Relayout completed successfully'))
528
- .catch(err => console.log('βœ— Relayout failed:', err));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
529
  } else {
530
- console.log('Missing requirements - Plotly:', !!window.Plotly, 'PlotDiv:', !!plotDiv);
531
  }
532
- } else {
533
- console.log('Region not found or None selected');
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
  }