From de68ed08fc81e4044c262fa7813d2f6420aab8ec Mon Sep 17 00:00:00 2001 From: Elastic Jasper Date: Wed, 12 Oct 2016 12:52:50 -0400 Subject: [PATCH] Backport PR #8638 --------- **Commit 1:** Fix label on scripted field date histograms Now that we support Painless scripted fields users can create scripted date fields, and thus scripted date histograms. The label making method for the date histogram agg was getting the field name in a way that was incompatible with scripted fields, so I've added some fallback code for that scenario. I looked through the rest of the makeLabel methods on all the other aggs and they all correctly access the field displayName already so this should only need fixed for date histograms. Fixes https://github.com/elastic/kibana/issues/8632 * Original sha: 7359b4534278cac646924dbe0d99a103b055048e * Authored by Matthew Bargar on 2016-10-12T15:10:15Z --- src/ui/public/agg_types/buckets/date_histogram.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ui/public/agg_types/buckets/date_histogram.js b/src/ui/public/agg_types/buckets/date_histogram.js index 58d3f0eb144a..d99562e11722 100644 --- a/src/ui/public/agg_types/buckets/date_histogram.js +++ b/src/ui/public/agg_types/buckets/date_histogram.js @@ -41,7 +41,8 @@ export default function DateHistogramAggType(timefilter, config, Private) { makeLabel: function (agg) { const output = this.params.write(agg); const params = output.params; - return params.field + ' per ' + (output.metricScaleText || output.bucketInterval.description); + const field = params.field || agg.params.field.displayName || ''; + return field + ' per ' + (output.metricScaleText || output.bucketInterval.description); }, createFilter: createFilter, decorateAggConfig: function () {