import { XYBrushEvent } from '@elastic/charts' ; import { History } from 'history' ; import { Coordinate , TimeSeries } from '../../../../../typings/timeseries' ; import { fromQuery , toQuery } from '../../links/url_helpers' ; export const onBrushEnd = ( { x , history , } ) => { if ( x ) { const start = x [ 0 ] ; const end = x [ 1 ] ; const currentSearch = toQuery ( history . location . search ) ; const nextSearch = { rangeFrom : new Date ( start ) . toISOString ( ) , rangeTo : new Date ( end ) . toISOString ( ) , } ; history . push ( { ... history . location , search : fromQuery ( { ... currentSearch , ... nextSearch , } ) , } ) ; } } ; export function isTimeseriesEmpty ( timeseries ? ) { return ( ! timeseries || timeseries . map ( ( serie ) => serie . data ) . flat ( ) . every ( ( { y } ) => y === null || y === undefined ) ) ; }