Project#loadProfile#

Reads per-bucket load and capacity of resources on the solved baseline of a Project. Read-only, and needs a solved project. For the load of hypothetical dates, use preview with a profile query instead.

Signature#

public LoadProfile loadProfile(LoadProfileOptions options)

Synchronous and CPU-only. Doesn't change the project. Not synchronized: serialize calls on one instance.

Parameters#

Name Type Description
options LoadProfileOptions A ProfileQuery (range, resources, basis, task lists) and an optional baselineId check. Build it with new LoadProfileOptions(query). Must not be null

Returns#

A new LoadProfile for the baseline dates.

Errors#

All exceptions are unchecked.

Error When
ProjectException with code == ProjectError.NO_BASELINE The project is unsolved, including after apply
ProjectException with code == ProjectError.STALE_BASELINE options.baselineId doesn't name the current baseline
InputException to <= from, or more than 100 000 buckets per resource (path to); an unknown resource (path resources)
NullPointerException options is null

Example#

Print the overloaded days of a resource that works on two tasks at once.

import java.util.List;
import org.dhtmlx.plen.*;

public class LoadProfileExample {
  public static void main(String[] args) throws Exception {
    ProjectData data = new ProjectData()
        .withTasks(List.of(
            new TaskData(Id.str("a")).withStartDate(Moment.fromYmdHm(2026, 1, 1, 0, 0)).withDuration(2.0),
            new TaskData(Id.str("b")).withStartDate(Moment.fromYmdHm(2026, 1, 2, 0, 0)).withDuration(2.0)))
        .withResources(List.of(new ResourceData().withId(Id.str("dev"))))
        .withAssignments(List.of(
            new AssignmentData().withTask(Id.str("a")).withResource(Id.str("dev")).withValue(1.0),
            new AssignmentData().withTask(Id.str("b")).withResource(Id.str("dev")).withValue(1.0)));
    data.config.useCalendars = false;

    Project project = new Project();
    project.solve(data, new SolveOptions());

    ProfileQuery query = new ProfileQuery(Moment.fromYmdHm(2026, 1, 1, 0, 0), Moment.fromYmdHm(2026, 1, 5, 0, 0));
    LoadProfile profile = project.loadProfile(new LoadProfileOptions(query));
    for (ResourceLoad resource : profile.resources) {
      for (LoadBucket bucket : resource.buckets) {
        if (bucket.load > bucket.capacity) {
          System.out.println(resource.resource + " at " + bucket.start + ": " + bucket.load + " of " + bucket.capacity);
          // dev at 2026-01-02 00:00: 2.0 of 1.0
        }
      }
    }
  }
}