Skip to content
Advertisement

How to get starting plotted date and ending plotted date from DHTMLX Gantt chart

I am using the DHTMLX Gantt chart, Here I need to get the starting plotted date and ending plotted date from the Gantt. For example here start date is 31 Mar 2019 and the end Date is 7 Apr 2019 in the chart, I want this date without taking it from the JSON. Actually, I want to add some more days to the start date and end date that’s why I need it. Here is the code below.

HTML

JavaScript

Advertisement

Answer

There is an API called getState() for that if you want the starting date and ending date from the Gantt chart.

gantt.getState().min_date will give you the date that tasks are displayed in the chart from and gantt.getState().max_date will give you the date that tasks are displayed in the chart till. If you want a date before or after the starting date or ending date, you can add/subtract the number of days according to your need by this gantt.date.add(new Date(gantt.getState().max_date), -1, 'day'). Here is the working example:

JavaScript
Advertisement