Hello~
We're a solution company using Bryntum Gantt.
We know that when the criticalPath feature is enabled, the taskbar and path (arrow) are displayed in red. However, in our solution, we set the taskbar color based on the task status. In this case, the taskbar color doesn't change even when the criticalPath feature is enabled (using the console command: gantt.features.criticalPaths.disabled = false;).
So, I have a few questions:
Is there a way to control the taskbar border color?
(I want to indicate the critical path without changing the existing colors.)
For criticalPath, what's the method to force the color to display in red?
When each taskbar uses a different color, what's a good way to indicate the criticalPath?
For criticalPath, what's the method to force the color to display in red?
We apply b-critical to the tasks which are critical and then we already have css which applies this color. But you can control it using:
.b-ganttbase.b-gantt-critical-paths .b-gantt-task.b-critical {
background-color : // your color
}
When each taskbar uses a different color, what's a good way to indicate the criticalPath?
I believe that is upto the end user. We mark it with the red color to show the criticality. You can have any other color to indicate this or as you said above a different border color.
Thank you for your kind response.
However, if we modify the CSS, the code might be missing when we deploy a new version of the gantt.
Is there a way to handle this in app.js?
Two simple ways to do it from app.js (no external CSS file edits):
1) Inject CSS at runtime (recommended for global override)
const s = document.createElement('style');
s.textContent = `
.b-ganttbase.b-gantt-critical-paths .b-gantt-task.b-critical {
border: 2px solid red !important;
/* or use background/border changes you need */
}
`;
document.head.appendChild(s);
2) Control per-task appearance in taskRenderer (fine if you can detect “critical” in data or compute it)
We are displaying data from our database in the Gantt chart.
We want to store the criticalPath information in the DB as well, but it seems that some tasks are missing from the criticalPath result.
In the screenshot, the critical path looks like it contains more than 20 tasks, but the actual criticalPaths data retrieved from the Gantt only includes 15 tasks.
It appears that only the tasks connected with the red critical-path arrows are included in the criticalPaths list.
Is there a way to also retrieve tasks that are part of the critical path but are not connected with the red arrows?
used comment
const set = new Set();
for (let i = 0; i < xgantt.project.criticalPaths.length; i++) {
var ids = "";
for (let j = 0; j < xgantt.project.criticalPaths[i].length; j++) {
ids += xgantt.project.criticalPaths[i][j].event.id + ",";
set.add(xgantt.project.criticalPaths[i][j].event.id);
}
console.log(i + "row id list: " + ids);
}
console.log("distinct id list"); console.log(set);
Attachments
criticalPaths data
스크린샷 2025-11-14 090647.png (20.21 KiB) Viewed 33745 times
gantt view
스크린샷 2025-11-14 090454.png (39.22 KiB) Viewed 33745 times
The behaviour you see is expected: gantt.project.criticalPaths returns the linked critical chains (nodes connected by dependencies/arrows). Tasks that are “critical” (zero slack) but not part of a linked chain may not appear in those arrays.
To collect every task that is critical you can:
read the criticalPaths chains, and
also scan the taskStore for tasks flagged as critical (TaskModel.critical).
Example (run after scheduling is finished, e.g. await project.commitAsync()):
const project = gantt.project;
// IDs from highlighted chains
const chainIds = new Set(project.criticalPaths.flatMap(path => path.map(node => node.event.id)));
// IDs from tasks marked critical
const flaggedIds = new Set();
project.taskStore.forEach(task => { if (task.critical) flaggedIds.add(task.id); });
// union of both
const allCritical = new Set([...chainIds, ...flaggedIds]);
console.log({ chainIds, flaggedIds, allCritical });
If you still miss tasks after this, please show a minimal code / project state (are tasks inactive, segmented, or computed before propagation finished?) and I’ll help further.