Tooltip for scale area and links


Hi Support,

I wont to display tooltip in scale area.
if scale is “month” and gantt displays Jul 2022 , then tooltip should be “1/7/2022 - 31/7/2022”. like wise i want to display tool tips for Year , month ,week and day scales.

And I want to display tooltips for links too.



You can use tooltipFor method, which adds a tooltip for the specified Gantt element: ;
You can specify the CSS-selectors of the required Gantt element and create a template for a tooltip. To return the date of the cursor’s position, you need to use gantt.utils module with the help of dateFromPos method that gets the date of the specified horizontal position in the chart area. Here are related articles: ; ;
For month tooltip, you can use method and for week tooltip –>13-,month_start%20(%20date),--%20returns%20a%20Date ;>10-,week_start%20(%20date),--%20returns%20a%20Date ;
The example might look like:

const tooltips = gantt.ext.tooltips;
    selector: ".gantt_scale_line:nth-child(2)",
    html: function (event, domElement) {
        const domHelper = gantt.utils.dom;
        const dateToStr ="%d/%m/%Y");
        let pos = domHelper.getRelativeEventPosition(event, gantt.$task_scale);
        let firstDay =;
        let lastDay = new Date(firstDay.getFullYear(), firstDay.getMonth() + 1, 0);
        return `${dateToStr(firstDay)} -  ${dateToStr(lastDay)}`;

Please check the following snippet: ;
To create a tooltip for links, you need to get the ID of the link. One of the options is to get it from the attribute of the DOM element:

    selector: ".gantt_task_link",
    html: function (event, domElement) {
        let linkId = domElement.getAttribute(gantt.config.link_attribute);
        if (linkId) {
            ...  your tooltip's template 

Please check the example of how it might be implemented: