import { IESAggField } from './agg_field_types' ; import { IVectorSource } from '../../sources/vector_source' ; import { ITooltipProperty , TooltipProperty } from '../../tooltips/tooltip_property' ; import { TOP_TERM_PERCENTAGE_SUFFIX , FIELD_ORIGIN } from '../../../../common/constants' ; import { TileMetaFeature } from '../../../../common/descriptor_types' ; export class TopTermPercentageField implements IESAggField { private readonly _topTermAggField : IESAggField ; constructor ( topTermAggField ) { this . _topTermAggField = topTermAggField ; } supportsFieldMetaFromEs ( ) { return false ; } supportsFieldMetaFromLocalData ( ) { if ( this . getSource ( ) . isMvt ( ) ) { return false ; } else { return true ; } } getSource ( ) { return this . _topTermAggField . getSource ( ) ; } getMbFieldName ( ) { return this . getName ( ) ; } getOrigin ( ) { return this . _topTermAggField . getOrigin ( ) ; } getName ( ) { return `${ this . _topTermAggField . getName ( ) }${ TOP_TERM_PERCENTAGE_SUFFIX }` ; } getRootName ( ) { return '' ; } async getLabel ( ) { const baseLabel = await this . _topTermAggField . getLabel ( ) ; return `${ baseLabel }%` ; } isValid ( ) { return this . _topTermAggField . isValid ( ) ; } async getDataType ( ) { return 'number' ; } async createTooltipProperty ( value ) { return new TooltipProperty ( this . getName ( ) , await this . getLabel ( ) , value ) ; } getValueAggDsl ( ) { return null ; } getBucketCount ( ) { return 0 ; } isCount ( ) { return false ; } async getExtendedStatsFieldMetaRequest ( ) { return null ; } async getPercentilesFieldMetaRequest ( percentiles ) { return null ; } async getCategoricalFieldMetaRequest ( ) { return null ; } canValueBeFormatted ( ) { return false ; } isEqual ( field ) { return field . getName ( ) === this . getName ( ) ; } pluckRangeFromTileMetaFeature ( metaFeature ) { return null ; } }