Our state of the art Gantt chart


Post by johanbrodin »

Hi,

I am adding some 450 tasks to the roadmap with below code. The problem is that it is just to slow to be useful requiring some 60+ seconds for the code to finish (please see gif)

The issue is of course the await and I could remove the second one however the majority of the tasks are on the first. And I need thew "childTask" reference to add the subtasks.

I make the assumption that there is a better way of doing this and please advice.

    //bryntum 5.3.1
    
//root task tmp = { myId: event.id, name: event.name, startDate: new Date(), duration: 10 }; var parentTask: any = this.gantt.taskStore.rootNode.appendChild(tmp); for (var i = issues.length - 1; i >= 0; i--) { //second level var issue = issues[i]; var childTask = await this.gantt.addSubtask(parentTask); this.populateTaskWithIssue(childTask, issue, false, true); //third level var childParentIssue = issue; for (var t = 0; t < childParentIssue.epicissues.length; t++) { var issue = childParentIssue.epicissues[t]; var tmp: any = await this.gantt.addSubtask(childTask); this.populateTaskWithIssue(tmp, issue, false, true); } }
Attachments
bryntum-slow.gif
bryntum-slow.gif (11.09 MiB) Viewed 106 times

Post by alex.l »

Hi johanbrodin,

There are 2 steps to improve the performance may be done.
1 You still can add all at once into the store, just use tree structure in data you adding.

const tasks = [{
    id : 2,
    parentId : parentTaskId,
    // ...
    children : [{
        id : 21,
        //...
        children : [{
             id : 211,
             // ...
        }]
    }]
}, {
    id : 3, 
    // ...
}];

gantt.taskStore.add(tasks);

2 Use batching when you have many operations one by one to prevent re-calculation after every change in the store.
https://bryntum.com/products/gantt/docs/api/Gantt/data/TaskStore#function-beginBatch
https://bryntum.com/products/gantt/docs/api/Gantt/data/TaskStore#function-endBatch

All the best,
Alex


Post by johanbrodin »

Thx! I did figure out #1 myself but I think your suggested #2 is the better option. Please close the issue and once again thx for the great support.


Post Reply