import { last } from 'lodash' ; import { PanelSeries } from '../../../../common/types/vis_data' ; param { Array } seriesGroup return { number } export function getLastSeriesTimestamp ( seriesGroup = [ ] ) { let lastTimestamp ; seriesGroup . forEach ( ( series ) => { series . forEach ( ( { data } ) => { const lastValue = last ( data ) ; if ( lastValue ) { const [ dataLastTimestamp ] = lastValue ; if ( typeof dataLastTimestamp === 'number' ) { lastTimestamp = Math . max ( dataLastTimestamp , lastTimestamp ?? dataLastTimestamp ) ; } } } ) ; } ) ; return lastTimestamp ; }