How can i assign dynamic background color in task cell

I’ve tried with
gantt.templates.task_cell_class = function(item, date) {
if (holidays.includes(moment(date).format(‘DD-MM-YYYY’))) return ‘customClass’;
else if (!gantt.isWorkTime({ date: date, task: item })) return ‘weekend’;

But instead of class i want to use the dynamic style.

Hello @Subhasis,

The current way of styling timeline cells - is through the timeline_cell_class(task_cell_class in old versions) template which returns the class name.

Unfortunately, there is no way to return color styles directly, so I only can suggest you define different classes to colorizing, like :


Also, you can try to implement some custom solution to change class colors directly from js if you don’t want to create many classes, unfortunately, I can’t give you any advice on implementation.

API Templates of the Timeline Area :

Hello @Subhasis,

I forgot to say in the previous answer: in case if you are unable to stylize timeline cells in advance, you can generate CSS dynamically, as described in the following article: