@@ -422,6 +422,12 @@ <h4 style="color: {{ statusMessageColour }};" data-cy="statusmsg"> {{ statu
422
422
$scope . statusMessage = "" ;
423
423
}
424
424
425
+ // Clear out any existing table data
426
+ $scope . clearData = function ( ) {
427
+ $scope . db . ColNames = [ ] ;
428
+ $scope . db . Records = [ ] ;
429
+ }
430
+
425
431
// Handle browser resize events
426
432
function resizeEvent ( ) {
427
433
if ( dataReceived === true ) {
@@ -433,14 +439,16 @@ <h4 style="color: {{ statusMessageColour }};" data-cy="statusmsg"> {{ statu
433
439
// Change to a newly selected visualisation
434
440
// Note, the 'execNewVis' parameter controls whether to execute and display the visualisation after loading it
435
441
$scope . changeVis = function ( newVis , execNewVis ) {
442
+ // Clear out any existing table data and chart
443
+ $scope . showVis = false ;
444
+ $scope . clearData ( ) ;
445
+
436
446
// Retrieve the SQL and chart settings for the newly chosen visualisation from the server
437
447
$http . get ( "/x/visget/[[ .DB.Info.Owner ]]/[[ .DB.Info.Database ]]?visname=" + newVis ) . then (
438
448
function success ( response ) {
439
449
if ( execNewVis ) {
440
- // Clear any existing status message, chart, and table data
450
+ // Clear any existing status message
441
451
$scope . statusMessage = "" ;
442
- $scope . showVis = true ;
443
- $scope . clearData ( ) ;
444
452
}
445
453
446
454
// Apply the retrieved information
@@ -460,14 +468,14 @@ <h4 style="color: {{ statusMessageColour }};" data-cy="statusmsg"> {{ statu
460
468
461
469
// If requested, we execute the newly loaded visualisation
462
470
if ( execNewVis ) {
471
+ $scope . showVis = true ;
463
472
$scope . execSQL ( ) ;
464
473
}
465
474
} , function failure ( response ) {
466
475
if ( execNewVis ) {
467
476
// Retrieving visualisation text failed, so display the returned error message
468
477
$scope . statusMessageColour = "red" ;
469
478
$scope . statusMessage = nowString ( ) + "Retrieving visualisation failed: " + response . data ;
470
- $scope . showVis = false ;
471
479
}
472
480
}
473
481
)
@@ -525,12 +533,6 @@ <h4 style="color: {{ statusMessageColour }};" data-cy="statusmsg"> {{ statu
525
533
$scope . doChart ( true ) ;
526
534
} ;
527
535
528
- // Clear out any existing table data
529
- $scope . clearData = function ( ) {
530
- $scope . db . ColNames = [ ] ;
531
- $scope . db . Records = [ ] ;
532
- }
533
-
534
536
// Deletes a saved visualisation
535
537
$scope . deleteVis = function ( ) {
536
538
// Check if the user is logged in
@@ -555,6 +557,10 @@ <h4 style="color: {{ statusMessageColour }};" data-cy="statusmsg"> {{ statu
555
557
// Remove the visualisation from the drop-down list
556
558
$scope . visNames . splice ( arrIdx , 1 ) ;
557
559
560
+ // Clear out any existing table data, and remove any chart
561
+ $scope . showVis = false ;
562
+ $scope . clearData ( ) ;
563
+
558
564
// If the currently selected visualisation was the deleted one, pick the first in the remaining
559
565
// visualisation list as the new selection
560
566
if ( $scope . visName === name ) {
0 commit comments