getSlack

确定一个任务在当前持续时间单位内,在影响其他任务之前还有多少时间余量

number|string getSlack(object task1,object task2);

Deprecated

该方法已被弃用。

task1object第一个要检查余量的任务对象
task2object第二个要检查余量的任务对象
number|string两个任务之间的余量,单位为当前持续时间单位;如果任务之间没有链接,则返回 'Infinity'

Available only in PRO Edition

Example

const tasks = {
    data:[
       {id:1, text:"Project #1", start_date:"01-04-2013", duration:18, type:"project"},
       {id:2, text:"Task #1", start_date:"02-04-2013",duration:8, parent:1},
       {id:3, text:"Task #2", start_date:"13-04-2013",duration:8, parent:1}
    ],
    links:[
       {id:1, source:1, target:2, type:"1"},
       {id:2, source:2, target:3, type:"0"}
    ]
};
 
gantt.config.highlight_critical_path = true; 
gantt.init("gantt_here");
gantt.parse(tasks);
 
gantt.getSlack(gantt.getTask(2), gantt.getTask(3)); // -> 1

Related samples

Details

getSlack 方法已被弃用。请改用以下方法获取任务的自由余量或总余量:

gantt.getFreeSlack(task);
 
gantt.getTotalSlack(task);


getSlack 方法仅在 PRO 版本中可用。

该方法属于 critical_path 扩展的一部分,请确保在页面中包含此扩展。更多细节请参阅 关键路径 文章。

See also
Back to top