diff --git a/public/app/directives/metric.segment.js b/public/app/directives/metric.segment.js index 953c92b6d3a..7f4144e4530 100644 --- a/public/app/directives/metric.segment.js +++ b/public/app/directives/metric.segment.js @@ -173,11 +173,12 @@ function (angular, app, _, $) { $scope.valueToSegment = function(value) { var option = _.findWhere($scope.options, {value: value}); - if (option) { - return uiSegmentSrv.newSegment({value: option.text, cssClass: attrs.cssClass, custom: attrs.custom}); - } else { - return uiSegmentSrv.newSegment({value: value, cssClass: attrs.cssClass, custom: attrs.custom}); - } + var segment = { + cssClass: attrs.cssClass, + custom: attrs.custom, + value: option ? option.text : value, + }; + return uiSegmentSrv.newSegment(segment); }; $scope.getOptionsInternal = function() { diff --git a/public/app/plugins/datasource/elasticsearch/bucketAgg.js b/public/app/plugins/datasource/elasticsearch/bucketAgg.js index 52dce608b13..6d5ef5adc68 100644 --- a/public/app/plugins/datasource/elasticsearch/bucketAgg.js +++ b/public/app/plugins/datasource/elasticsearch/bucketAgg.js @@ -54,7 +54,7 @@ function (angular, _, queryDef) { $scope.settingsLinkText += ' (' + $scope.agg.order + ')'; } } else if ($scope.agg.type === 'date_histogram') { - delete $scope.agg.field; + $scope.agg.field = $scope.target.timeField; } return true; diff --git a/public/app/plugins/datasource/elasticsearch/partials/bucketAgg.html b/public/app/plugins/datasource/elasticsearch/partials/bucketAgg.html index fa4d5f3658f..3a16f058af0 100644 --- a/public/app/plugins/datasource/elasticsearch/partials/bucketAgg.html +++ b/public/app/plugins/datasource/elasticsearch/partials/bucketAgg.html @@ -7,10 +7,10 @@