How to display scale by days


#1

Hi,
Is there any way to display the scale by days number instead of date?
Just like this picture


#2

Hello,
One of the options is to use gantt.scales.config with format function that expects a date object as a parameter:
https://docs.dhtmlx.com/gantt/api__gantt_scales_config.html ;
You can get the configuration of the time scale by getScale method:
https://docs.dhtmlx.com/gantt/api__gantt_getscale.html ;
and get the amount of dates in the timeline area from the trace_x property. You can return the indices dates as numbers in the following way:

gantt.config.scales = [
    {
        unit: "day", step: 1, format: function (date) {
            const scale = gantt.getScale();
            let index = scale.trace_x.findIndex(function (x) {
                return +x === +date
            });
            return index + 1
        }
    }
]

Please check the example:
https://snippet.dhtmlx.com/ukjyqc8r


#3

Thanks for reply,
And how to remove the offsets Before the first task? I had specify the startDate (gantt.config.start_date), but it seems not work


#4

Hello,
You can specify the start date of the earliest task as gantt.config.start_date to display a timeline area without empty interval. You can get the start date of the earliest task from the getSubtaskDates method:
https://docs.dhtmlx.com/gantt/api__gantt_getsubtaskdates.html ;
Please check the example of how it might be implemented:
https://snippet.dhtmlx.com/2hkr8hd8 ;