Could you please explain this in more details. I’m not so clear about this.
sure. Pls consider this,
I’ve put a breakpoint into the filter. There are four tasks in the gantt, so when the filtering is refreshed - I expect the code to hit a breakpoint four times.
Firstly, if I call gantt.render - all as expected, the code stops 4 times at breakpoint.
Now, if I click Day/Hour - the breakpoint is hit 8 times. If I look at the stack trace of first 4 calls - they originate from the anonymous function as a part of gantt.render call tree,
and the second 4 calls originate from gantt.refreshData inside the same gantt.render call.
Meaning that both calls are the part of gantt repaint process, and there are no duplicated event handlers.
Does that meant that it’s caused by the gantt library itself hence, that is why I am still seeing multiple log message in the console?
If I need to do 2-3 type of filter, would that be considered as complex? Such as filter by Date AND Priority AND (text-match) or Date AND Priority AND STATUS-TYPE.
No, I don’t think so.
If filtering of a single task would have required accessing a DOM element or something else that can be potentially heavy, a 2x or 3x more function calls would likely affect the user experience. But in case if simple string/date operations I don’t think such an increase will be a problem.
If you think it still affects the overall performance, you can optimize it a bit by moving filtering logic from onBeforeTaskDispaly to a separate function, where you precalculate visibility of each task in gantt chart and store it in some variable. And inside onBeforeTaskDisplay you simply check whether is task should be visible or not.That way you’ll be able to run actual filtering only when needed, and any redundant calls of onBeforeTaskDisplay will cost only accessing the precalculated value
For example, regular text filter:
Precalculate values in a separate function:
And what about having a few thousands of rows rendered? That is to say that if in my current example, there is 8000 tasks, the console would have then shown 16 000 lines.
Gantt performance in case of that amount of tasks will depend on settings and extensions you use, so it’s hard to tell in advance. I’m almost sure that filtering won’t be the most impactful factor in that case.
the console would have then shown 16 000 lines.
Please, be sure to comment out console logs if you’re doing such test. Console output works much slower than anything else in your code, so having thousands of console.log calls will dramatically increase the execution time.