Dhtmlxgantt初始化如何定位在当前日期

刚进页面获取系统时间,将甘特图的滚动条定位在当前日期所在的位置如下图:

Hello @ypj9607,

Could you please post your questions in English? We won’t be able to understand you otherwise.

Regarding the question: as I understood through the google translate, you want your gantt chart to be scrolled to the current date after it’s initialized, am I right?
You can use the showDate() method to scroll the gantt chart to the passed date:
https://docs.dhtmlx.com/gantt/api__gantt_showdate.html
for that.

Or if you meant to display month label in the cases if it’s hidden in the left/right edge of the chart, you can use this workaround:
http://snippet.dhtmlx.com/5/a4fc4b492

Which lets you get the visible date by the scroll position and insert it into some “div” element.

Here is the main part of the code with a couple of comments:


gantt.attachEvent("onGanttScroll", function (left, top){
  // Get the element which will be container for the date
  var element = document.querySelector("#monthDisplay")
  // Get the date by the current scroll position(and format it)
  var date = dateToStr(gantt.dateFromPos(left));
  // Insert it to the HTML element
  element.innerHTML = date;
});

If you meant something else, could you please clarify your question?

hello,You answered my question very well. The problem has been solved!