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


# JsonProject.analyze

Computes analytics over dates without scheduling them. It reads either a supplied [`ProjectData`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/project-data.md>) snapshot or the current dates of the [`JsonProject`](<https://docs.dhtmlx.com/planning-engine/wasm/api/json-project.md>), including edits that haven't been solved yet. Use it instead of [`solve`](<https://docs.dhtmlx.com/planning-engine/wasm/api/project-solve.md>) when the dates are already final and only the critical path or slack is needed. It works on an unsolved project.

## Signature

```ts
analyze(data_json: string | null | undefined, options_json: string): string
```

Synchronous and read-only.

## Request

| Argument | Payload | Required | Description |
|---|---|---|---|
| `data_json` | [`ProjectData`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/project-data.md>) | no | Dates to analyze. `null` or `undefined` analyzes the project's current dates. |
| `options_json` | [`AnalyzeOptions`](<https://docs.dhtmlx.com/planning-engine/wasm/api/project-analyze.md#analyzeoptions>) | yes | Which analytics to compute. Send `"{}"` for none. |

### AnalyzeOptions

The options object for `analyze`. Unknown fields are rejected with a `parse` error. The object itself can't be `null`.

| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| `analytics` | [`AnalyticsOptions`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/common.md#analyticsoptions>) \| `null` | no | no analytics | Requests `criticalPath` and `slack`. Fills `analytics` in the result. `null` is the same as leaving it out. |

## Behavior

- With `data_json`, the data is validated and read but never installed. The project keeps its previous state, and its solved status doesn't change. When the project was created with `validation: "repair"`, the data is repaired first and the repairs are reported in `notes`.
- Without `data_json`, the project's current dates are read, including unsolved edits from [`apply`](<https://docs.dhtmlx.com/planning-engine/wasm/api/project-apply.md>). The project stays unsolved after the call if it was unsolved before.
- Nothing is scheduled: dates are taken as they are.

## Response

An [envelope](<https://docs.dhtmlx.com/planning-engine/wasm/wire-format.md#envelope>) with a [`ScheduleResult`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/schedule-result.md>):

- `updates` and `conflicts` are always empty, and `converged` is `true`.
- `cycles`, `notes` and `overallocations` describe the analyzed dates.
- `analytics` is present only when `options_json` requests it. Check its `status` before reading the data; see [`ScheduleResult`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/schedule-result.md>).
- `baselineId` is present only when `data_json` is omitted and the project is solved with no unsolved edits. Otherwise the field is left out.

## Errors

| `kind` | When |
|---|---|
| `parse` | `data_json` or `options_json` isn't valid JSON, has a wrong type or an unknown field, or `options_json` is `"null"` |
| `validation` | The supplied data fails validation, e.g. a task with fewer than two of `start_date`, `end_date` and `duration` (`path`: `tasks[0].start_date`) |

`analyze` doesn't return `project` errors and doesn't throw for bad input. Error kinds are described in [Error handling](<https://docs.dhtmlx.com/planning-engine/wasm/error-handling.md>).

## Example

Get the critical path and slack of dates stored elsewhere, without scheduling them. Task `build` starts a day later than link `l1` requires.

Request (`data_json`):

```json
{
  "tasks": [
    { "id": "design", "start_date": "2026-08-10 08:00", "duration": 2 },
    { "id": "build", "start_date": "2026-08-13 08:00", "duration": 3 }
  ],
  "links": [{ "id": "l1", "source": "design", "target": "build", "type": "fs" }]
}
```

Request (`options_json`):

```json
{ "analytics": { "criticalPath": true, "slack": true } }
```

Response:

```json
{
  "ok": true,
  "result": {
    "analytics": {
      "criticalPath": { "links": [], "tasks": ["build"] },
      "slack": [
        { "free": 1, "task": "design", "total": 1 },
        { "free": 0, "task": "build", "total": 0 }
      ],
      "status": "available"
    },
    "conflicts": [],
    "converged": true,
    "cycles": [],
    "notes": [],
    "updates": []
  }
}
```

The call from a Node.js host:

```js
const { JsonProject } = require("./pkg-node/plen_wasm.js");

const data = {
  tasks: [
    { id: "design", start_date: "2026-08-10 08:00", duration: 2 },
    { id: "build", start_date: "2026-08-13 08:00", duration: 3 },
  ],
  links: [{ id: "l1", source: "design", target: "build", type: "fs" }],
};
const options = { analytics: { criticalPath: true, slack: true } };

const project = new JsonProject("{}");
try {
  const response = JSON.parse(project.analyze(JSON.stringify(data), JSON.stringify(options)));
  if (!response.ok) {
    throw new Error(`${response.error.kind}: ${response.error.message}`);
  }
  console.log(response.result.analytics.criticalPath.tasks); // [ 'build' ]
} finally {
  project.free();
}
```

## Related

- [`ProjectData`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/project-data.md>) - the dates to analyze
- [`ScheduleResult`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/schedule-result.md>) - the result, with `analytics`
- [`AnalyticsOptions`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/common.md#analyticsoptions>) - the critical path and slack switches
- [`JsonProject.solve`](<https://docs.dhtmlx.com/planning-engine/wasm/api/project-solve.md>) - schedule and compute analytics in one call
- [Critical path and slack](<https://docs.dhtmlx.com/planning-engine/wasm/scheduling/critical-path-and-slack.md>) - what critical path and slack mean
