start_date
Description
设置时间刻度的起始值
start_date: Date | undefined
Example
gantt.config.start_date = new Date(2027, 8, 10);
gantt.config.end_date = new Date(2027, 8, 20);
gantt.init("gantt_here");
Details
注释
要应用 start_date 选项,必须与 end_date 一起使用。
- 如果同时指定 start_date 和 end_date 选项,并且你在该范围之外创建任务,任务将从图表中消失。
init()的可选参数可以用作 start_date 和 end_date 的初始值。- start_date 和 end_date 将覆盖 fit_tasks。如果你想把这些设置一起使用,你需要 从代码中管理时间尺度。
在这种情况下,我们可以扩展范围:
gantt.attachEvent("onLightboxSave", (taskId, task, isNew) => {
const taskStartDate = task.start_date;
const taskEndDate = task.end_date;
const scaleStartDate = gantt.config.start_date;
const scaleEndDate = gantt.config.end_date;
if (scaleStartDate > taskEndDate || scaleEndDate < taskStartDate) {
gantt.message({ type: "warning", text: "Warning! The task is outside the date range!", expire: 5000 });
return false;
}
return true;
});
Related API
Related Guides
Need help?
Got a question about the documentation? Reach out to our technical support team for help and guidance. For custom component solutions, visit the Services page.