How to split one task in multiple parts having different colors


Hello everyone,

We are using this library at work for a project and the client is asking us to develope this feature:
“Tasks can have periods of inactivity. These periods will be displayed on the timeline by either a blank color or a different color than the one already used for the task. There can be multiple inactivity periods between the start date and end date of one task.” Example : start IIIIIIIII IIIII III end

I have beeen browsing the documentation for a few hours and from what I can tell there does not seem to be a way to separate one task in multiple parts and assign a different color to each one.

Can anyone help me with a way to do it? Coloring multiple background cells behind the task bar while reducing task bar height at the same time could also work but I have no idea how to achieve this result.

Thanks in advance.

Edit: Seems like this could work out:


Yes, you can use split tasks for this adaptation: ;
One of the options is to add different CSS classes which will depending on custom task’s property with periods of inactivity. To specify the CSS class that will be applied to task bars use task_class template: ;
Please check the following snippet: ;
Also, you can try to use task_text template: ;
with HTML content inside. As an example: ;
Another solution is to add some element on the desired dates on top of the task strip to indicate an inactive period using gantt.addTaskLayer : ;
There is an article about it: