Search results

Holidays in JavaScript Gantt control

23 Mar 2023 / 1 minute 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.

Copied to clipboard
import { Gantt, DayMarkers } from '@syncfusion/ej2-gantt';
import { GanttData } from 'datasource.ts';


let gantt: Gantt = new 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"

Copied to clipboard
<!DOCTYPE html>
<html lang="en">

    <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="" rel="stylesheet" type="text/css"/>
    <script src=""></script>
    <script src="systemjs.config.js"></script>
	.e-gantt .e-gantt-chart .e-custom-holiday {

    <div id='loader'>Loading....</div>
    <div id="container">
        <div id="Gantt"></div>