Skip to content

Resolve overallocated tasks with JavaScript Gantt resource leveling ​

Sam is scheduled to commission a machine and write handover notes on the same two days. Both tasks need all of Sam’s time. RevoGrid Gantt can flag the overload and delay the lower-priority task until Sam is free.

The React example shows the dates in warning and automatic modes. It also shows how protecting the handover task changes which task moves. Your application can review the proposed schedule before saving it.

Run the example ​

The React example uses pinned Gantt and Pro trial packages.

sh
git clone https://github.com/revolist/revogrid-docs.git
cd revogrid-docs/examples/gantt-workflows
npm ci
npm run dev

Open the address printed by Vite and choose Resource leveling. Verify expected dates executes the public scheduling engine against the fixture, including the protected-task case. The trial is an evaluation build; see trial limitations before using its bundle size or startup time as production measurements.

For a larger editable project, open the resource planning demo and the resource leveling documentation.

Set up two tasks that need the same engineer ​

Sam has allocationCapacity: 100. Both assignments request allocationUnits: 100. Each task requires 16 hours, or two eight-hour working days, starting Monday, July 13, 2026. There are no dependencies and no holidays in this fixture.

TaskPriorityInitial datesSam's allocation
Commission machine900July 13–14100%
Write handover notes100July 13–14100%

The two assignments require 200% of Sam's 100% capacity on both dates. A dependency-valid project can therefore still be impossible to staff. Dependencies describe the order of work; resource capacity describes whether the people or equipment can perform it.

The fixture uses the public ProjectSnapshot shape. Its numeric task duration values are canonical hours. Use explicit units when accepting user input; avoid interpreting the same bare number as hours in one layer and days in another.

ts
export function createLevelingProject(protectDocumentation = false) {
  return project({
    tasks: [
      task('commission', 'Commission machine', { priority: 900 }),
      task('document', 'Write handover notes', {
        priority: 100,
        canLevel: !protectDocumentation,
      }),
    ],
    resources: [
      {
        id: 'sam',
        name: 'Sam',
        role: 'Engineer',
        calendarId: 'standard',
        allocationCapacity: 100,
        hourlyCost: 60,
      },
    ],
    assignments: [
      {
        id: 'sam-commission',
        taskId: 'commission',
        resourceId: 'sam',
        allocationUnits: 100,
        responsibility: 'Commission the machine',
      },
      {
        id: 'sam-document',
        taskId: 'document',
        resourceId: 'sam',
        allocationUnits: 100,
        responsibility: 'Prepare handover notes',
      },
    ],
  });
}

The helper functions and the standard Monday–Friday calendar are included in the companion's projects.ts. Assignments have their own stable IDs and reference task and resource IDs. A resource name is display data and should not be used as the relationship key.

Report the conflict before changing dates ​

Start with warning mode:

ts
const scheduling = {
  excludeHolidaysFromDuration: true,
  resourceLeveling: 'warn' as const,
};

Pass this object as gantt.scheduling. Warning mode leaves the authored dates in place and reports resource-overallocation conflicts. The example's table also calls createSchedulerEngine().recalculate(project, scheduling), so the proposed dates and diagnostic codes are visible independently of the timeline.

Keep invalid-data issues separate from scheduling conflicts. A missing resource reference is a malformed plan. Two valid assignments exceeding capacity are a scheduling conflict. A resource-leveling-adjustment is an explanation of a change, rather than evidence that the final plan remains overallocated.

See the exact data contracts in resources and assignments.

Turn on automatic leveling ​

ts
import { createSchedulerEngine } from '@revolist/gantt';

const result = createSchedulerEngine().recalculate(project, {
  excludeHolidaysFromDuration: true,
  resourceLeveling: 'auto',
  resourceLevelingWithinSlack: false,
});

const unresolved = result.conflicts.filter(
  (conflict) => conflict.code === 'resource-overallocation',
);

createSchedulerEngine is exported by @revolist/gantt. The same options work through the grid's gantt.scheduling configuration. For the fixture, enabling Auto-level produces:

TaskBeforeAfterWhy
Commission machineJuly 13–14July 13–14Priority 900 is considered before priority 100
Write handover notesJuly 13–14July 15–16It moves beyond the occupied interval

Sam now has one assignment per working day. The lower-priority task receives a resource-leveling-adjustment diagnostic and a two-calendar-day levelingDelayDays value. The duration of each task remains two working days.

This example deliberately allows the project finish to move. With resourceLevelingWithinSlack: true, the engine limits movement to the task's calculated slack before leveling. A conflict can remain when that slack is insufficient. Inspect the result instead of treating the option as a promise to solve every overload.

Protect a task without raising its priority ​

Set canLevel: false when a task must stay fixed for resource leveling. In the example, select Protect handover notes while automatic leveling is enabled.

TaskResult with notes protected
Write handover notesJuly 13–14
Commission machineJuly 15–16

The fixed task is placed before the priority ordering. Raising Commission's priority does not override the protection. canLevel: false controls the leveling pass; it is different from locked, which controls packaged task editing.

Automatic leveling also excludes manual tasks, summary tasks, inactive tasks, tasks carrying actual start/finish dates, and tasks with must-start-on or must-finish-on constraints. These exclusions can leave an overload unresolved. The leveling guide lists the supported controls.

Show capacity and explain the change ​

The Show resource load switch uses the Gantt resource-planning projection:

ts
const resourcePlanning = {
  enabled: true,
  loadGranularity: 'day' as const,
  capacityDisplay: 'line' as const,
  overAllocationDisplay: 'highlight' as const,
};

The projection switches the grid to resource rows and displays allocation against capacity. It does not create assignments or change capacity. Keep the task view available so users can inspect which task caused a load segment.

For an approval workflow, keep the original snapshot, calculate the candidate, and show a table of changed task IDs, dates, and diagnostic messages. Persist the complete accepted change with a server revision check. If another planner changed the project, reload and recalculate before accepting it; otherwise a correct local calculation may overwrite a newer assignment.

The React component keeps scenario inputs stable between renders and changes them only when the user chooses a policy. It uses ordinary React rendering and the RevoGrid React wrapper.

Check for overloads that leveling leaves unresolved ​

The current engine delays tasks; it does not split a task automatically, add people, reduce assignment units, or optimize the whole portfolio for minimum finish date. Automatic shifts apply to forward scheduling from the project start. Project-finish scheduling remains warning-only for resource leveling.

Resource load and this leveling pass use date-level allocation. Do not use the example as a minute-by-minute room-reservation lock. For resource reservations, use a Scheduler workflow with authoritative overlap validation on the server.

After leveling, check remaining allocation warnings, dependencies, constraints, deadlines, and the project finish. A task may have several resources, and moving it can affect its successors. A successful calculation and a visually separated pair of bars are not sufficient acceptance criteria for a larger plan.

Use the working-calendar tutorial when staff availability differs by weekday or holiday. If the starting plan comes from Microsoft Project, review import conversion limits before relying on imported resource data. The Gantt scheduling overview connects these policies to the full scheduling model.