Is it possible to display scales logically like D+0, D+1?


#1

Hi

I’m new to dhtmlx gantt.

We would like to be able to use gantt chart for creating a plan as a template, such that it can be reused multiple times.

In this case the user won’t know the start date when they are creating it, just that certain tasks may start on D+1 09:00 (on day 2 of the plan). I guess the same may apply at Hour and (potentially) Minute level as well.

Is it possible to use logical/relative dates within the gantt?

I have managed to get a reasonable starter (see attached) by forcing task times and using, but I am not aware of a way to show the day scale without showing an explicit date.

gantt.config.scales = [
    {unit: "hour", step: 1, format: "%H" },
    {unit: "minute", step: 1, format: "%i" }
];


#2

Hi @dhub,

Firstly, I should say that the gantt chart can’t exist without defined “start” and “end” dates and there is no way to change this behavior and al

Regarding using “relative” dates while creating tasks, you may implement custom lightbox controls which will use the “start date” of the gantt as “D”, and create tasks based on this variable, you can read about custom controls by the following links:
https://docs.dhtmlx.com/gantt/desktop__custom_editor.html

It may look like follows:
http://snippet.dhtmlx.com/5/eb27e2e38

Regarding just visual part, you can changer the format of the date scale using the template function, and return content that you need, it may look like the following fragment:

gantt.config.scales = [
  { unit: "day", step: 1, format: function(date){
     return "D" + String( gantt.columnIndexByDate(date) + 1) ;
  }}
];

Here is a demo:
http://snippet.dhtmlx.com/5/207a7ae2f

Helpful API:
Set the initial dates for the timescale:
https://docs.dhtmlx.com/gantt/api__gantt_start_date_config.html
Lightbox:
https://docs.dhtmlx.com/gantt/api__gantt_lightbox_config.html
Scales:
https://docs.dhtmlx.com/gantt/api__gantt_scales_config.html


#3

Hi @Siarhei.

That’s very helpful - I believe I can work with that.