Dummy Tasks with gantt.posFromDate


I am trying to create temporary task bar to overlap other task on hover or click.
The challenge we have is to find out the width of the duration/endDate.

We use gantt.posFromDate(new Date()), but how can we find the width according to
it’s endDate?

Appreciate tip on this issue


You can use the getTaskPosition method to find the sizes of a dummy task by using only the dates and a task object (you need any task to obtain the height and top parameters):
Here is an example of how it works:


Thank you for tip. I have ordinary task, but want to create a dummy task box that retrieve optional date values and show as separate bar. Do I need to create a task object each time I hover or click ordinary task, then create optional “dummy” task, for then to delete same? Am not sure how to accomplish this.


The getTaskPosition method requires the task object to get the vertical and horizontal position of the sizes. And anyway, you will need to draw a dummy task bar in the timeline, isn’t it? So, you can choose a task row and use the task object from that row. Otherwise, you just need to take the first task in the chart, if you only need horizontal sizes.

If you hover an ordinary task and want to show a dummy task only during that time, it would be easier to do that by using the addTaskLayer feature:
Here is an example of how it can be implemented: