Get Date by X on Chart

TL;DR;
Is there any API where I can provide the X and/or Y coords and get the date? Like gantt.getDateAt(x,y): Date?

Long:
I have a custom element that I added through the addTimelineLayer API and now I have to handle the drag and drop of it, so while dragging it around I have to identify its current position so that I have to either render it in the middle of the grid column, or extend the timeline in case it hits the borders. By the way, the task does this, is there any way to maybe reuse this behaviour?

Thanks!

You can try using dateFromPos method that returns the date according to “x” position and combine it with getScrollState method:
https://docs.dhtmlx.com/gantt/api__gantt_datefrompos.html
https://docs.dhtmlx.com/gantt/api__gantt_getscrollstate.html
However, the timeline is not displayed under the grid. In the following example you will see the date in the web console after you move the mouse. When it is above the grid, you will see “null”:
http://snippet.dhtmlx.com/471b42688

1 Like

Thank you once again @ramil!