@@ -422,6 +422,12 @@ <h4 style="color: {{ statusMessageColour }};" data-cy="statusmsg"> {{ statu
422422 $scope . statusMessage = "" ;
423423 }
424424
425+ // Clear out any existing table data
426+ $scope . clearData = function ( ) {
427+ $scope . db . ColNames = [ ] ;
428+ $scope . db . Records = [ ] ;
429+ }
430+
425431 // Handle browser resize events
426432 function resizeEvent ( ) {
427433 if ( dataReceived === true ) {
@@ -433,14 +439,16 @@ <h4 style="color: {{ statusMessageColour }};" data-cy="statusmsg"> {{ statu
433439 // Change to a newly selected visualisation
434440 // Note, the 'execNewVis' parameter controls whether to execute and display the visualisation after loading it
435441 $scope . changeVis = function ( newVis , execNewVis ) {
442+ // Clear out any existing table data and chart
443+ $scope . showVis = false ;
444+ $scope . clearData ( ) ;
445+
436446 // Retrieve the SQL and chart settings for the newly chosen visualisation from the server
437447 $http . get ( "/x/visget/[[ .DB.Info.Owner ]]/[[ .DB.Info.Database ]]?visname=" + newVis ) . then (
438448 function success ( response ) {
439449 if ( execNewVis ) {
440- // Clear any existing status message, chart, and table data
450+ // Clear any existing status message
441451 $scope . statusMessage = "" ;
442- $scope . showVis = true ;
443- $scope . clearData ( ) ;
444452 }
445453
446454 // Apply the retrieved information
@@ -460,14 +468,14 @@ <h4 style="color: {{ statusMessageColour }};" data-cy="statusmsg"> {{ statu
460468
461469 // If requested, we execute the newly loaded visualisation
462470 if ( execNewVis ) {
471+ $scope . showVis = true ;
463472 $scope . execSQL ( ) ;
464473 }
465474 } , function failure ( response ) {
466475 if ( execNewVis ) {
467476 // Retrieving visualisation text failed, so display the returned error message
468477 $scope . statusMessageColour = "red" ;
469478 $scope . statusMessage = nowString ( ) + "Retrieving visualisation failed: " + response . data ;
470- $scope . showVis = false ;
471479 }
472480 }
473481 )
@@ -525,12 +533,6 @@ <h4 style="color: {{ statusMessageColour }};" data-cy="statusmsg"> {{ statu
525533 $scope . doChart ( true ) ;
526534 } ;
527535
528- // Clear out any existing table data
529- $scope . clearData = function ( ) {
530- $scope . db . ColNames = [ ] ;
531- $scope . db . Records = [ ] ;
532- }
533-
534536 // Deletes a saved visualisation
535537 $scope . deleteVis = function ( ) {
536538 // Check if the user is logged in
@@ -555,6 +557,10 @@ <h4 style="color: {{ statusMessageColour }};" data-cy="statusmsg"> {{ statu
555557 // Remove the visualisation from the drop-down list
556558 $scope . visNames . splice ( arrIdx , 1 ) ;
557559
560+ // Clear out any existing table data, and remove any chart
561+ $scope . showVis = false ;
562+ $scope . clearData ( ) ;
563+
558564 // If the currently selected visualisation was the deleted one, pick the first in the remaining
559565 // visualisation list as the new selection
560566 if ( $scope . visName === name ) {
0 commit comments