genericTimeline.js 1.1 KB

12345678910111213141516171819202122
  1. const timeline = document.getElementById("timeline");
  2. const rows = [
  3. {id:'1',title:"Ressource 1 DarkSlate",eventBgColor:"DarkSlateBlue"},
  4. {id:'3',title:"Ressource 3"},
  5. {id:'4',title:"Ressource 4"},
  6. {id:'5',title:"Ressource 5"}];
  7. rows[0].parent = rows[1];
  8. rows[2].parent = rows[1];
  9. const data = dayjs().startOf("hour").hour(9);
  10. const timeslots = [
  11. {id:'1', title:"Fixed ressource" ,ressourceId:'3', start:data.subtract(3,"h").toDate(), end:data.toDate(), ressourceEditable:false,bgColor:"darkgreen"},
  12. {id:'2', title:"Fixed time" , ressourceId:'3', start:data.toDate(), end:data.endOf("hour").add(1,"h").toDate(), editable:false,bgColor:"FireBrick"},
  13. {id:'3', ressourceId:'4', start:data.add(1,"h").toDate(), end:data.endOf("hour").add(2,"h").toDate()},
  14. {id:'4', ressourceId:'3', start:data.startOf("day").subtract(1,"h").toDate(), end:dayjs().endOf("hour").add(1,"h").toDate()}
  15. ]
  16. console.log(timeline.addRessources(rows));
  17. timeline.addEvents(timeslots);
  18. const timeline2 = document.getElementById("timeline2");
  19. timeline2.setLegendUnitFormat("d","MMM D")