When filtering out all results, graph disappears totally

Hi there. When I filter all the results from a graph in this project I’m working on, the entire graph totally disappears. There are ‘father’ elements in the filter which you can choose ‘All’ or ‘None’ for. ‘None’ removes all of the ‘son’ data from the graph. However, if you filter the data until it is all gone, the graph disappears and even pressing ‘All’ back on the ‘father’ elements does not bring the graph back. I have to refresh the page to regain functionality.

Ideally I need the graph to stay there with just empty axis when there is no data. Can anyone help with this?

The relevant code is below (I believe ‘scope’ is just where the database data is stored). This isn’t my project, and it is too large to show all related functions, but hopefully this is enough:


$scope.showtabletab5 = false;
    $scope.expandTab5 = true;
    $scope.changeSizeTab5 = function(){
        generateDataTab4($scope.filtering);
        resizeTab4();
        if($scope.expandTab5){
            $scope.showtabletab5 = false;
            draw_Bubble_Tab3();
        }else{
            $scope.showtabletab5 = true;
            draw_Bubble_Tab4();
        }
    };

    $scope.show_side_left = function(){ $mdSidenav('left').toggle();}
    $scope.hide_side_left = function(){ $mdSidenav('left').close();}
    $scope.filtering = [];

    $scope.change_state_son = function(idx_father, idx_son){
        $scope.filtering[idx_father].sons[idx_son].selected = !$scope.filtering[idx_father].sons[idx_son].selected;
        //Re-Draw
        generateDataTab4($scope.filtering);
        resizeTab4();
        if ($scope.expandTab5) {
            draw_Bubble_Tab3();
        } else {
            draw_Bubble_Tab4();
        }
    };

    $scope.check_all_tab4 = function(idx_father){
        for(var i=0;i<$scope.filtering[idx_father].sons.length; i++){
            $scope.filtering[idx_father].sons[i].selected = true;
        }
        //Re-Draw
        generateDataTab4($scope.filtering);
        resizeTab4();
        if ($scope.expandTab5) {
            draw_Bubble_Tab3();
        } else {
            draw_Bubble_Tab4();
        }
    };

    $scope.check_none_tab4 = function(idx_father){
        for(var i=0;i<$scope.filtering[idx_father].sons.length; i++){
            $scope.filtering[idx_father].sons[i].selected = false;
        }
        //Re-Draw
        generateDataTab4($scope.filtering);
        resizeTab4();
        if ($scope.expandTab5) {
            draw_Bubble_Tab3();
        } else { 
            draw_Bubble_Tab4();
        }
    };

I’ve edited your post for readability. When you enter a code block into the forum, precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

markdown_Forums