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
This commit is contained in:
Matthew Bargar 2016-10-12 11:10:15 -04:00
parent 64227dcf8e
commit 7359b45342

View file

@ -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 () {