а

Dynamically gets the time on the timescale


#1

Because when rendering the data, I need to decide which time period the data is displayed according to the time scale. For example, I have a data that needs to be displayed in the interval of May 18th to May 31st, but the data of the data set corresponds to the two periods of May 18th to May 20th and May 24th to May 31st.Because this is in the same data set, I need to know exactly what time it is on the right hand side.


#2

Hi @yangyun15757!

You can set the date range explicitly by using the start_date and end_date configuration options:
https://docs.dhtmlx.com/gantt/api__gantt_start_date_config.html
https://docs.dhtmlx.com/gantt/api__gantt_end_date_config.html

Here is a sample you can see how it can be implemented for your dates:
http://snippet.dhtmlx.com/b4a01a3a3

Also, you can set the gantt.config.fit_tasks = true. The Gantt chart will automatically extend the time scale in order to fit all displayed tasks. Please check this article:
https://docs.dhtmlx.com/gantt/api__gantt_fit_tasks_config.html
Please check this sample:
https://docs.dhtmlx.com/gantt/samples/03_scales/08_scale_autoconfig.html

If you meant something different - please clarify.


#3

Since I cannot accurately determine the time of the data set, I need to compare the data set with the time scale.


#4

Hi @yangyun15757!

Sorry, I’m still not sure I completely understand.
Do you mean you need to know the time (min date and max date) of the time scale in gantt?
If so - please check this method https://docs.dhtmlx.com/gantt/api__gantt_getstate.html


#5

For example, if the time scale is many grids, and the current time is one grid, then I need to know the current time of the grid.


#6

Hi @yangyun15757!

Unfortunately the description still not clear. Please send me screenshots:

  1. with many grids
  2. with one grid
  3. display the current time of the grid that you mean.
    I hope screenshots will help me understand your issue and how to solve it.