We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Change WorkingDays property in one Gantt chart for some date range

Hi,

I have I question about Gantt Chart component.

Is there an option to have different settings for WorkingDays in one Gantt chart for some date range?

For example from 1st January, till 15th February to set 3 working days (Wed, Thursday and Friday) and from 16th, February, till 31st December, 5 working days (Monday - Friday). Can you provide an example if such functionality exists.


Thanks in advance.


Regards,


1 Reply 1 reply marked as answer

MS Monisha Sivanthilingam Syncfusion Team January 5, 2023 04:10 AM UTC

Hi Ana-li,


Greetings from Syncfusion support.


Unfortunately, it is not possible to set different working days for different periods of time in the Gantt Chart. However, we can block off the days you do not want to be considered as working days by setting them as holidays. For example, if you want to block off Mondays and Tuesdays as holidays for the period between January 1 and February 15, you can set the working week to be from Monday to Friday for the entire duration of the project and then mark Mondays and Tuesdays as holidays for that specific period.


The below code snippets demonstrate the solution.


Index.razor

 

<GanttHolidays>

  @foreach (var (start, end) in holidayDates)

  {

    <GanttHoliday From="start" To="end" Label="Holiday" />

  }

</GanttHolidays>

 


 

public List<(DateTime Start, DateTime End)> GetHolidays()

{

  var from = new DateTime(2023, 01, 01);

  var to = new DateTime(2023, 02, 15);

  var monday = new DateTime();

  var nextMonday = new DateTime();

  for (var day = from.Date; day.Date <= to.Date; day = day.AddDays(1))

  {

    if(day.DayOfWeek == DayOfWeek.Monday)

    {

      monday = day;

      break;

    }

  }

  holidayDates.Add((monday, monday.AddDays(1)));

  while(monday.Date < to.Date)

  {

    nextMonday = monday.AddDays(7);

    holidayDates.Add((nextMonday, nextMonday.AddDays(1)));

    monday = nextMonday;

  }

  return holidayDates;

}

 


Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/F17970538856936


Regards,

Monisha.


Marked as answer
Loader.
Live Chat Icon For mobile
Up arrow icon