import { useMemo } from 'react' ; import { useUiSettings } from '../../contexts/kibana' ; import { TimeBuckets } from '../../util/time_buckets' ; import { UI_SETTINGS } from '../../../../../../../src/plugins/data/common' ; export const useTimeBuckets = ( ) => { const uiSettings = useUiSettings ( ) ; return useMemo ( ( ) => { return new TimeBuckets ( { 'histogram:maxBars' : uiSettings . get ( UI_SETTINGS . HISTOGRAM_MAX_BARS ) , 'histogram:barTarget' : uiSettings . get ( UI_SETTINGS . HISTOGRAM_BAR_TARGET ) , dateFormat : uiSettings . get ( 'dateFormat' ) , 'dateFormat:scaled' : uiSettings . get ( 'dateFormat:scaled' ) , } ) ; } , [ uiSettings ] ) ; } ;