Description: nonworkingHours determine the non working Hours of the day. Similar to nonworkingDays they are also ignored in the task start/end date calculations. Also colored in gray. Drag and Drop a task inside the timeline to see how the Task Bar changes according to the new added/removed slack time.
JavaScript Gantt with non working hours.
A live JavaScript/jQuery example of jqxGantt, the jQWidgets Gantt component, with its complete source code below. It is one of 15 jqxGantt demos for jQuery.
source property – Determines the tasks that will be loaded inside the Timeline.dateEnd property – Determines a specific end date for the Timeline.dateStart property – Determines a specific starting date for the Timeline.nonworkingHours property – Determines the nonworking hours of a day.tasks property – A getter that returns a flat structure as an array of all tasks inside the element.view property – Determines the viewing date range of the timeline.To run it in your own page, load jqx.base.css, a theme and the library files below from npm (npm install jqwidgets-scripts) or the jsDelivr CDN, then add the markup and the script. jQuery is not required: jqxcore.js provides $.
The page loads jqx.base.css, a theme and these library files: jqxcore.js, jqxgantt.js, jqxgantt.api.js.
It also loads helper scripts of this demo site, which are not part of the library: demos.js (getWidth() and other layout helpers).
window.onload = () => {
const gantt = new jqxGantt("#gantt", {
height: 'auto',
view: 'day',
nonworkingHours: [22, 23, 0, 1, 2, 3, 4, 5, 6],
source: [{
label: 'Project 1',
dateStart: '2026-02-14T12:30:00',
dateEnd: '2026-02-16T3:59:00',
type: 'project',
expanded: true,
connections: [
{
target: 1,
type: 0
}
],
tasks: [
{
label: 'Task 1.1',
dateStart: '2026-02-20',
dateEnd: '2026-02-24',
type: 'task',
connections: [
{
target: 2,
type: 1
},
{
target: 4,
type: 1
}
]
},
{
label: 'Task 1.2',
dateStart: '2026-2-15',
dateEnd: '2026-2-25',
type: 'task',
connections: [
{
target: 3,
type: 1
}
]
}
]
},
{
label: 'Task 2',
dateStart: '2026-02-17T15:30:00',
dateEnd: '2026-02-26T15:30:00',
type: 'task'
},
{
label: 'Milestone 1',
dateEnd: '2026-02-20',
type: 'milestone',
connections: [
{
target: 5,
type: 1
}
]
},
{
label: 'Task 3',
dateStart: '2026-02-14T1:00:00',
dateEnd: '2026-02-14T18:30:00',
progress: 50,
type: 'task'
}
]
});
};
<div>
<p>
<b>Description:</b> <b>nonworkingHours</b> determine the non working Hours of the day. Similar to
nonworkingDays they are also ignored in the task start/end date calculations. Also colored in gray. Drag and
Drop a task inside the timeline to see how the Task Bar changes according to the new added/removed slack
time.
</p>
</div>
<div id="gantt"></div>
<div style="position: absolute; bottom: 5px; right: 5px;">
<a href="https://www.jqwidgets.com/" alt="https://www.jqwidgets.com/"><img alt="https://www.jqwidgets.com/" title="https://www.jqwidgets.com/" src="https://www.jqwidgets.com/wp-content/design/i/logo-jqwidgets.png"></a>
</div>