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


# AnalyticsOptions

Selects which analytics a [`ScheduleResult`](<https://docs.dhtmlx.com/planning-engine/java/api/results/schedule-result.md>) carries. Create one with `new AnalyticsOptions()`, set flags with the fluent `withX` setters, and pass it as the `analytics` field of [`SolveOptions`](<https://docs.dhtmlx.com/planning-engine/java/api/project/solve-options.md>), [`PreviewOptions`](<https://docs.dhtmlx.com/planning-engine/java/api/project/preview-options.md>) or [`AnalyzeOptions`](<https://docs.dhtmlx.com/planning-engine/java/api/project/analyze-options.md>). Each of those fields defaults to `new AnalyticsOptions()`, which requests nothing.

## Declaration

```java
public class AnalyticsOptions extends ValueRecord implements DeepCloneable<AnalyticsOptions>
```

## Constructors

### AnalyticsOptions()

```java
public AnalyticsOptions()
```

Creates options with both flags `false`.

## Fields

| Field | Type | Default | Description |
|---|---|---|---|
| `slack` | `boolean` | `false` | `true` fills [`Analytics.slack`](<https://docs.dhtmlx.com/planning-engine/java/api/results/analytics.md>) with the total and free slack of each task. |
| `criticalPath` | `boolean` | `false` | `true` fills [`Analytics.criticalPath`](<https://docs.dhtmlx.com/planning-engine/java/api/results/analytics.md>) with the critical tasks and links. |

With both flags `false`, [`ScheduleResult.analytics`](<https://docs.dhtmlx.com/planning-engine/java/api/results/schedule-result.md>) is `null`. With either flag set, `ScheduleResult.analytics` is set, and a field whose flag is `false` stays `null`. Check [`Analytics.status`](<https://docs.dhtmlx.com/planning-engine/java/api/results/analytics.md>) before reading the fields.

## Methods

### withSlack

```java
public AnalyticsOptions withSlack(boolean value)
```

Sets `slack` and returns this instance for chaining.

**Parameters**

| Name | Type | Description |
|---|---|---|
| `value` | `boolean` | `true` to request slack |

**Returns** - this `AnalyticsOptions`.

### withCriticalPath

```java
public AnalyticsOptions withCriticalPath(boolean value)
```

Sets `criticalPath` and returns this instance for chaining.

**Parameters**

| Name | Type | Description |
|---|---|---|
| `value` | `boolean` | `true` to request the critical path |

**Returns** - this `AnalyticsOptions`.

### deepClone

```java
public AnalyticsOptions deepClone()
```

Returns a copy with the same `slack` and `criticalPath`.

**Returns** - a new `AnalyticsOptions`.

### copy

```java
public AnalyticsOptions copy()
```

Returns a shallow copy. `AnalyticsOptions` holds only `boolean` fields, so the result is the same as `deepClone()`.

**Returns** - a new `AnalyticsOptions`.

### equals, hashCode, toString

```java
public boolean equals(Object other)
public int hashCode()
public String toString()
```

Inherited from [`ValueRecord`](<https://docs.dhtmlx.com/planning-engine/java/api/support/value-record.md>). Two `AnalyticsOptions` are equal when `slack` and `criticalPath` are equal. `toString()` lists the fields, e.g. `AnalyticsOptions{slack=true, criticalPath=false}`.

## Example

```java
// `project` already holds solved data.
AnalyzeOptions options = new AnalyzeOptions()
    .withAnalytics(new AnalyticsOptions().withCriticalPath(true).withSlack(true));

Analytics analytics = project.analyze(null, options).analytics;
```

## Related

- [`Analytics`](<https://docs.dhtmlx.com/planning-engine/java/api/results/analytics.md>) - the slack and critical path it selects
- [`SolveOptions`](<https://docs.dhtmlx.com/planning-engine/java/api/project/solve-options.md>) - carries it for solve and schedule
- [`PreviewOptions`](<https://docs.dhtmlx.com/planning-engine/java/api/project/preview-options.md>) - carries it for preview
- [`AnalyzeOptions`](<https://docs.dhtmlx.com/planning-engine/java/api/project/analyze-options.md>) - carries it for analyze
- [Critical path and slack](<https://docs.dhtmlx.com/planning-engine/java/scheduling/critical-path-and-slack.md#requesting-analytics>) - requesting and reading analytics
