[Canonical page](<https://docs.dhtmlx.com/planning-engine/js/api/project-analyze/>)
[Full documentation index](<https://docs.dhtmlx.com/planning-engine/llms.txt>)


# Project#analyze

Computes analytics over dates without scheduling them. It reads either the supplied [`ProjectData`](<https://docs.dhtmlx.com/planning-engine/js/api/types/project-data.md>) or the current dates of the [`Project`](<https://docs.dhtmlx.com/planning-engine/js/api/project.md>), including unsolved edits. It never installs data, and it never changes the baseline or the solved status. Unlike [`preview`](<https://docs.dhtmlx.com/planning-engine/js/api/project-preview.md>), it works on an unsolved project.

## Signature

```ts
analyze(data: ProjectData | null, options?: AnalyzeOptions): ScheduleResult
```

Synchronous. Never mutates the project.

## Parameters

| Name | Type | Description |
|---|---|---|
| `data` | [`ProjectData`](<https://docs.dhtmlx.com/planning-engine/js/api/types/project-data.md>) \| `null` | Dates to analyze, or `null` for the project's current dates. Never mutated. |
| `options` | [`AnalyzeOptions`](<https://docs.dhtmlx.com/planning-engine/js/api/project-analyze.md#analyzeoptions>) | Optional. Which analytics to compute. Default `{}`: none. |

### AnalyzeOptions

The analytics to compute.

| Field | Type | Default | Description |
|---|---|---|---|
| `analytics` | [`AnalyticsOptions`](<https://docs.dhtmlx.com/planning-engine/js/api/types/common.md#analyticsoptions>) | none | `criticalPath` adds critical task and link ids, `slack` adds total and free slack per task. Without it, `analytics` is absent from the result. |

## Behavior

- With `data`, the call validates and reads the data but doesn't install it. The project's own tasks, baseline and cached result stay as they were. On a project created with `validation: "repair"`, the supplied data is repaired first, and each fix is reported as a `repaired` note.
- With `null`, the call reads the dates the project holds now. After [`apply`](<https://docs.dhtmlx.com/planning-engine/js/api/project-apply.md>), these include the applied edits that haven't been solved yet.
- A project that needs `solve(null)` before the call still needs it after.

## Returns

A [`ScheduleResult`](<https://docs.dhtmlx.com/planning-engine/js/api/types/schedule-result.md>) with `cycles`, `notes`, `analytics` and `overallocations`. `updates` and `conflicts` are always empty arrays, and `converged` is `true`. `baselineId` is present only for `null` on a solved project with no unsolved edits.

## Errors

| Error | When |
|---|---|
| [`InputError`](<https://docs.dhtmlx.com/planning-engine/js/api/types/errors.md>) | `data` or `options` fails parsing or validation; `kind`, `message` and `path` name the field. Also thrown for a non-finite number or an invalid `Date` in the input. |
| `TypeError` | The input has a circular reference or a `BigInt`. |
| `Error("Project has been disposed")` | The project was disposed. |

`analyze` never throws [`ProjectError`](<https://docs.dhtmlx.com/planning-engine/js/api/types/errors.md>).

## Example

Get the critical path of dates stored elsewhere, without scheduling them.

```js
import { Project } from "plen-js";

const data = {
  tasks: [
    { id: "design", start_date: "2026-01-05 00:00", duration: 2 },
    { id: "build", start_date: "2026-01-07 00:00", duration: 3 },
  ],
  links: [{ id: "l1", source: "design", target: "build", type: "fs" }],
};

const project = new Project();
const result = project.analyze(data, { analytics: { criticalPath: true } });

console.log(`critical tasks: ${result.analytics?.criticalPath?.tasks.join(", ")}`);
```

## Related

- [`Project`](<https://docs.dhtmlx.com/planning-engine/js/api/project.md>) - the class and its other methods
- [`AnalyticsOptions`](<https://docs.dhtmlx.com/planning-engine/js/api/types/common.md#analyticsoptions>) - which analytics to compute
- [`ScheduleResult`](<https://docs.dhtmlx.com/planning-engine/js/api/types/schedule-result.md#analytics>) - the returned `analytics`
- [Critical path and slack](<https://docs.dhtmlx.com/planning-engine/js/scheduling/critical-path-and-slack.md>) - requesting and reading analytics
