Auto scheduling
The functionality is available in PRO Edition only
Overview
The feature allows you to maintain valid schedules automatically, reducing manual updates and potential errors.
Auto scheduling enables cascading adjustments of tasks in Gantt based on their dependencies. When enabled, the system automatically moves dependent tasks forward when their predecessors are modified.
- Only forward propagation is supported. When a task's start, end, or duration changes, the system checks its outgoing links and moves successor tasks forward accordingly. Predecessors are never moved
- When a user moves a task, it is placed as close to the new dates as its links allow: a task moved earlier than its predecessors allow returns to the earliest allowed date. If the task's own constraint breaks a link, the link is reported as a conflict. Manually scheduled tasks keep the dates as set
- Tasks cannot start before the configured
projectStart: if defined, initial scheduling shifts tasks to start after the specified project start date - Cascading changes trigger the
schedule-tasksaction
Enabling auto scheduling
Auto scheduling is activated via the schedule property:
schedule?: {
auto?: boolean;
};
true– any changes to task start, end, or duration automatically move successor tasks forward according to the links between themfalse– tasks are moved only manually; dependencies are not automatically enforced
Example:
<script setup>
import { Gantt } from "@svar/vue-gantt";
import { getData } from "../data";
const data = getData();
</script>
<template>
<Gantt :tasks="data.tasks" :links="data.links" :schedule="{ auto: true }" />
</template>
Tasks excluded from auto scheduling
Inactive tasks are skipped by auto scheduling entirely. Switching a task back to active re-runs auto scheduling.
Setting the lag
In the auto schedule mode, a link can have the lag property, defining the number of days between predecessor and successor tasks. The lag is counted from the end of the predecessor task for e2s and e2e links, and from its start for s2s and s2e ones.
lag sets the minimum gap: the successor is placed no earlier than lag days from the date the link requires. lag can be positive or negative. If lag is not set, it is 0.
const links = [
{ id: 1, source: 3, target: 4, type: "e2s", lag: 2 }, // starts no earlier than 2 days after task 3 ends
{ id: 2, source: 1, target: 2, type: "e2s" }, // no lag: starts no earlier than task 1 ends
{ id: 3, source: 5, target: 6, type: "s2s", lag: -1 }, // starts no earlier than 1 day before task 5 starts
];
A user can edit link lags in the Editor, where a dedicated field appears.
Manually scheduled tasks
In the auto schedule mode, Gantt moves tasks to keep the plan valid, so a date set by hand can be overwritten on the next recalculation. To keep a task on the dates you set, mark it as manually scheduled. Neither its incoming links nor its constraint push it anywhere, and only a user can move it to another date. Still, such a task drives the plan. Its successors are scheduled relative to it as usual, and conflicts of its links and constraint are still reported.
Manual scheduling has no dedicated Gantt property. To make a task manual, add the manual field to its data object:
{
id: 4,
text: "Fixed delivery",
start: new Date(2027, 3, 8),
duration: 3,
manual: true
}
A summary task can be manual as well. It keeps its own dates instead of taking them from its child tasks, and its child tasks stay in place when it is moved.
Gantt reads the field only in the auto schedule mode.
Switching the manual flag at runtime
You can switch the state of the task from "manual" to "auto" and back at any time, via UI or through the API.
via UI
-
In the Editor, use the Manual checkbox on the Scheduling tab. The checkbox is hidden for split task segments.
-
In the grid, there is no built-in column for the
manualvalue. To show the flag in the tasks tree, add a column with a custom cell component.
via API
You can change the "manual" state through the update-task action:
api.exec("update-task", { id: 4, task: { manual: false } });
Setting manual to false returns the task to auto scheduling and re-runs it, so the task is moved to the dates the plan requires. Setting manual to true pins the task in its current place, so the task doesn't move.
Handling invalid links
Auto schedule mode automatically manages invalid links to prevent conflicts.
Invalid link types:
- circular links: chains that loop back to the original task
- links between a summary task and its own child tasks, in either direction
- links from the start of a summary task (s2s, s2e) or to the end of a summary task (e2e, s2e)
If a task is moved in a way that causes a link to become invalid, the link is automatically removed. On initial load, all invalid links are removed when auto scheduling is active.
Behaviour during schedule modifications
Auto scheduling is triggered by any operation that affects the schedule:
- editing tasks (start, end, duration, type)
- adding, copying, or moving tasks to another parent
- adding or editing links
All such operations automatically run scheduling logic and fire the schedule-tasks action after the updates are applied.
Example
<script setup>
import { ref } from "vue";
import { getData } from "../data";
import { Gantt, Editor } from "@svar/vue-gantt";
const data = getData();
const api = ref(null);
</script>
<template>
<Editor :api="api" />
<Gantt
ref="api"
:tasks="data.tasks"
:links="data.links"
:scales="data.scales"
:schedule="{ auto: true }"
:projectStart="new Date(2024, 3, 2)"
/>
</template>
Related samples:
Related articles: