From 13ee3daa2c31fffaaf1c51146f9161b2f6c59b31 Mon Sep 17 00:00:00 2001 From: Matthew Bargar Date: Wed, 12 Oct 2016 20:14:35 -0400 Subject: [PATCH] Backport PR #8646 --------- **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. Now with more lodash for safer access Fixes elastic#8632 * Original sha: fc635bcf2f110f251eb789c13a2dcddcf1f4e986 * Authored by Matthew Bargar on 2016-10-12T22:30: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 58d3f0eb144a8..03bf6aa3f9b05 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 || _.get(agg, 'params.field.displayName', ''); + return field + ' per ' + (output.metricScaleText || output.bucketInterval.description); }, createFilter: createFilter, decorateAggConfig: function () {