Having trouble getting help?
Contact Support
Contact Support
Holidays in EJ2 JavaScript Gantt control
2 May 20233 minutes to read
Non-working days in a project can be displayed in the Gantt control using the holidays
property. Each holiday can be defined with the following properties:
-
from
: Defines start date of the holiday(s). -
to
: Defines end date of the holiday(s). -
label
: Defines the description or label for the holiday. -
cssClass
: Formats the holidays label in the Gantt chart.
To highlight the holidays, inject the DayMarkers
module into the Gantt control.
The following code example shows how to display the non-working days in the Gantt control.
ej.gantt.Gantt.Inject(ej.gantt.DayMarkers);
var ganttChart = new ej.gantt.Gantt({
dataSource: GanttData,
height:'450px',
taskFields: {
id: 'TaskID',
name: 'TaskName',
startDate: 'StartDate',
duration: 'Duration',
progress: 'Progress',
child: 'subtasks'
},
holidays: [{
from: "04/04/2019",
to:"04/05/2019",
label: " Public holidays",
cssClass:"e-custom-holiday"
},
{
from: "04/12/2019",
to:"04/12/2019",
label: " Public holiday",
cssClass:"e-custom-holiday"
}]
});
ganttChart.appendTo('#Gantt');
<!DOCTYPE html><html lang="en"><head>
<title>EJ2 Gantt</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Typescript Gantt Controls">
<meta name="author" content="Syncfusion">
<link href="index.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/29.1.33/material.css" rel="stylesheet" type="text/css">
<style>
.e-gantt .e-gantt-chart .e-custom-holiday {
background-color:#e82869;
}
</style>
<script src="https://cdn.syncfusion.com/ej2/29.1.33/dist/ej2.min.js" type="text/javascript"></script>
<script src="es5-datasource.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="Gantt"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>