import { addDays , getUnixTime } from 'date-fns' ; import { GanttGroup , GanttItem } from 'ngx-gantt' ; export function random ( min , max ) { return Math . floor ( Math . random ( ) * ( max - min ) ) + min ; } export function randomItems ( length , parent ? , group ? ) { const items = [ ] ; for ( let i = 0 ; i < length ; i ++ ) { const start = addDays ( new Date ( ) , random ( - 200 , 200 ) ) ; const end = addDays ( start , random ( 0 , 100 ) ) ; items . push ( { id : `${ parent ?. id || group || '' }00000${ i }` , title : `${ parent ?. title || 'Task' }-${ i }` , start : getUnixTime ( start ) , end : getUnixTime ( end ) , group_id : group } ) ; } return items ; } export function randomGroupsAndItems ( length ) { const groups = [ ] ; let items = [ ] ; for ( let i = 0 ; i < length ; i ++ ) { groups . push ( { id : `00000${ i }` , title : `Group-${ i }` } ) ; items = [ ... items , ... randomItems ( 6 , undefined , groups [ i ] . id ) ] ; } return { groups , items } ; }