а

Customize "date_scale"


#1

Hi there,
I want to customize “gantt.config.date_scale”. Do I have a way to combine 2 “days” into 1 “days” and use the “day” I just combined as a new unit of measurement?


#2

Hi @longhai,
The first way you can do this is to use the ‘day’ unit with step:2 and custom format function to show two days in one cell, like in the following snippet:
http://snippet.dhtmlx.com/9d1613302

If it is not the thing you need, you can create a custom time unit,
doubleDay, which will be 2 days long.
To create custom doubleDay unit , you should define its logic in the gantt.date.shiftDay_start/gantt.date.add_shiftDay methods. After that, you will be able to add this unit into the gantt.config.scale and use it like default time units.
Here is the snippet:
http://snippet.dhtmlx.com/d44c793b7

Also, you can combine both ways, and use different step with custom units, like in the snippet below, where I used the doubleDay unit with step:2 to create quadraDay on the scale:
http://snippet.dhtmlx.com/676428f40

Important: In these examples, I used gantt.config.scale because gantt.config.date_scale is deprecated.
API list:
custom time units
https://docs.dhtmlx.com/gantt/desktop__configuring_time_scale.html#customtimeunits
gantt.config.scale
https://docs.dhtmlx.com/gantt/api__gantt_scales_config.html
I didn’t fully understand what you meat as use the “day” I just combined as a new unit of measurement?, so if I didn’t answer your question, could you please clarify it?


#3

Yo!! many thanks @Siarhei. Now i can create a custom time unit hehe ^^~