Auto scheduling
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 end-to-start 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 whether it has end-to-start dependencies and moves successor tasks forward accordingly
- When moving a task backward, the link constraint is respected: a task cannot start earlier than the end of its predecessor if connected via an end-to-start link
- 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 end-to-start linksfalse– tasks are moved only manually; dependencies are not automatically enforced
Cascading changes trigger the schedule-tasks action. It fires after all dependent tasks have been adjusted.
Example:
<script>
import { Gantt } from "@svar/svelte-gantt";
import { getData } from "../data";
const data = getData();
</script>
<Gantt tasks={data.tasks} links={data.links} schedule={{ auto: true }} />
Setting the lag
In auto schedule mode, links can have the lag property, defining the number of days between tasks.
If lag is not set, the system assumes a flexible lag, meaning the successor can start any time after the predecessor. If lag is set, the successor starts exactly lag days after the predecessor. lag can be positive or negative.
const links = [
{ id: 1, source: 3, target: 4, type: "e2s", lag: 2 }, // 2-day gap
{ id: 2, source: 1, target: 2, type: "e2s" }, // flexible lag
];
A user can edit end-to-start link lags in the Editor, where a dedicated field appears.
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
- summary-to-child links: links from a summary task to one of its child tasks
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, deleting, or reordering tasks
- adding, editing, or removing links
All such operations automatically run scheduling logic and fire the schedule-tasks action after the updates are applied.
Example
<script>
import { getData } from "../data";
import { Gantt, Editor } from "@svar/svelte-gantt";
const data = getData();
let api = $state();
</script>
<Editor {api} />
<Gantt
bind:this={api}
tasks={data.tasks}
links={data.links}
scales={data.scales}
schedule={{ auto: true }}
projectStart={new Date(2024, 3, 2)}
/>