Documentation
A resource is someone or something that does the work: a person, a team, a machine, a room. In jqxGantt each task can name the resources that work on it. The chart then shows a resource panel under the tasks: one row for each resource, and a timeline of how many hours it works each day, in red where that is more than it has.
This page assigns four people to a two-week plan, reads their workload, finds who is over-allocated, groups the tasks by person and changes the resources with methods. It builds on the getting-started guide, which shows how to load the files, describe tasks and change them with methods. Each example is a complete page.
A task's resources field names the resources that work on it. It takes a resource object, a resource id, or an array of either. The first time a resource appears, describe it with an object; after that, its id is enough:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jqxGantt: people assigned to tasks</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27/jqwidgets/styles/jqx.base.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27/jqwidgets/styles/gantt/jqx.gantt.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27/jqwidgets/styles/jqx.fluent.css">
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27/jqwidgets/jqxcore.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27/jqwidgets/jqxgantt.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27/jqwidgets/jqxgantt.api.js"></script>
<style>
/* Narrower day columns, so that two weeks fit the page, and nonworking days in the
theme's colours (the Gantt stylesheet gives them a fixed light grey). */
#gantt {
--jqx-gantt-chart-timeline-cell-min-size: 34px;
--jqx-gantt-chart-timeline-nonworking-color: color-mix(in srgb, var(--jqx-background-color) 9%, var(--jqx-background));
--jqx-gantt-chart-timeline-weekend-color: var(--jqx-background);
}
</style>
</head>
<body>
<div id="gantt"></div>
<script type="module">
// Four people work on a two-week plan. A task's resources field names its people.
const tasks = [
{
id: 'wireframes', type: 'task', label: 'Wireframes', dateStart: '2026-04-06T00:00:00', dateEnd: '2026-04-09T00:00:00', progress: 100,
// A resource object: the first task that names a resource describes it.
resources: { id: 'ana', label: 'Ana', capacity: 8, maxCapacity: 8 }
},
{
id: 'visual', type: 'task', label: 'Visual design', dateStart: '2026-04-09T00:00:00', dateEnd: '2026-04-17T00:00:00', progress: 40,
// An id: the same resource again.
resources: 'ana'
},
{
id: 'api', type: 'task', label: 'API', dateStart: '2026-04-06T00:00:00', dateEnd: '2026-04-15T00:00:00', progress: 60,
resources: [{ id: 'chloe', label: 'Chloe', capacity: 8, maxCapacity: 8 }]
},
{
id: 'frontend', type: 'task', label: 'Front end', dateStart: '2026-04-08T00:00:00', dateEnd: '2026-04-18T00:00:00', progress: 20,
resources: [{ id: 'ben', label: 'Ben', capacity: 6, maxCapacity: 8 }]
},
{ id: 'content', type: 'task', label: 'Content entry', dateStart: '2026-04-13T00:00:00', dateEnd: '2026-04-15T00:00:00', resources: ['ben'] },
{
id: 'testing', type: 'task', label: 'Testing', dateStart: '2026-04-15T00:00:00', dateEnd: '2026-04-18T00:00:00',
// An array: several resources, as objects or ids.
resources: [{ id: 'dan', label: 'Dan', capacity: 6, maxCapacity: 8 }, 'chloe']
}
];
const gantt = new jqxGantt('#gantt', {
theme: 'fluent',
width: '100%',
height: 'auto',
view: 'week',
dayFormat: 'narrow',
nonworkingDays: [0, 6],
adjustToNonworkingTime: true,
durationUnit: 'day',
treeSize: '36%',
// The resource panel's height in pixels: its header and four rows.
resourcePanelSize: 152,
taskColumns: [
{ label: 'Task', value: 'label', size: '58%' },
{
label: 'Owner',
value: 'resources',
// The value is the task's list of resource ids; show their labels.
formatFunction: (ids) => ids.map((id) => gantt.getResource(id).label).join(', ')
}
],
resourceColumns: [
{ label: 'Name', value: 'label', size: '40%' },
{ label: 'Done', value: 'progress', formatFunction: (value) => value + '%' },
{ label: 'Work', value: 'workload', formatFunction: (value) => value + ' h' }
],
source: tasks
});
</script>
</body>
</html>
There is no list of resources apart from the tasks: new jqxGantt('#gantt', { resources: [...] }) throws Invalid property: resources. The chart collects the resources from the tasks' resources fields, in the order in which they first appear, and keeps each field as a list of ids: getTask('testing').resources is ['dan', 'chloe']. To add a resource that has no tasks yet, use insertResource.
A task column whose value is 'resources' shows the ids, separated by commas. Its formatFunction receives the list of ids, so the Owner column above turns them into labels with getResource.
The plan is drawn in the week view, one column per day, with Saturday and Sunday as nonworking days. A dateEnd of '2026-04-09T00:00:00' ends a task at midnight at the start of April 9, so Wireframes takes Monday to Wednesday. adjustToNonworkingTime: true keeps the weekends out of the hours: without it, Visual design counts 8 hours on Saturday and Sunday too. The working time page explains both options. The page's stylesheet narrows the day columns so that the two weeks fit, and resourcePanelSize makes the panel as tall as its four rows (see The resource panel).
A resource object can have these fields. getResources() returns copies of the resources with these fields, the calculated ones included:
| Field | Meaning |
|---|---|
id | The name that tasks and methods use to find the resource. Required: an object without an id is not taken as a resource. |
label | The text in the resource panel |
capacity | The hours a day the resource spends on each of its tasks. 8 when not given. |
maxCapacity | The hours a day the resource has. More than this is drawn in red. 24 when not given, so set it. |
minCapacity | Kept with the resource (0 when not given), but the chart does not use it |
class | A CSS class for the resource's cells in the resource timeline |
progress | Calculated: the average progress of the resource's tasks, each task counting once whatever its length. A value you give is replaced. |
workload | Calculated: the number of days of the resource's tasks times its maxCapacity. A value you give is ignored. |
In the plan above, Ana's two tasks are 100% and 40% done, so her Done column shows 70%. Ben's tasks take 8 and 2 working days, so his Work is 10 × 8 = 80 hours. Note that workload uses maxCapacity, not capacity: it is the hours Ben would work at his maximum, not the 60 hours he is booked for. To show the booked hours, count them yourself, as in Find who is over-allocated.
The panel appears under the tasks as soon as one resource exists. Its tree on the left lists the resources, and its timeline on the right has the same columns as the task timeline. These options set it up:
| Option | What it does |
|---|---|
hideResourcePanel | true hides the panel, even when there are resources |
resourceColumns | The columns of the panel's tree, like taskColumns: label, value (a resource field), size and formatFunction. One column, Resource Name, when not given. |
resourcePanelSize | The height of the panel |
resourcePanelMin | The smallest height that users can give the panel by dragging the splitter above it (100 by default) |
resourcePanelHeaderTemplate | A row above the panel: a function that fills the header element it receives, a <template> element, or the id of one |
resourceFiltering | A filter row under the column headers |
resourcePanelRefreshRate | While users drag or resize a task, the panel is updated this many milliseconds after the pointer stops (0 by default: at once) |
This page uses all of them but the first:
const gantt = new jqxGantt('#gantt', {
theme: 'fluent',
width: '100%',
height: 500,
view: 'week',
dayFormat: 'narrow',
nonworkingDays: [0, 6],
adjustToNonworkingTime: true,
durationUnit: 'day',
treeSize: '36%',
// The panel's height (a percentage of a fixed chart height), and the smallest height
// that users can give it with the splitter above it.
resourcePanelSize: '46%',
resourcePanelMin: 120,
// A row above the panel: the function fills the header element.
resourcePanelHeaderTemplate: (header) => {
header.innerHTML = '<span class="team-header">Team: hours per day; red is more than the person has</span>';
},
// A filter row under the column headers.
resourceFiltering: true,
// While a task is dragged or resized, update the panel 300 ms after the pointer stops.
resourcePanelRefreshRate: 300,
resourceColumns: [
{ label: 'Name', value: 'label', size: '50%' },
{ label: 'Work', value: 'workload', formatFunction: (value) => value + ' h' }
],
source: tasks
});
Typing in the filter row keeps the resources whose value in that column contains the text, in the tree and in the timeline. With a fixed chart height, give resourcePanelSize as a percentage: in 27.1.0 and earlier a number of pixels is ignored, and the panel gets its resourcePanelMin. With height: 'auto', a number of pixels works.
Each cell of the resource timeline shows the load of one resource on one day, worked out from the tasks it has that day. Two options decide what the load is and how it is drawn:
| Option | Value | What it does |
|---|---|---|
resourceTimelineView | 'hours' (default) | The load is the hours worked: capacity for each task that day. It is red when it is more than maxCapacity. |
'tasks' | The load is the number of tasks, compared with maxCapacity. It counts every day the task spans, nonworking days too. | |
'custom' | resourceTimelineFormatFunction returns the load | |
resourceTimelineMode | 'diagram' (default) | A circle with the load: green, or red over maxCapacity |
'histogram' | A bar as high as the load is part of maxCapacity, labelled load/maxCapacity (12/8) | |
'custom' | The HTML that resourceTimelineFormatFunction returns |
The load is counted per timeline cell. Use the week view, which has a cell per day, or the month view with monthScale: 'week', which has a cell per week and shows the hours of the week. In 27.1.0 and earlier the month view with its default day cells counts a whole week in every day cell.
resourceTimelineMode: 'histogram' draws the same loads as bars. A full bar is a full day; Ben's 6-hour days fill three quarters of his row, and his 12-hour days are red:
The hours view gives a resource the same hours on every task. When a person spends different hours on different tasks, keep the hours on the tasks and return the load from resourceTimelineFormatFunction with resourceTimelineView: 'custom'. In this page each task has an hours field (Content entry takes 3 hours a day), and the buttons switch the view and the mode:
const gantt = new jqxGantt('#gantt', {
theme: 'fluent',
width: '100%',
height: 'auto',
view: 'week',
dayFormat: 'narrow',
nonworkingDays: [0, 6],
adjustToNonworkingTime: true,
treeSize: '30%',
// The resource panel's height in pixels: its header and four rows.
resourcePanelSize: 152,
resourceTimelineView: 'custom',
resourceTimelineMode: 'histogram',
// Called for each resource, day and task, with the resource's tasks in the cell so far
// (their indexes in getTasks()); the chart adds up the capacities that the calls return.
resourceTimelineFormatFunction: (taskIndexes, resourceIndex, cellDate) => {
if (cellDate.getDay() === 0 || cellDate.getDay() === 6) {
return null;
}
const task = gantt.getTasks()[taskIndexes[taskIndexes.length - 1]];
return { capacity: task.hours, maxCapacity: 8 };
},
source: tasks
});
The function receives the indexes of tasks in getTasks(), the index of the resource, and the date of the cell. The chart calls it once for each task of the resource in the cell, each time with the tasks found so far, and adds up the capacity values of the objects it returns. So return the hours of the last task in the list: returning the hours of all of them counts the first task again on every call (6 + 9 = 15 for Ben). The second value, maxCapacity, is the limit for the red colour and the full bar. Return null for a cell without load: in this view the chart calls the function for weekends too.
The function can also return a single value instead of an object. The cell then shows that value from the last call, without the red colour, and the histogram draws no bar.
With resourceTimelineMode: 'custom', a cell shows the HTML that resourceTimelineFormatFunction returns. Here it is a letter for each task, in the task's colour:
const gantt = new jqxGantt('#gantt', {
theme: 'fluent',
width: '100%',
height: 'auto',
view: 'week',
dayFormat: 'narrow',
nonworkingDays: [0, 6],
adjustToNonworkingTime: true,
treeSize: '30%',
// The resource panel's height in pixels: its header and four rows.
resourcePanelSize: 152,
resourceTimelineMode: 'custom',
// The cell shows the HTML that the function returns: a letter for each task.
resourceTimelineFormatFunction: (taskIndexes, resourceIndex, cellDate) => {
const all = gantt.getTasks();
return taskIndexes
.map((index) => `<span class="slot ${all[index].class}" title="${all[index].label}">${all[index].label[0]}</span>`)
.join('');
},
source: tasks
});
The cells still follow resourceTimelineView: a cell exists only where the view finds a load (here, the hours of working days), and the load circle is drawn as well. This rule in the page's stylesheet hides the circle:
/* In custom mode the chart still draws the load circle; this page shows only its own content. */
#gantt .jqx-resource-timeline-view-cell::after {
display: none;
}
The chart marks an over-allocated day in red but has no method that lists them. With getResources() and getResourceTasks(id) the same rule takes a few lines: on each working day, a resource's capacity times its number of tasks that day must not be more than its maxCapacity. This page draws the histogram above and lists what it finds under the chart:
// The chart's rule: on a day, a resource is over-allocated when its capacity times the
// number of its tasks that day is more than its maxCapacity.
function overAllocations() {
const found = [];
for (const resource of gantt.getResources()) {
const assigned = gantt.getResourceTasks(resource.id);
const first = new Date(Math.min(...assigned.map((task) => task.dateStart)));
const last = new Date(Math.max(...assigned.map((task) => task.dateEnd)));
for (const day = first; day < last; day.setDate(day.getDate() + 1)) {
if (day.getDay() === 0 || day.getDay() === 6) {
continue;
}
const next = new Date(day.getFullYear(), day.getMonth(), day.getDate() + 1);
const count = assigned.filter((task) => task.dateStart < next && task.dateEnd > day).length;
const hours = count * resource.capacity;
if (hours > resource.maxCapacity) {
const date = day.toLocaleDateString('en', { weekday: 'short', month: 'short', day: 'numeric' });
found.push(`${resource.label}: ${hours} of ${resource.maxCapacity} h on ${date}`);
}
}
}
return found;
}
When the page opens, the list reads Over-allocated: Ben: 12 of 8 h on Mon, Apr 13; Ben: 12 of 8 h on Tue, Apr 14. To fix it, give Content entry to Dan, who is free on those days. updateTask changes a task's resources like any other field, and the panel follows:
// Assign the task to someone else: set its resources field.
document.getElementById('reassign').addEventListener('click', () => {
gantt.updateTask('content', { resources: ['dan'] });
showOverAllocations();
});
After the click Ben's bars are all 6/8, Dan's start on April 13, and the list reads Nobody is over-allocated.
groupByResources: true puts each task under a group row for its resources. Tasks with the same resources share a group: Testing, done by Chloe and Dan together, gets a group of its own, and tasks without resources go to a group labelled Unassigned. The groups follow the order in which the resources first appear. resourceGroupFormatFunction receives the ids of a group's resources and returns its label:
const gantt = new jqxGantt('#gantt', {
theme: 'fluent',
width: '100%',
height: 'auto',
view: 'week',
dayFormat: 'narrow',
nonworkingDays: [0, 6],
adjustToNonworkingTime: true,
treeSize: '34%',
groupByResources: true,
// In 27.1.0 and earlier, grouping works only without the resource panel.
hideResourcePanel: true,
// ids: the resource ids of the group; [''] for the tasks without resources.
resourceGroupFormatFunction: (ids) => ids[0] ? ids.map((id) => gantt.getResource(id).label).join(' and ') : 'Not assigned yet',
source: tasks
});
The function labels only the group rows of the tree; the bars in the timeline show the resources' labels joined with commas (Chloe, Dan), or Unassigned. For the tasks without resources the function receives [''].
In 27.1.0 and earlier, grouping needs hideResourcePanel: true, as above. With the panel visible, the chart logs Group field name is not found in the dataFields collection!, throws an error, and the panel shows an empty group instead of the resources. Set groupByResources when you create the chart: it can be turned off later, but turning it on again does not group the tasks.
The methods that read resources and select them belong to the widget (see Options and methods). The ones that add, change and remove a resource exist only on the chart's jqx-gantt-chart element: in 27.1.0 and earlier jqxGantt has no insertResource, updateResource or removeResource.
| Method | On | What it does |
|---|---|---|
insertResource(resource), insertResource(index, resource) | chart element | Adds a resource at the end, or at an index. A resource without tasks gets an empty row. An id that exists updates that resource instead. |
updateResource(id, fields) | chart element | Changes the fields it is given |
removeResource(id) | chart element | Removes a resource |
getResource(id) | both | A copy of the resource, or undefined |
getResources() | both | Copies of all resources, in the panel's order |
getResourceIndex(resource) | both | The position of a resource, given the object (an id returns -1) |
getResourceTasks(id) | both | Copies of the tasks assigned to the resource |
clearResources() | both | Removes every resource, empties every task's resources field and hides the panel |
selectResource(id), unselectResource(id) | both | Selects or unselects a resource, and with it its tasks |
getSelectedResources() | both | Copies of the selected resources |
Each button of this page runs one of them on the same plan:
<p>
<button type="button" id="insert">Add Eve to Content entry</button>
<button type="button" id="update">Ben: 4 hours a day</button>
<button type="button" id="remove">Remove Dan</button>
<button type="button" id="select">Select Ben</button>
<button type="button" id="clear">Remove all</button>
</p>
<div id="gantt"></div>
<p id="status"></p>
// insertResource, updateResource and removeResource are methods of the chart element.
const chart = document.querySelector('#gantt jqx-gantt-chart');
const status = document.getElementById('status');
// Each resource with its position and its tasks.
const showResources = () => {
const list = gantt.getResources().map((resource) => {
const labels = gantt.getResourceTasks(resource.id).map((task) => task.label);
return `${gantt.getResourceIndex(resource)}: ${resource.label} (${labels.join(', ') || 'no tasks'})`;
});
status.textContent = list.length ? list.join('; ') : 'No resources';
};
chart.whenReady(showResources);
When the page opens, the status line reads 0: Ana (Wireframes, Visual design); 1: Chloe (API, Testing); 2: Ben (Front end, Content entry); 3: Dan (Testing).
// Add a resource, then assign it: a task's resources field lists resource ids.
document.getElementById('insert').addEventListener('click', () => {
chart.insertResource({ id: 'eve', label: 'Eve', capacity: 4, maxCapacity: 8 });
gantt.updateTask('content', { resources: ['ben', 'eve'] });
showResources();
});
// In 27.1.0 and earlier, updateResource and removeResource do not redraw the resource
// timeline correctly by themselves. Between beginUpdate and endUpdate, the chart
// redraws once, at the end.
document.getElementById('update').addEventListener('click', () => {
gantt.beginUpdate();
chart.updateResource('ben', { capacity: 4 });
gantt.endUpdate();
showResources();
});
// removeResource keeps the id in the tasks' resources fields: take it out there first.
document.getElementById('remove').addEventListener('click', () => {
for (const task of gantt.getResourceTasks('dan')) {
gantt.updateTask(task.id, { resources: task.resources.filter((id) => id !== 'dan') });
}
gantt.beginUpdate();
chart.removeResource('dan');
gantt.endUpdate();
showResources();
});
// Selecting a resource also selects its tasks.
document.getElementById('select').addEventListener('click', () => {
gantt.selectResource('ben');
const selected = gantt.getSelectedResources().map((resource) => resource.label);
status.textContent = `Selected: ${selected.join(', ')}; their tasks: ${gantt.getSelectedIds().task.join(', ')}`;
});
document.getElementById('clear').addEventListener('click', () => {
gantt.clearResources();
showResources();
});
Three of these need care in 27.1.0 and earlier:
updateResource changes the resource and its row in the tree, but not its row in the resource timeline: after updateResource('ben', { capacity: 4 }) the circles still show 6. Between beginUpdate() and endUpdate() the chart redraws everything once, at the end, and the circles show 4.removeResource leaves an empty row in the resource timeline, so the rows under it no longer line up with their names. Call it between beginUpdate() and endUpdate() too. It also leaves the id in the tasks' resources fields, where a resource with that id inserted later would find its old tasks again; the page takes the id out with updateTask first.getSelectedIds() returns { task, resources }: after Select Ben, task is ['frontend', 'content']. Users select a resource by clicking its row, which selects its tasks too.The selectedResourceIds option sets and reads the selected resources by id. Set it once the chart is ready: given to new jqxGantt, the resource is reported as selected but not drawn as selected. When users click a row, the widget's selectedResourceIds stays as it was; read getSelectedResources() instead.
A resource can also be inserted and assigned in one step: an assignedTo field with a task id or a list of them, as in chart.insertResource({ id: 'eve', label: 'Eve', assignedTo: ['content'] }), adds the resource to those tasks.