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' ; export interface AggParamsGeoCentroid extends BaseAggParams { field : string ; } const geoCentroidTitle = i18n . translate ( 'data.search.aggs.metrics.geoCentroidTitle' , { defaultMessage : 'Geo Centroid' , } ) ; const geoCentroidLabel = i18n . translate ( 'data.search.aggs.metrics.geoCentroidLabel' , { defaultMessage : 'Geo Centroid' , } ) ; export const getGeoCentroidMetricAgg = ( ) => { return new MetricAggType ( { name : METRIC_TYPES . GEO_CENTROID , title : geoCentroidTitle , makeLabel : ( ) => geoCentroidLabel , params : [ { name : 'field' , type : 'field' , filterFieldTypes : OSD_FIELD_TYPES . GEO_POINT , } , ] , getValue ( agg , bucket ) { return bucket [ agg . id ] && bucket [ agg . id ] . location ; } , } ) ; } ;