diff --git a/src/ui/public/vis/editors/default/agg.html b/src/ui/public/vis/editors/default/agg.html index baba3554a9c3b..4cf8174c7a7ba 100644 --- a/src/ui/public/vis/editors/default/agg.html +++ b/src/ui/public/vis/editors/default/agg.html @@ -24,7 +24,7 @@ - + {{ aggForm.describeErrors() }} diff --git a/src/ui/public/vis/editors/default/agg_params.js b/src/ui/public/vis/editors/default/agg_params.js index de252c2f2dd82..0f67e687dc9d0 100644 --- a/src/ui/public/vis/editors/default/agg_params.js +++ b/src/ui/public/vis/editors/default/agg_params.js @@ -47,6 +47,11 @@ uiModules $scope.aggTypeOptions = aggTypeFilters .filter(aggTypes.byType[$scope.groupName], $scope.indexPattern, $scope.agg); + // If current agg type is not part of allowed agg types, set to first element of allowed agg types + if(!$scope.aggTypeOptions.includes($scope.agg.type)) { + $scope.agg.type = $scope.aggTypeOptions[0]; + } + $scope.advancedToggled = false; // We set up this watch prior to adding the controls below, because when the controls are added,