import { getAggValue } from './get_agg_value' ; import { METRIC_TYPES } from '../../../../../../data/common' ; import type { Metric } from '../../../../common/types' ; import type { PanelDataArray } from '../../../../common/types/vis_data' ; export const mapEmptyToZero = ( metric , buckets ) : PanelDataArray [ ] => { const isSettableToZero = [ METRIC_TYPES . COUNT , METRIC_TYPES . CARDINALITY , METRIC_TYPES . SUM , ] . includes ( metric . type as METRIC_TYPES ) ; return isSettableToZero && ! buckets . length ? [ [ undefined , 0 ] ] : buckets . map ( ( bucket ) => [ bucket . key , getAggValue ( bucket , metric ) ] ) ; } ;