I have used pro version for grouping based on resources,but workload calculation has issue,check screenshot where in some value “3” is considered overload.
and see code
setResourceTemplates(): void {
this.oGanttInstance.templates.resource_cell_value = (
cellStart,
cellEnd,
resource,
tasks
) => {
const totalHours = this.calculateTotalHours(tasks, resource.id, cellStart, cellEnd);
return this.formatHours(totalHours);
};
}
/** Core calculator */
private calculateTotalHours(tasks: any[], resourceId: any, cellStart: Date, cellEnd: Date): number {
let total = 0;
for (const task of tasks) {
const assignments = this.oGanttInstance.getResourceAssignments(resourceId, task.id);
total += this.calculateAssignmentsHours(assignments, cellStart, cellEnd);
}
return this.roundHours(total);
}
/** Per assignment calculation */
private calculateAssignmentsHours(assignments: any[], cellStart: Date, cellEnd: Date): number {
let total = 0;
for (const assignment of assignments) {
const overlapHours = this.getOverlapHours(assignment, cellStart, cellEnd);
total += overlapHours;
}
return total;
}
/** Overlap logic isolated */
private getOverlapHours(assignment: any, cellStart: Date, cellEnd: Date): number {
if (!assignment.start_date) return 0;
const start = new Date(assignment.start_date);
const end = assignment.end_date
? new Date(assignment.end_date)
: new Date(start.getTime() + 24 \* 60 \* 60 \* 1000);
if (end <= start) return 0;
const overlapStart = start > cellStart ? start : cellStart;
const overlapEnd = end < cellEnd ? end : cellEnd;
if (overlapStart >= overlapEnd) return 0;
return (overlapEnd.getTime() - overlapStart.getTime()) / 3600000;
}
/** Rounding logic */
private roundHours(hours: number): number {
return hours % 1 ? Math.round(hours \* 10) / 10 : hours;
}
/** UI formatting */
private formatHours(hours: number): string {
return hours ? \`<div>${hours}</div>\` : "";
}
and prepare groups i used
private groupTasksByResources(resources): void {
const groups = resources.map(this.prepareGroups.bind(this))
this.oGanttInstance.groupBy({
groups: groups,
relation_property: this.oGanttInstance.config.resource_property,
group_id: "group_id",
group_text: "text",
default_group_label: 'Un-Assigned',
default: true,
});
}
private prepareGroups(item): any {
const group = this.oGanttInstance.copy(item);
group.group_id = group.id;
group.id = this.oGanttInstance.uid();
return group;
}

