diff --git a/src/ui/public/vis/editors/default/agg.html b/src/ui/public/vis/editors/default/agg.html index c8ccdeff89b16..aa37aaa97130b 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 cf4d7b1f7d499..4c4e5c3139f9c 100644 --- a/src/ui/public/vis/editors/default/agg_params.js +++ b/src/ui/public/vis/editors/default/agg_params.js @@ -44,7 +44,12 @@ uiModules const aggTypeSubscription = aggTypeFilters .filter$(aggTypes.byType[$scope.groupName], $scope.indexPattern, $scope.agg) - .subscribe(aggTypes => $scope.aggTypeOptions = aggTypes); + .subscribe(aggTypes => { + if(!aggTypes.includes($scope.agg.type) && aggTypes && aggTypes.length) { + $scope.agg.type = aggTypes[0]; + } + $scope.aggTypeOptions = aggTypes; + }); $scope.$on('$destroy', () => { aggTypeSubscription.unsubscribe();