How can i count events section wise in per timeslot?


#1

How can I count events section-wise per timeslot in the unit view?


#2

Hello @Rijwan_Mohammed,

As I understand, you want to count events based on their units and dates, am I right?

If it’s so, you can do it using the getEvents(startDate, endDate) method:
https://docs.dhtmlx.com/scheduler/api__scheduler_getevents.html
which allows you to count events by date range.

After that, you will be able to map through the array of the events and count them based on their “unit” unit properties, the coded may look like follows:

function countEventsSec(){ 
  var evs = scheduler.getEvents(new Date(2020,5,29),new Date(2020,5,30));
  var aSec = 0, bSec = 0, cSec = 0;
  for (var i=0; i<evs.length; i++){
    console.log(evs[i].unit_id)
    if(evs[i].unit_id == 1)
      aSec++
    if(evs[i].unit_id == 2)
      bSec++
    if(evs[i].unit_id == 3)
      cSec++
   }
  
  console.log("A Section: ", aSec, "B Section: ", bSec, "C Section: ", cSec,)
}

Here is a demo:
https://snippet.dhtmlx.com/5/58c38d37c

If you meant something different, could you please clarify what exactly you want to count and based on which properties?