import { i18n } from '@osd/i18n' ; import { MetricAggType } from './metric_agg_type' ; import { METRIC_TYPES } from './metric_agg_types' ; import { OSD_FIELD_TYPES } from '../../../../common' ; import { BaseAggParams } from '../types' ; const averageTitle = i18n . translate ( 'data.search.aggs.metrics.averageTitle' , { defaultMessage : 'Average' , } ) ; export interface AggParamsAvg extends BaseAggParams { field : string ; } export const getAvgMetricAgg = ( ) => { return new MetricAggType ( { name : METRIC_TYPES . AVG , title : averageTitle , makeLabel : ( aggConfig ) => { return i18n . translate ( 'data.search.aggs.metrics.averageLabel' , { defaultMessage : 'Average {field}' , values : { field : aggConfig . getFieldDisplayName ( ) } , } ) ; } , params : [ { name : 'field' , type : 'field' , filterFieldTypes : [ OSD_FIELD_TYPES . NUMBER , OSD_FIELD_TYPES . HISTOGRAM ] , } , ] , } ) ; } ;