Documentation
This page shows how to change the way jqxGantt draws its tasks: the colour of each bar, a progress label, the planned dates under a bar, deadlines and other marked dates, a task split into pieces, your own content in a bar, tooltips, a header bar, and themes.
Each example is a complete page that loads jQWidgets 27 from the CDN, as in the getting-started guide. The guide explains the files, the task fields and the methods used here; this page adds only what changes the look.
The chart takes its colours from CSS variables. Set a variable on #gantt to change it for the whole chart, or on a class to change it for some tasks. The class field of a task is added to its bar element, next to the chart's own task, project or milestone class, so a rule such as #gantt .build reaches the bar. Give a task one class name: in 27.1.0 and earlier a value with a space, such as 'test late', stops the chart with the error The token provided ('test late') contains HTML space characters.
This page uses one class for each kind of work, and changes the row height, the corners, and the colours of projects and milestones for the whole chart:
/* The whole chart: taller rows, rounded bars, projects and milestones */
#gantt {
--jqx-gantt-chart-task-default-height: 36px;
--jqx-gantt-chart-task-fill-border-radius: 6px;
--jqx-gantt-chart-project-color: #334155;
--jqx-gantt-chart-project-label-color: #ffffff;
--jqx-gantt-chart-project-label-color-selected: #ffffff;
--jqx-gantt-chart-project-progress-color: rgba(255, 255, 255, .25);
--jqx-gantt-chart-milestone-color: #c2413d;
}
/* One class for each kind of work */
#gantt .design {
--jqx-gantt-chart-task-color: #ffc535;
--jqx-gantt-chart-task-label-color: #1f2937;
--jqx-gantt-chart-task-label-color-selected: #1f2937;
}
#gantt .build {
--jqx-gantt-chart-task-color: #5e63b5;
--jqx-gantt-chart-task-label-color: #ffffff;
--jqx-gantt-chart-task-label-color-selected: #ffffff;
--jqx-gantt-chart-task-progress-color: rgba(0, 0, 0, .3);
}
#gantt .test {
--jqx-gantt-chart-task-color: #2f7d5b;
--jqx-gantt-chart-task-label-color: #ffffff;
--jqx-gantt-chart-task-label-color-selected: #ffffff;
}
/* A late task, whatever its kind of work */
#gantt .late {
--jqx-gantt-chart-task-color: #c2413d;
--jqx-gantt-chart-task-label-color: #ffffff;
--jqx-gantt-chart-task-label-color-selected: #ffffff;
}
const gantt = new jqxGantt('#gantt', {
theme: 'fluent',
width: '100%',
height: 'auto',
view: 'quarter',
treeSize: '30%',
source: [
{
id: 'app', type: 'project', label: 'Mobile app 2.0', dateStart: '2026-01-05T00:00:00', dateEnd: '2026-06-19T00:00:00',
progress: 45, expanded: true,
tasks: [
{ id: 'ux', label: 'UX research', dateStart: '2026-01-05T00:00:00', dateEnd: '2026-02-13T00:00:00', progress: 100, class: 'design' },
{ id: 'ui', label: 'Screens', dateStart: '2026-02-02T00:00:00', dateEnd: '2026-03-20T00:00:00', progress: 80, class: 'design' },
{ id: 'api', label: 'API', dateStart: '2026-02-16T00:00:00', dateEnd: '2026-04-24T00:00:00', progress: 50, class: 'build' },
{ id: 'client', label: 'App', dateStart: '2026-03-09T00:00:00', dateEnd: '2026-05-22T00:00:00', progress: 20, class: 'build' },
{ id: 'qa', label: 'Testing', dateStart: '2026-04-27T00:00:00', dateEnd: '2026-06-12T00:00:00', class: 'test' },
{ id: 'launch', type: 'milestone', label: 'Launch', dateStart: '2026-06-19T00:00:00' }
]
}
]
});
A class can change at any time: updateTask(id, { class: '...' }) replaces the task's class and draws the bar again. The buttons of this page mark Testing as late, which turns its bar red, and put it back:
// A task's class can change: updateTask replaces it.
document.getElementById('late').addEventListener('click', () => {
gantt.updateTask('qa', { class: 'late' });
});
document.getElementById('onTime').addEventListener('click', () => {
gantt.updateTask('qa', { class: 'test' });
});
The variables for the bars, with their defaults in jqx.gantt.css (version 27.1.0; before it, tasks were #0099FF with square corners in every theme):
| Variable | Default | What it sets |
|---|---|---|
--jqx-gantt-chart-task-color | var(--jqx-primary) | The fill of a task bar (any CSS background, a gradient too); by default the theme's accent colour |
--jqx-gantt-chart-task-label-color | var(--jqx-primary-color) | The label on a task bar; by default the theme's text colour for its accent |
--jqx-gantt-chart-task-label-color-selected | var(--jqx-primary-color) | The label on a selected task bar |
--jqx-gantt-chart-task-progress-color | rgba(0, 0, 0, .22) | The done part of a task bar, drawn over the fill |
--jqx-gantt-chart-project-color | #F89911 | The fill of a project bar |
--jqx-gantt-chart-project-label-color | #333 | The label on a project bar |
--jqx-gantt-chart-project-label-color-selected | #000 | The label on a selected project bar |
--jqx-gantt-chart-project-progress-color | var(--jqx-gantt-chart-task-progress-color) | The done part of a project bar |
--jqx-gantt-chart-milestone-color | #800080 | The milestone diamond |
--jqx-gantt-chart-task-fill-border-radius | 4px | The corners of the bars |
--jqx-gantt-chart-task-default-height | 30px | The height of a row, in the tree and in the timeline |
--jqx-gantt-chart-task-bar-fill-padding | 5px | The space above and below a bar in its row |
--jqx-gantt-chart-task-thumb-color | rgba(0, 0, 0, .55) | The handle that changes the progress of a bar |
--jqx-gantt-chart-timeline-task-connection-color | #8a8a8a | The connection lines; in browsers with color-mix(), a grey half way between the theme's text and background colours. The line drawn while the user connects two tasks has --jqx-gantt-chart-timeline-task-connection-feedback-color, the theme's accent. |
The two label colours default to the theme's text colour for its accent, which reads well on the default bar colour. When you give bars a colour of your own, set the label colour and the -selected colour with it: when a user clicks a yellow bar with a dark label, the label otherwise turns to the default, white in fluent. (Before 27.1.0 the label colours had no default, and a label had the theme's text colour.)
The API reference lists more variables. For some it gives other defaults than the published stylesheet, which is the one that counts. The sections below name the variables for progress labels, baselines, deadlines and the header.
showProgressLabel: true writes the progress of each task into the darker, done part of its bar. By default the text is the number with a percent sign (40%); progressLabelFormatFunction receives the progress, a number from 0 to 100, and returns the text instead. A task without progress shows 0%.
showBaseline: true draws a thin bar under each task: its baseline, the dates it was planned for. Give each task a planned field with a dateStart and a dateEnd. A task that moved shows how far it is from the plan. Milestones have no baseline.
const gantt = new jqxGantt('#gantt', {
theme: 'fluent',
width: '100%',
height: 'auto',
view: 'quarter',
treeSize: '30%',
// The progress, as a label inside the darker part of the bar
showProgressLabel: true,
progressLabelFormatFunction: (progress) => progress === 100 ? 'Done' : Math.round(progress) + '%',
// The planned dates of each task, as a thin bar under it
showBaseline: true,
source: [
{
id: 'ux', label: 'Research', dateStart: '2026-01-05T00:00:00', dateEnd: '2026-02-27T00:00:00', progress: 100,
planned: { dateStart: '2026-01-05T00:00:00', dateEnd: '2026-02-27T00:00:00' }
},
{
id: 'ui', label: 'Screens', dateStart: '2026-02-02T00:00:00', dateEnd: '2026-03-27T00:00:00', progress: 85,
planned: { dateStart: '2026-02-02T00:00:00', dateEnd: '2026-03-13T00:00:00' }
},
{
id: 'api', label: 'API', dateStart: '2026-03-02T00:00:00', dateEnd: '2026-04-24T00:00:00', progress: 40,
planned: { dateStart: '2026-02-16T00:00:00', dateEnd: '2026-04-10T00:00:00' }
},
{
id: 'client', label: 'App', dateStart: '2026-03-23T00:00:00', dateEnd: '2026-05-29T00:00:00', progress: 15,
planned: { dateStart: '2026-03-09T00:00:00', dateEnd: '2026-05-15T00:00:00' }
},
{
id: 'qa', label: 'Testing', dateStart: '2026-05-04T00:00:00', dateEnd: '2026-06-19T00:00:00',
planned: { dateStart: '2026-04-27T00:00:00', dateEnd: '2026-06-05T00:00:00' }
}
]
});
A baseline takes part of the row: its height is the row height divided by --jqx-gantt-chart-baseline-proportion (2 by default, half the row), and the bar gets the rest. This page makes the rows taller and the baselines a quarter of them, so that the bars still hold their labels:
/* With baselines, a row holds the bar and the baseline under it */
#gantt {
--jqx-gantt-chart-task-default-height: 48px;
--jqx-gantt-chart-baseline-proportion: 4;
--jqx-gantt-chart-baseline-background: #8c95a3;
--jqx-gantt-chart-task-color: #5e63b5;
--jqx-gantt-chart-task-label-color: #ffffff;
--jqx-gantt-chart-task-label-color-selected: #ffffff;
--jqx-gantt-chart-task-progress-color: rgba(0, 0, 0, .3);
--jqx-gantt-chart-progress-label-width: 64px;
}
| Variable | Default | What it sets |
|---|---|---|
--jqx-gantt-chart-progress-label-width | 60px | How far the task label moves right to leave room for the progress label |
--jqx-gantt-chart-progress-label-padding | 0 10px 0 10px | The padding of the progress label |
--jqx-gantt-chart-baseline-background | rgba(166, 205, 87, .5) | The baseline |
--jqx-gantt-chart-baseline-proportion | 2 | The row height divided by this number is the height of the baseline |
The field is planned: a field named baseline draws nothing.
Three task fields mark dates on a task's row:
deadline is the date a task must end by. The chart draws an icon at that date, with the date as its tooltip. When the task ends later, its overdue field is true and the text Overdue: 7 days follows the bar.indicators is an array of dates to point out, each drawn with its label in the task's row. icon adds an icon before the label, className adds a CSS class to it, and tooltip is the text shown when tooltips are on (see Tooltips).segments splits a task into pieces with gaps between them, for work that stops and starts again. Each segment has its own dateStart, dateEnd and label; a dashed line joins them.const shortDate = { month: 'short', day: 'numeric' };
const gantt = new jqxGantt('#gantt', {
theme: 'fluent',
width: '100%',
height: 'auto',
view: 'quarter',
treeSize: '34%',
// The overdue text after a bar counts in this unit
durationUnit: 'day',
taskColumns: [
// The value 'overdue' shows the deadline icon for overdue tasks
{ label: '', value: 'overdue', size: 32 },
{ label: 'Task', value: 'label', size: '55%' },
{
label: 'Deadline', value: 'deadline',
formatFunction: (value, task) => task.deadline ? task.deadline.toLocaleDateString('en', shortDate) : ''
}
],
source: [
{
id: 'api', label: 'API', dateStart: '2026-01-05T00:00:00', dateEnd: '2026-03-06T00:00:00',
deadline: '2026-02-27T00:00:00'
},
{
id: 'client', label: 'App', dateStart: '2026-01-19T00:00:00', dateEnd: '2026-05-08T00:00:00',
deadline: '2026-05-15T00:00:00',
// Work stops in March and starts again in April
segments: [
{ label: 'Build', dateStart: '2026-01-19T00:00:00', dateEnd: '2026-03-06T00:00:00' },
{ label: 'Polish', dateStart: '2026-04-06T00:00:00', dateEnd: '2026-05-08T00:00:00' }
]
},
{
id: 'qa', label: 'Testing', dateStart: '2026-03-30T00:00:00', dateEnd: '2026-05-15T00:00:00',
deadline: '2026-05-08T00:00:00',
indicators: [
{
label: 'Review', date: '2026-03-04T00:00:00', className: 'review',
icon: '\\e829', tooltip: 'Test plan review with the client'
}
]
},
{
id: 'launch', type: 'milestone', label: 'Launch', dateStart: '2026-06-05T00:00:00'
}
]
});
#gantt {
--jqx-gantt-chart-task-default-height: 36px;
--jqx-gantt-chart-deadline-color: #c2413d;
}
/* An indicator's className is added to its element */
#gantt .review {
color: #5e63b5;
font-weight: 600;
}
The number in the overdue text counts in the chart's durationUnit. Set it: with the default unit, milliseconds, the text reads Overdue: 604800000 milliseconds. The deadline icon and its colour are --jqx-gantt-chart-deadline-icon (default var(--jqx-icon-attention-circled)) and --jqx-gantt-chart-deadline-color (default var(--jqx-error)). A tree column with the value 'overdue' shows the same icon for each overdue task.
An indicator's icon is a character of the chart's icon font, jqx-gantt-icons, written as a CSS escape: '\\e829' in JavaScript is \e829, the calendar. The other icons are the values of the --jqx-icon-* variables in jqx.gantt.css, such as --jqx-icon-bell (\f0f3) and --jqx-icon-star (\e801).
A task needs two segments or more; with one, the chart ignores the segments field. The first segment always starts with the task and the last one ends with it: the chart moves them if they do not. Users can drag a single segment along the timeline; with disableSegmentDrag: true, dragging a segment moves the whole task. The colour of the line between segments is --jqx-gantt-chart-segment-link-color (default var(--jqx-gantt-chart-task-color)).
onTaskRender is a function that the chart calls for each task and project bar every time it draws one: when the chart opens, and again when a method such as updateTask changes the task. Dragging a bar moves it without a new call, and what the function added stays. It is not called for milestones. It receives five arguments:
| Argument | What it is |
|---|---|
task | The task, with its fields and any fields of your own |
segment | The segment being drawn; for a task without segments, the task again. A segmented task gets one call per segment. |
taskElement | The bar element (.jqx-timeline-task) |
segmentElement | The element of the segment (.jqx-task-segment) |
labelElement | The element that holds the label text |
This page keeps two fields of its own on each task, status and owner. The function copies the status into a data-status attribute of the bar, which the stylesheet turns into a colour, and puts the owner's initials before the label:
// Called for each bar (and each segment of a bar) whenever the chart draws it
const renderTask = (task, segment, taskElement, segmentElement, labelElement) => {
// Your own fields are kept on the task: status and owner
taskElement.dataset.status = task.status || 'on-track';
const initials = document.createElement('span');
initials.className = 'owner';
initials.textContent = task.owner;
labelElement.prepend(initials);
};
/* onTaskRender sets data-status on each bar */
#gantt [data-status="done"] {
--jqx-gantt-chart-task-color: #2f7d5b;
}
#gantt [data-status="on-track"] {
--jqx-gantt-chart-task-color: #5e63b5;
}
#gantt [data-status="at-risk"] {
--jqx-gantt-chart-task-color: #c2413d;
}
const gantt = new jqxGantt('#gantt', {
theme: 'fluent',
width: '100%',
height: 'auto',
view: 'quarter',
treeSize: '30%',
taskColumns: [
{ label: 'Task', value: 'label', size: '65%' },
{ label: 'Owner', value: 'owner' }
],
onTaskRender: renderTask,
source: [
{ id: 'ux', label: 'Research', owner: 'AK', status: 'done', dateStart: '2026-01-05T00:00:00', dateEnd: '2026-02-20T00:00:00' },
{ id: 'api', label: 'API', owner: 'MB', status: 'on-track', dateStart: '2026-02-02T00:00:00', dateEnd: '2026-04-17T00:00:00' },
{ id: 'pay', label: 'Payments', owner: 'JS', status: 'on-track', dateStart: '2026-03-02T00:00:00', dateEnd: '2026-05-15T00:00:00' },
{ id: 'client', label: 'App', owner: 'LT', status: 'on-track', dateStart: '2026-03-16T00:00:00', dateEnd: '2026-06-05T00:00:00' }
]
});
// updateTask draws the bar again, so onTaskRender sees the new status
document.getElementById('risk').addEventListener('click', () => {
gantt.updateTask('pay', { status: 'at-risk' });
});
document.getElementById('track').addEventListener('click', () => {
gantt.updateTask('pay', { status: 'on-track' });
});
The chart writes the label text into labelElement before each call, so adding to it does not pile up. Set the attributes for every task, not only for some: after updateTask the function runs again, and it is the only place that knows the new status.
A task can also have its own onRender field, a function with the same arguments, which runs for that task only, after onTaskRender.
tooltip: true shows a tooltip when the pointer rests on a bar, a segment, a connection or an indicator. By default it lists the task's name and dates (Task, Date Start, Date End), a connection's two tasks and type, or an indicator's label. A task or an indicator with a tooltip field shows that text instead; it can hold HTML.
The other tooltip settings and the format function are not options of jqxGantt in 27.1.0 and earlier. The API reference describes tooltip as an object (enabled, arrow, delay, offset), but jqxGantt takes only true or false, and refuses an object with the error Invalid 'tooltip_enabled' property value type: the chart is not drawn. Set them on the chart's jqx-gantt-chart element instead:
const gantt = new jqxGantt('#gantt', {
theme: 'fluent',
width: '100%',
height: 'auto',
view: 'quarter',
treeSize: '30%',
durationUnit: 'day',
// Show a tooltip when the pointer rests on a bar, a segment, a connection or an indicator
tooltip: true,
source: [
{ id: 'ux', label: 'Research', owner: 'Anna', dateStart: '2026-01-05T00:00:00', dateEnd: '2026-02-20T00:00:00', progress: 100 },
{ id: 'api', label: 'API', owner: 'Mark', dateStart: '2026-02-02T00:00:00', dateEnd: '2026-04-17T00:00:00', progress: 60 },
{ id: 'client', label: 'App', owner: 'Lena', dateStart: '2026-03-16T00:00:00', dateEnd: '2026-06-05T00:00:00', progress: 20 },
{
id: 'launch', type: 'milestone', label: 'Launch', dateStart: '2026-06-12T00:00:00',
// A fixed text for one item, instead of the generated one
tooltip: 'Go live in the <b>App Store</b> and <b>Google Play</b>'
}
]
});
// The tooltip settings and the format function are set on the chart element.
const chart = document.querySelector('#gantt jqx-gantt-chart');
chart.tooltip = { enabled: true, arrow: true, delay: 50, offset: [0, 5] };
const day = { month: 'short', day: 'numeric' };
chart.tooltipFormatFunction = (item, event, content) => {
// item is the task, segment, indicator or connection under the pointer
if (!item || !item.owner) {
return content;
}
return `<b>${item.label}</b> (${item.owner})<br>` +
`${item.dateStart.toLocaleDateString('en', day)} to ${item.dateEnd.toLocaleDateString('en', day)}, ` +
`${Math.round(item.duration)} days<br>${item.progress}% done`;
};
tooltipFormatFunction(item, event, content) runs before a tooltip opens. item is the task, segment, indicator or connection under the pointer, and content is the HTML the chart would show. The function returns the HTML to show; returning content keeps the default. The result is used as HTML, so escape any text that users typed.
The tooltip is a jqx-tooltip element with the class jqx-gantt-chart-tooltip, added to the end of the page's <body>, so style it with a rule that does not start with #gantt:
/* The tooltip is added to the end of the page's body */
.jqx-gantt-chart-tooltip .jqx-tooltip-content {
text-align: start;
line-height: 1.5;
}
headerTemplate adds a bar above the tree and the timeline. It takes the id of a <template> element, whose content goes into the bar, or a function that receives the bar's element and fills it. This page shows the plan's name and a legend of the bar colours:
<template id="planHeader">
<div class="plan-header">
<h2>Mobile app 2.0</h2>
<span><span class="swatch design"></span>Design</span>
<span><span class="swatch build"></span>Build</span>
</div>
</template>
const gantt = new jqxGantt('#gantt', {
theme: 'fluent',
width: '100%',
height: 'auto',
view: 'quarter',
treeSize: '30%',
// The id of a <template>; its content goes above the tree and the timeline
headerTemplate: 'planHeader',
source: [
{ id: 'ux', label: 'Research', dateStart: '2026-01-05T00:00:00', dateEnd: '2026-02-20T00:00:00', class: 'design' },
{ id: 'ui', label: 'Screens', dateStart: '2026-02-02T00:00:00', dateEnd: '2026-03-27T00:00:00', class: 'design' },
{ id: 'api', label: 'API', dateStart: '2026-03-02T00:00:00', dateEnd: '2026-05-01T00:00:00', class: 'build' },
{ id: 'client', label: 'App', dateStart: '2026-03-23T00:00:00', dateEnd: '2026-06-05T00:00:00', class: 'build' }
]
});
The header is as high as --jqx-gantt-chart-header-height, 30px by default. That default comes from the row height of the stylesheet, not from a --jqx-gantt-chart-task-default-height set on #gantt, so set both when you change the row height.
inverted: true puts the tree on the right of the timeline. A right-to-left layout also mirrors the timeline, with January on the right. In 27.1.0 and earlier, jqxGantt refuses a rightToLeft option, and accepts an rtl option without passing it on to the chart. Set rightToLeft on the chart element:
// inverted puts the tree on the right of the timeline
document.getElementById('inverted').addEventListener('click', () => {
gantt.inverted = !gantt.inverted;
});
// jqxGantt has no right-to-left option in 27.1.0 and earlier: set it on the chart element
document.getElementById('rtl').addEventListener('click', () => {
const chart = document.querySelector('#gantt jqx-gantt-chart');
chart.rightToLeft = !chart.rightToLeft;
});
The theme option names the theme, and the page loads its stylesheet after jqx.gantt.css, as the getting-started guide explains under Load the files. Every picture on this page has a dark version: the same page with jqx.tailwind-dark.css and theme: 'tailwind-dark'.
A theme sets the chart's background, text, borders and accent colour. Since 27.1.0 the task bars and their labels, the connection lines, the row under the pointer, the scroll bars, and the weekend and nonworking cells of the timeline take their colours from the theme as well; projects and milestones keep the colours of jqx.gantt.css in every theme. Before 27.1.0, task bars were #0099FF in every theme, and tailwind-dark left the row under the pointer (--jqx-ui-state-hover, #ebebeb), the scroll bars, and the weekend and nonworking cells light.
The chart element carries the theme's name in its theme attribute, so a rule can set colours for one theme only. The colours example ends with this rule; with fluent it does nothing:
/* The chart element carries the theme's name: colours for a dark theme */
#gantt jqx-gantt-chart[theme="tailwind-dark"] {
--jqx-gantt-chart-project-color: #94a3b8;
--jqx-gantt-chart-project-label-color: #0f172a;
--jqx-gantt-chart-project-label-color-selected: #0f172a;
--jqx-gantt-chart-project-progress-color: rgba(0, 0, 0, .2);
/* light before 27.1.0, which takes them from the theme */
--jqx-ui-state-hover: #1f2937;
--jqx-ui-state-color-hover: #f3f4f6;
--jqx-ui-state-focus: #374151;
--jqx-ui-state-color-focus: #f3f4f6;
--jqx-scroll-bar-background: #1f2937;
--jqx-scroll-bar-border: #1f2937;
--jqx-scroll-bar-button-background: #1f2937;
--jqx-scroll-bar-button-border: #1f2937;
--jqx-scroll-bar-thumb-background: #4b5563;
--jqx-gantt-chart-timeline-weekend-color: #1f2937;
--jqx-gantt-chart-timeline-nonworking-color: #1f2937;
}