Calendar Settings in ASP.NET MVC Gantt Chart Control
The Gantt Chart control supports advanced calendar configuration through the CalendarSettings property, enabling management of working hours, holidays, and task-specific scheduling. Calendar settings control how the Gantt Chart calculates task duration, determines working days, and schedules dependencies.
The CalendarSettings property contains two key configurations:
- Project Calendar: Defines the default daily working hours, holidays, and exceptions.
-
Task Calendars: Define working days, hours, holidays, and exceptions for tasks with a matching
CalendarId.
Project calendar
The CalendarSettings.ProjectCalendar defines default daily working hours and date rules for tasks without a matching task calendar. Configure the default weekdays with the global WorkWeek property, and use IncludeWeekend to include or exclude weekend days from task-duration calculations. These are Gantt properties, not members of ProjectCalendar.
Configure project working hours and exceptions
Set the default daily working hours in the project calendar’s WorkingTime collection. Each range uses numeric from and to hour values; use multiple ranges to represent breaks. Tasks without an assigned task calendar use the project calendar’s working hours.
Project calendar exceptions override the project calendar’s standard working hours or non-working status on specific dates. Use them to define custom working hours for an otherwise non-working date or to change the hours for a particular date. The following example sets the Gantt work week and weekend behavior, then defines project working hours and a date-specific exception:
@(Html.EJS().Gantt("Gantt")
.DataSource((IEnumerable<object>)ViewBag.DataSource)
.Height("450px")
.ProjectStartDate("04/01/2026")
.ProjectEndDate("04/30/2026")
.WorkWeek(new string[] { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" })
.IncludeWeekend(false)
.TaskFields(task => task
.Id("TaskId")
.Name("TaskName")
.StartDate("StartDate")
.Duration("Duration")
.ParentID("ParentId"))
.LabelSettings(label => label.LeftLabel("TaskName"))
.CalendarSettings(calendar => calendar.ProjectCalendar(project =>
project
.WorkingTime(new List<object>
{
new { from = 9, to = 12 },
new { from = 13, to = 17 }
})
.Exceptions(new List<object>
{
new
{
from = new DateTime(2026, 4, 6),
to = new DateTime(2026, 4, 6),
label = "Extended Working Day",
exceptionWorkingTime = new List<object>
{
new { from = 8, to = 18 }
}
}
})))
.Render())using System;
using System.Collections.Generic;
using System.Web.Mvc;
namespace MVCSamples.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
ViewBag.DataSource = new List<TaskData>()
{
new TaskData
{
TaskId = 1,
TaskName = "Project Planning",
StartDate = new DateTime(2026, 4, 2),
Duration = 3
},
new TaskData
{
TaskId = 2,
TaskName = "Requirements Analysis",
StartDate = new DateTime(2026, 4, 5),
Duration = 2,
ParentId = 1
},
new TaskData
{
TaskId = 3,
TaskName = "Design",
StartDate = new DateTime(2026, 4, 7),
Duration = 4,
ParentId = 1
},
new TaskData
{
TaskId = 4,
TaskName = "Development",
StartDate = new DateTime(2026, 4, 11),
Duration = 5
},
new TaskData
{
TaskId = 5,
TaskName = "Testing",
StartDate = new DateTime(2026, 4, 16),
Duration = 3
}
};
return View();
}
}
public class TaskData
{
public int TaskId { get; set; }
public string TaskName { get; set; }
public DateTime? StartDate { get; set; }
public DateTime? EndDate { get; set; }
public int? Duration { get; set; }
public int? ParentId { get; set; }
}
}Define project holidays
Holidays are non-working dates that exclude time from task calculations. The following example defines holidays for April 10 and April 17, excluding these dates from task scheduling calculations:
@Html.EJS().Gantt("Gantt")
.DataSource((IEnumerable<object>)ViewBag.DataSource)
.Height("450px")
.ProjectStartDate("04/01/2026")
.ProjectEndDate("04/30/2026")
.TaskFields(ts => ts
.Id("TaskId")
.Name("TaskName")
.StartDate("StartDate")
.Duration("Duration")
.ParentId("ParentId"))
.LabelSettings(label => label.LeftLabel("TaskName"))
.Columns(col =>
{
col.Field("TaskId").Add();
col.Field("TaskName").HeaderText("Name").Width(250).Add();
col.Field("StartDate").Add();
col.Field("Duration").Add();
})
.CalendarSettings(cal => cal
.ProjectCalendar(pc => pc
.Holidays(hol =>
{
hol.From(new DateTime(2026, 4, 10)).To(new DateTime(2026, 4, 10)).Label("Regional closure").Add();
hol.From(new DateTime(2026, 4, 17)).To(new DateTime(2026, 4, 17)).Label("Public holidays").Add();
})))
.Render()public IActionResult Index()
{
ViewBag.DataSource = new List<object>
{
new { TaskId = 1, TaskName = "Project Planning", StartDate = new DateTime(2026, 4, 2), Duration = 3 },
new { TaskId = 2, TaskName = "Requirements Analysis", StartDate = new DateTime(2026, 4, 5), Duration = 2, ParentId = 1 },
new { TaskId = 3, TaskName = "Design", StartDate = new DateTime(2026, 4, 7), Duration = 4, ParentId = 1 },
new { TaskId = 4, TaskName = "Development", StartDate = new DateTime(2026, 4, 11), Duration = 5 },
new { TaskId = 5, TaskName = "Testing", StartDate = new DateTime(2026, 4, 16), Duration = 3 }
};
return View();
}Task calendars
Task calendars define working days, hours, holidays, and exceptions for tasks assigned to them. Use them when a team follows a different schedule from the project calendar; the project calendar’s working-time settings may still provide fallback for working-time settings the task calendar does not define.
A task uses a task calendar only when its mapped CalendarId matches an entry in CalendarSettings.TaskCalendars. Without a match, the Gantt-level WorkWeek and IncludeWeekend settings and project WorkingTime determine its working schedule, and project-calendar holidays and exceptions apply. A matching task calendar uses its own date rules; fixed project holidays and exceptions are not copied to that task.
| Task calendar selection | Working days and hours | Holidays and exceptions |
|---|---|---|
| No matching task calendar | Uses Gantt-level WorkWeek and IncludeWeekend with project WorkingTime. |
Project-calendar holidays and exceptions apply. |
| Matching task calendar | Uses the selected task calendar’s schedule. Unset values first follow the inheritance rules below; values still unresolved use Gantt-level WorkWeek or project WorkingTime. Listed WeekWorkingTime days override normal working-time ranges. |
Uses date rules defined for the selected task calendar. Fixed project holidays and project exceptions do not apply. |
The task-calendar holiday sample demonstrates this distinction using its actual records. Project Calendar Work has no matching task calendar, so the project calendar’s fixed Regional Holiday on April 10 and Project extended hours exception on April 17 apply to it. Local Team Work uses local-team, which defines Local Holiday on April 6. Offshore Team Work uses offshore-team, which defines Offshore Holiday on April 8. Both assigned tasks span April 10 and 17, but the project holiday and exception do not apply to them; they use date rules defined for their selected calendars. Project working-time settings may still provide schedule fallback. Recurring project holidays have a separate fallback rule described in the inheritance section.
Configure working days and hours for task calendars
Use a task calendar when a team follows a schedule that differs from the project calendar. Configure the schedule on an entry in CalendarSettings.TaskCalendars:
-
WorkWeeklists the calendar’s working weekdays, using names from Sunday through Saturday. -
WorkingTimesets the standard daily hours with numericfromandtovalues. -
WeekWorkingTimesets different hours for specific weekdays usingDayOfWeekandTimeRange. Each entry replaces the complete schedule for that weekday.
In this example, both tasks use the day-shift calendar. It works Monday through Friday, uses a split schedule on Monday, and has shorter hours on Friday:
@using Syncfusion.EJ2.Gantt
@(Html.EJS().Gantt("Gantt")
.DataSource((IEnumerable<object>)ViewBag.DataSource)
.Height("450px")
.ProjectStartDate("04/06/2026")
.ProjectEndDate("04/24/2026")
.TaskFields(task => task
.Id("TaskId")
.Name("TaskName")
.StartDate("StartDate")
.Duration("Duration")
.CalendarId("CalendarId"))
.LabelSettings(label => label.LeftLabel("TaskName"))
.CalendarSettings(calendar => calendar
.ProjectCalendar(project => project
.WorkingTime(new List<object> { new { from = 9, to = 17 } }))
.TaskCalendars(new List<object>
{
new
{
calendarId = "day-shift",
workWeek = new[] { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" },
workingTime = new[] { new { from = 9, to = 17 } },
weekWorkingTime = new[]
{
new { dayOfWeek = "Monday", timeRange = new[] { new { from = 9, to = 12 }, new { from = 13, to = 17 } } },
new { dayOfWeek = "Friday", timeRange = new[] { new { from = 9, to = 13 } } }
}
}
}))
.Render())using System;
using System.Collections.Generic;
using System.Web.Mvc;
namespace MVCSamples.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
ViewBag.DataSource = new List<TaskData>
{
new TaskData { TaskId = 1, TaskName = "Project planning", StartDate = new DateTime(2026, 4, 6), Duration = 5, CalendarId = "day-shift" },
new TaskData { TaskId = 2, TaskName = "Requirements review", StartDate = new DateTime(2026, 4, 6), Duration = 3, CalendarId = "day-shift" },
new TaskData { TaskId = 3, TaskName = "Design", StartDate = new DateTime(2026, 4, 7), Duration = 4, CalendarId = "day-shift" },
new TaskData { TaskId = 4, TaskName = "Development", StartDate = new DateTime(2026, 4, 11), Duration = 5, CalendarId = "day-shift" },
new TaskData { TaskId = 5, TaskName = "Testing", StartDate = new DateTime(2026, 4, 16), Duration = 3, CalendarId = "day-shift" }
};
return View();
}
}
public class TaskData
{
public int TaskId { get; set; }
public string TaskName { get; set; }
public DateTime? StartDate { get; set; }
public int? Duration { get; set; }
public string CalendarId { get; set; }
}
}Assign task-specific calendars with exceptions
To assign a custom calendar to a task, define it in CalendarSettings.TaskCalendars, then reference it using the CalendarId property in the task data. Task calendars can define their own working weekdays, hours, holidays, and date-specific exceptions.
An exception without ExceptionWorkingTime, or with ExceptionWorkingTime: [], keeps the effective calendar schedule for the date. For example, the Team Meeting Day record below adds a label but does not close the day. To make the full date non-working, define a holiday instead.
The following example defines two task calendars with different working days, task-specific exceptions, and assigns them to specific tasks:
@using Syncfusion.EJ2.Gantt
@(Html.EJS().Gantt("Gantt")
.DataSource((IEnumerable<object>)ViewBag.DataSource)
.Height("450px")
.ProjectStartDate("04/01/2026")
.ProjectEndDate("04/30/2026")
.TaskFields(ts => ts
.Id("TaskId")
.Name("TaskName")
.StartDate("StartDate")
.Duration("Duration")
.CalendarId("CalendarId"))
.LabelSettings(ls => ls.LeftLabel("TaskName"))
.CalendarSettings(cs => cs
.ProjectCalendar(pc => pc.WorkingTime(new List<object>
{
new { from = 9, to = 17 }
}))
.TaskCalendars(new List<object>
{
new
{
calendarId = "day-shift",
workingTime = new[]
{
new { from = 9, to = 17 }
},
holidays = new object[] { },
exceptions = new[]
{
new
{
from = new DateTime(2026, 4, 9),
to = new DateTime(2026, 4, 9),
label = "Team Meeting Day"
}
}
},
new
{
calendarId = "night-shift",
workingTime = new[]
{
new { from = 17, to = 9 }
},
holidays = new object[] { },
exceptions = new[]
{
new
{
from = new DateTime(2026, 4, 10),
to = new DateTime(2026, 4, 10),
label = "Maintenance Window",
exceptionWorkingTime = new[]
{
new { from = 18, to = 8 }
}
}
}
}
}))
.Render())public class HomeController : Controller
{
public ActionResult Index()
{
ViewBag.DataSource = GetTaskCollection();
return View();
}
public static List<GanttDataSource> GetTaskCollection()
{
return new List<GanttDataSource>()
{
new GanttDataSource
{
TaskId = 1,
TaskName = "Development Team Work",
StartDate = new DateTime(2026, 4, 2),
Duration = 5,
CalendarId = "day-shift"
},
new GanttDataSource
{
TaskId = 2,
TaskName = "Night Shift Support",
StartDate = new DateTime(2026, 4, 2),
Duration = 5,
CalendarId = "night-shift"
},
new GanttDataSource
{
TaskId = 3,
TaskName = "Standard Hours",
StartDate = new DateTime(2026, 4, 2),
Duration = 5
}
};
}
public class GanttDataSource
{
public int TaskId { get; set; }
public string TaskName { get; set; }
public DateTime? StartDate { get; set; }
public int? Duration { get; set; }
public string CalendarId { get; set; }
}
}Define task calendar holidays
Task calendars can define holidays that affect the assigned task’s schedule. The following example sets a project-calendar holiday and exception, then defines separate holidays for two task calendars to show how the rules apply to tasks with and without a matching task calendar:
@using Syncfusion.EJ2.Gantt
@(Html.EJS().Gantt("Gantt")
.DataSource((IEnumerable<object>)ViewBag.DataSource)
.Height("450px")
.ProjectStartDate("04/01/2026")
.ProjectEndDate("04/30/2026")
.TaskFields(ts => ts
.Id("TaskId")
.Name("TaskName")
.StartDate("StartDate")
.Duration("Duration")
.CalendarId("CalendarId"))
.LabelSettings(ls => ls.LeftLabel("TaskName"))
.CalendarSettings(cs => cs
.ProjectCalendar(pc => pc
.WorkingTime(new List<object>
{
new { from = 9, to = 17 }
})
.Holidays(new List<object>
{
new
{
from = new DateTime(2026, 4, 10),
to = new DateTime(2026, 4, 10),
label = "Regional Holiday"
}
})
.Exceptions(new List<object>
{
new
{
from = new DateTime(2026, 4, 17),
to = new DateTime(2026, 4, 17),
label = "Project extended hours",
exceptionWorkingTime = new[] { new { from = 8, to = 18 } }
}
}))
.TaskCalendars(new List<object>
{
new
{
calendarId = "local-team",
holidays = new[]
{
new
{
from = new DateTime(2026, 4, 6),
to = new DateTime(2026, 4, 6),
label = "Local Holiday"
}
}
},
new
{
calendarId = "offshore-team",
holidays = new[]
{
new
{
from = new DateTime(2026, 4, 8),
to = new DateTime(2026, 4, 8),
label = "Offshore Holiday"
}
}
}
}))
.Render())public class HomeController : Controller
{
public ActionResult Index()
{
ViewBag.DataSource = GetTaskCollection();
return View();
}
public static List<GanttDataSource> GetTaskCollection()
{
return new List<GanttDataSource>()
{
new GanttDataSource
{
TaskId = 1,
TaskName = "Local Team Work",
StartDate = new DateTime(2026, 4, 2),
Duration = 11,
CalendarId = "local-team"
},
new GanttDataSource
{
TaskId = 2,
TaskName = "Offshore Team Work",
StartDate = new DateTime(2026, 4, 2),
Duration = 11,
CalendarId = "offshore-team"
},
new GanttDataSource
{
TaskId = 3,
TaskName = "Project Calendar Work",
StartDate = new DateTime(2026, 4, 9),
Duration = 6
}
};
}
public class GanttDataSource
{
public int TaskId { get; set; }
public string TaskName { get; set; }
public DateTime? StartDate { get; set; }
public int? Duration { get; set; }
public string CalendarId { get; set; }
}
}Configure task calendar inheritance
The task’s mapped CalendarId selects the task calendar used for scheduling. To reuse settings, set ParentId on that calendar to another task calendar’s CalendarId. The parent supplies settings that the selected calendar does not define; it does not make project-calendar holidays or exceptions apply to the task.
The Gantt checks the assigned calendar first, then its parents from nearest to farthest. A value set on the child takes precedence; if it is not set, the nearest parent definition applies. This inheritance applies to WorkWeek, WorkingTime, WeekWorkingTime, Holidays, and Exceptions.
| Setting | Resolution for the selected task calendar |
|---|---|
WorkWeek |
An undefined value can inherit the nearest defined value in the task-calendar chain. An explicit WorkWeek: [] does not inherit; it falls back to the global WorkWeek, then the Monday-Friday default. |
WorkingTime |
An empty or undefined value uses the nearest non-empty task-calendar value, then CalendarSettings.ProjectCalendar.WorkingTime. |
WeekWorkingTime |
A non-empty entry replaces the full schedule for its DayOfWeek. If that weekday is omitted, the nearest ancestor entry is used; otherwise, normal WorkingTime resolution applies. An entry with TimeRange: [] continues to the nearest ancestor entry, then normal WorkingTime resolution. |
| Date rules | The nearest calendar’s rule wins across the chain. Within the same calendar, an exception takes precedence over a holiday. Therefore, a nearer calendar’s holiday can take precedence over a farther ancestor’s exception. |
An exception with omitted or empty ExceptionWorkingTime uses the effective schedule rather than making the date non-working. When a working-time setting is still unresolved after checking the task-calendar chain, CalendarSettings.ProjectCalendar.WorkingTime supplies the fallback. Global WorkWeek supplies the weekday fallback.
A recurring project-calendar holiday is considered only when neither the assigned task calendar nor any calendar it inherits from defines a holiday or exception for that date. Fixed project-calendar holidays and project-calendar exceptions are not used as task-calendar fallback.
Missing parent references, self-references, and parent cycles are ignored.
The following sample assigns Regional Inherited Schedule to the regional task calendar, which inherits its schedule and date rules from the company calendar:
@using Syncfusion.EJ2.Gantt
@(Html.EJS().Gantt("Gantt")
.DataSource((IEnumerable<object>)ViewBag.DataSource)
.Height("450px")
.ProjectStartDate("04/01/2026")
.ProjectEndDate("06/30/2026")
.TaskFields(ts => ts
.Id("TaskId")
.Name("TaskName")
.StartDate("StartDate")
.Duration("Duration")
.CalendarId("CalendarId"))
.LabelSettings(ls => ls.LeftLabel("TaskName"))
.CalendarSettings(cs => cs
.ProjectCalendar(pc => pc.WorkingTime(new List<object>
{
new { from = 8, to = 17 }
}))
.TaskCalendars(new List<object>
{
new
{
calendarId = "company",
workWeek = new[] { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" },
workingTime = new[] { new { from = 9, to = 12 }, new { from = 13, to = 17 } },
holidays = new[]
{
new
{
from = new DateTime(2026, 4, 10),
to = new DateTime(2026, 4, 10),
label = "Company closure"
}
},
exceptions = new[]
{
new
{
from = new DateTime(2026, 4, 17),
to = new DateTime(2026, 4, 17),
label = "Company partial working day",
exceptionWorkingTime = new[] { new { from = 9, to = 12 } }
}
}
},
new
{
calendarId = "regional",
parentId = "company"
}
}))
.Render())public class HomeController : Controller
{
public ActionResult Index()
{
ViewBag.DataSource = GetTaskCollection();
return View();
}
public static List<GanttDataSource> GetTaskCollection()
{
return new List<GanttDataSource>()
{
new GanttDataSource
{
TaskId = 1,
TaskName = "Company Schedule",
StartDate = new DateTime(2026, 4, 2),
Duration = 30,
CalendarId = "company"
},
new GanttDataSource
{
TaskId = 2,
TaskName = "Regional Inherited Schedule",
StartDate = new DateTime(2026, 4, 2),
Duration = 30,
CalendarId = "regional"
},
new GanttDataSource
{
TaskId = 3,
TaskName = "Project Calendar Schedule",
StartDate = new DateTime(2026, 4, 2),
Duration = 30
}
};
}
public class GanttDataSource
{
public int TaskId { get; set; }
public string TaskName { get; set; }
public DateTime? StartDate { get; set; }
public int? Duration { get; set; }
public string CalendarId { get; set; }
}
}Configure recurring holidays and exceptions
The Recurrence property defaults to null. Set it on a holiday or calendar exception to repeat the record from the anchor From date. To defines the inclusive source span repeated for every occurrence. If To is omitted, only the anchor date is repeated. These options are configured through the Gantt CalendarSettings API.
Use Count to limit the number of occurrence starts or Until to set an inclusive termination date. Do not use Count and Until together.
Recurrence properties
| Property | Type | Default | Purpose |
|---|---|---|---|
Frequency |
daily | weekly | monthly | yearly
|
null |
Required recurrence pattern. |
Interval |
number |
1 |
Positive number of frequency periods between starts. |
DaysOfWeek |
DayOfWeek[] |
null |
Unique weekday names from Sunday through Saturday for weekly or ordinal recurrence. |
DayOfMonth |
number | "last"
|
null |
Day for monthly or yearly recurrence. |
WeekOfMonth |
number | "last"
|
null |
Ordinal week used with exactly one weekday. |
Month |
number |
null |
Month number from 1 to 12 for yearly recurrence. |
Count |
number |
null |
Positive number of occurrence starts, including the anchor. |
Until |
Date | string
|
null |
Inclusive termination date for occurrence starts. |
Recurrence pattern examples
The examples below show the recurrence object configured in the MVC helper; set the record’s from date to match the selected weekday, day, ordinal, or month.
| Pattern | Example |
|---|---|
| Daily | { frequency: "daily", interval: 1 } |
| Weekly on Monday and Wednesday | { frequency: "weekly", daysOfWeek: ["Monday", "Wednesday"] } |
| Second Monday of each month | { frequency: "monthly", daysOfWeek: ["Monday"], weekOfMonth: 2 } |
| April 10 each year | { frequency: "yearly", month: 4, dayOfMonth: 10 } |
| February 29 each year |
{ frequency: "yearly", month: 2, dayOfMonth: 29 } — occurrences are skipped in non-leap years. |
For a weekly recurrence, use { frequency: "weekly", daysOfWeek: ["Monday"], count: 8 } or { frequency: "weekly", daysOfWeek: ["Monday"], until: new Date(2026, 5, 30) } as the end condition.
Use Count or Until, but not both. Selectors must match their frequency: DaysOfWeek contains unique, case-sensitive weekday names from Sunday through Saturday; monthly or yearly ordinal rules use exactly one weekday with WeekOfMonth set to 1-4 or "last"; DayOfMonth is 1-31 or "last"; and yearly Month is 1-12. Do not combine DayOfMonth with DaysOfWeek or WeekOfMonth. When recurrence is configured, From is required and must match any specified weekday, day, ordinal, or yearly month. If supplied, To must be the same as or later than From. Interval and Count must be positive integers; Until must be a valid date not before From.
Recurrence dates are parsed as dates and normalized using local date interpretation. Date-only values can behave differently across environment time zones, so provide dates consistently when working across time zones.
Recurrence is evaluated only as needed for the scheduling window and repeats the source From-To span.
For monthly rules on day 29-31, months without the selected day are skipped; a yearly February 29 rule skips non-leap years. Skipped dates do not consume Count. On initialization, an invalid recurrence with valid source dates is reported through actionFailure and treated as a one-time fixed-date rule; a record with invalid dates is skipped. If an invalid recurrence is introduced by a calendar update, actionFailure reports the error and the previous calendar configuration is retained.
The following sample demonstrates a holiday repeated three times using Count and a partial working-day exception repeated through June 17 using Until:
@using Syncfusion.EJ2.Gantt
@(Html.EJS().Gantt("Gantt")
.DataSource((IEnumerable<object>)ViewBag.DataSource)
.Height("450px")
.ProjectStartDate("04/01/2026")
.ProjectEndDate("06/30/2026")
.TaskFields(ts => ts
.Id("TaskId")
.Name("TaskName")
.StartDate("StartDate")
.Duration("Duration")
.CalendarId("CalendarId"))
.LabelSettings(ls => ls.LeftLabel("TaskName"))
.CalendarSettings(cs => cs
.ProjectCalendar(pc => pc.WorkingTime(new List<object>
{
new { from = 8, to = 17 }
}))
.TaskCalendars(new List<object>
{
new
{
calendarId = "regional",
workWeek = new[] { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" },
workingTime = new[] { new { from = 9, to = 12 }, new { from = 13, to = 17 } },
holidays = new[]
{
new
{
from = new DateTime(2026, 4, 10),
to = new DateTime(2026, 4, 10),
label = "Regional closure",
recurrence = new
{
frequency = "monthly",
interval = 1,
dayOfMonth = 10,
count = 3
}
}
},
exceptions = new[]
{
new
{
from = new DateTime(2026, 4, 17),
to = new DateTime(2026, 4, 17),
label = "Partial working day",
exceptionWorkingTime = new[] { new { from = 9, to = 12 } },
recurrence = new
{
frequency = "monthly",
interval = 1,
dayOfMonth = 17,
until = new DateTime(2026, 6, 17)
}
}
}
}
}))
.Render())public class HomeController : Controller
{
public ActionResult Index()
{
ViewBag.DataSource = GetTaskCollection();
return View();
}
public static List<GanttDataSource> GetTaskCollection()
{
return new List<GanttDataSource>()
{
new GanttDataSource
{
TaskId = 1,
TaskName = "Recurring Regional Schedule",
StartDate = new DateTime(2026, 4, 2),
Duration = 30,
CalendarId = "regional"
},
new GanttDataSource
{
TaskId = 2,
TaskName = "Project Calendar Schedule",
StartDate = new DateTime(2026, 4, 2),
Duration = 30
}
};
}
public class GanttDataSource
{
public int TaskId { get; set; }
public string TaskName { get; set; }
public DateTime? StartDate { get; set; }
public int? Duration { get; set; }
public string CalendarId { get; set; }
}
}Calendar limitations
- A task calendar cannot represent zero working weekdays with
WorkWeek: []. - Recurrence expansion extends up to 100 years after the scheduling evaluation window ends; occurrences beyond that period are not generated.
- No resource-specific calendar lookup is available.
Configure hours per day for task durations
The HoursPerDay property defines the number of hours used to represent one day when calculating task durations. Changing HoursPerDay recalculates day-based duration values using the existing working duration of the task. This affects how duration is displayed and calculated in days, but does not modify the task’s start date, end date, or underlying working duration.
For example, a task with 32 hours of working duration is displayed as 4 days when HoursPerDay is set to 8. If HoursPerDay is changed to 16, the same task is displayed as 2 days. The task schedule remains unchanged because the underlying working duration is not modified.
The following example demonstrates how changing HoursPerDay affects duration calculations.
@using Syncfusion.EJ2.Gantt
@using Syncfusion.EJ2.Buttons
@(Html.EJS().Button("updateHoursPerDay")
.Content("Update Hours Per Day")
.Render())
@(Html.EJS().Gantt("Gantt")
.DataSource((IEnumerable<object>)ViewBag.DataSource)
.Height("450px")
.HoursPerDay(8)
.ProjectStartDate("04/01/2026")
.ProjectEndDate("04/30/2026")
.TaskFields(ts => ts
.Id("TaskId")
.Name("TaskName")
.StartDate("StartDate")
.Duration("Duration")
.ParentID("ParentId"))
.LabelSettings(ls => ls.LeftLabel("TaskName"))
.CalendarSettings(new
{
projectCalendar = new
{
workingTime = new object[]
{
new { from = 9, to = 12 },
new { from = 13, to = 17 }
},
exceptions = new object[]
{
new
{
from = new DateTime(2026, 4, 6),
to = new DateTime(2026, 4, 6),
label = "Extended Working Day"
}
}
}
})
.Render())
<script>
document.getElementById('updateHoursPerDay').addEventListener('click', function () {
var gantt = document.getElementById('Gantt').ej2_instances[0];
gantt.hoursPerDay = 16;
});
</script>public class HomeController : Controller
{
public ActionResult Index()
{
ViewBag.DataSource = GetTaskCollection();
return View();
}
public static List<GanttDataSource> GetTaskCollection()
{
return new List<GanttDataSource>()
{
new GanttDataSource
{
TaskId = 1,
TaskName = "Project Planning",
StartDate = new DateTime(2026, 4, 2),
Duration = 3
},
new GanttDataSource
{
TaskId = 2,
TaskName = "Requirements Analysis",
StartDate = new DateTime(2026, 4, 5),
Duration = 2,
ParentId = 1
},
new GanttDataSource
{
TaskId = 3,
TaskName = "Design",
StartDate = new DateTime(2026, 4, 7),
Duration = 4,
ParentId = 1
},
new GanttDataSource
{
TaskId = 4,
TaskName = "Development",
StartDate = new DateTime(2026, 4, 11),
Duration = 5
},
new GanttDataSource
{
TaskId = 5,
TaskName = "Testing",
StartDate = new DateTime(2026, 4, 16),
Duration = 3
}
};
}
public class GanttDataSource
{
public int TaskId { get; set; }
public string TaskName { get; set; }
public DateTime? StartDate { get; set; }
public int? Duration { get; set; }
public int? ParentId { get; set; }
}
}Note: The default
hoursPerDayvalue is 8 hours. When a task has 4 days duration with thehoursPerDayvalue of 6, the total working hours = 4 days × 6 hours = 24 hours. If the calendar’s working time is configured as 24 hours (0:00 to 24:00), these 24 hours fit within a single calendar day, so the task displays as 1 calendar day on the chart, even though the duration specification is 4 days.
Impact on task scheduling
Calendar settings directly affect how task duration is calculated and when tasks are scheduled. Changes recalculate task schedules, durations, dependencies, and chart rendering.
- Working hours: Task durations are calculated using the configured working hours. Non-working hours are excluded from duration calculations.
- Holidays: Tasks skip over holiday dates, extending the end date accordingly to maintain the required working duration
-
Weekends: By default, weekends are treated as non-working days when
IncludeWeekendis set to false - Task dependencies: Dependency calculations use the predecessor task’s calendar to determine when the successor task can start
-
Task calendars: If no task calendar matches the task’s
CalendarId, the project calendar’s configured working days, working hours, holidays, and exceptions apply. If one matches, Gantt applies that task calendar to the task. Settings it does not define may come from task-calendar inheritance or project working-time fallback. Fixed project holidays and exceptions do not apply to that task; a recurring project holiday can apply only when no rule in its task-calendar chain covers the date. -
Duration calculations: Changing
HoursPerDayrecalculates day-based duration values without changing the scheduled start and end dates.