> ## Documentation Index
> Fetch the complete documentation index at: https://learn.nextedy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Gantt Config Script API

> The Gantt Config Script in Nextedy GANTT executes client-side JavaScript when the Gantt chart initializes.

export const LastReviewed = ({date}) => {
  if (!date) return null;
  const formatted = new Date(`${date}T00:00:00Z`).toLocaleDateString("en-US", {
    year: "numeric",
    month: "long",
    day: "numeric",
    timeZone: "UTC"
  });
  return <p className="mt-10 text-sm text-gray-400 dark:text-zinc-500 not-prose">
      Last reviewed on {formatted}
    </p>;
};

Configure the Gantt Config Script in **Widget Parameters > Advanced > Gantt Config Script**.

## Execution Context

The Gantt Config Script runs once during chart initialization on the client side. It has access to the `gantt` object and its configuration properties.

<Frame>
  <img src="https://mintcdn.com/none-17b4493f/umKaPvHwUHw-ZQFM/gantt/diagrams/reference/api/config-script-api/diagram-1.svg?fit=max&auto=format&n=umKaPvHwUHw-ZQFM&q=85&s=0a2347a6844cc9fb2c54a884d91d82fb" alt="diagram" style={{ maxWidth: "900px", width: "100%" }} width="900" height="80" data-path="gantt/diagrams/reference/api/config-script-api/diagram-1.svg" />
</Frame>

<Note title="Execution Timing">
  The Gantt Config Script executes **before** the chart renders data. Modifications to `gantt.config` and `gantt.templates` take effect on the initial render. To apply changes after initialization, call `gantt.render()`.
</Note>

## Configuration Properties (gantt.config)

Control Gantt behavior by setting `gantt.config.*` properties:

### Interaction Properties

| Property                            | Type      | Default | Description                                                                                                                     |
| ----------------------------------- | --------- | ------- | ------------------------------------------------------------------------------------------------------------------------------- |
| `gantt.config.drag_links`           | `Boolean` | `true`  | Enable or disable creating dependency links by dragging between task bars. Set to `false` to prevent users from creating links. |
| `gantt.config.drag_progress`        | `Boolean` | `true`  | Enable or disable dragging the progress indicator on task bars. Set to `false` when progress is calculated automatically.       |
| `gantt.config.show_progress_colors` | `Boolean` | `true`  | Enable dynamic progress-based coloring (red, orange, blue, gray). Set to `false` for fully static coloring via `task.color`.    |

### Display Properties

| Property                          | Type      | Default | Description                                                                                                                  |
| --------------------------------- | --------- | ------- | ---------------------------------------------------------------------------------------------------------------------------- |
| `gantt.config.workingHoursPerDay` | `Integer` | `8`     | Default working hours per day for all resources. Overrides the server-side administration property for this widget instance. |

### Custom Working Hours Function

Define per-resource working hours:

```javascript theme={null}
gantt.config.workingHoursPerDayFunction = (resource) => {
    if (resource === "rProject") {
        return 4;
    }
    return 8;
};
```

<Tip title="Velocity Pre-processing">
  The Gantt Config Script supports Velocity expressions (`$project`, `$user`, `$trackerService`). Velocity runs on the server before the script reaches the client. Use this to dynamically build script content based on Polarion data.
</Tip>

## Template Functions (gantt.templates)

Override rendering templates to customize how task elements display:

### Right-Side Text

Display custom text to the right of each task bar:

```javascript theme={null}
gantt.templates.rightside_text = function(start, end, task) {
    return (task.progress > 0
        ? "Progress: <b>" + Math.round(task.progress * 100) + " %</b>"
        : "");
};
```

### Right-Side Text with Status Icon

```javascript theme={null}
gantt.templates.rightside_text = function(start, end, task) {
    return "<b><img src='" + task.fields.statusIcon + "'/> "
        + task.fields.statusName + "</b> "
        + (task.progress != null ? task.fields.progressString : "");
};
```

### Status Icon Only

```javascript theme={null}
gantt.templates.rightside_text = function(start, end, task) {
    return "<b><img src='" + task.fields.statusIcon + "'/></b>";
};
```

<Note title="Data Preparation">
  Template functions access data prepared by the Item Script via `task.fields.*`. Prepare your data in the Item Script using `task.getFields().put(KEY, VALUE)`, then reference it in templates as `task.fields.KEY`.
</Note>

## Common Configuration Patterns

### Disable Dependency Link Creation

```javascript theme={null}
gantt.config.drag_links = false;
```

### Disable Progress Dragging

```javascript theme={null}
gantt.config.drag_progress = false;
```

### Enable Static Coloring

Disable dynamic progress-based colors to use only `task.color` values set in the Item Script:

```javascript theme={null}
gantt.config.show_progress_colors = false;
```

### Combined Example

```javascript theme={null}
gantt.config.drag_progress = false;
gantt.config.show_progress_colors = false;
gantt.templates.rightside_text = function(start, end, task) {
    return (task.fields.owner
        ? "Owner: <b>" + task.fields.owner + "</b>"
        : "");
};
```

## REST API Endpoints

The Gantt chart communicates with the server via these REST API endpoints:

| Endpoint                 | Method | Description                                                                                                      |
| ------------------------ | ------ | ---------------------------------------------------------------------------------------------------------------- |
| `gantt/api/data`         | GET    | Serves Gantt data (tasks, links, resources). Requires `config` query parameter.                                  |
| `gantt/api/conf`         | GET    | Serves Gantt configuration data.                                                                                 |
| `gantt/api/fields`       | GET    | Returns custom field metadata for the lightbox form.                                                             |
| `api/clearCalendarCache` | GET    | Clears the server-side working calendar cache. Call after modifying calendar work items when caching is enabled. |

<Warning title="Authentication Required">
  All Gantt API endpoints require Polarion user authentication. Anonymous access is not supported.
</Warning>

## Error Handling

* Script errors display as a warning indicator with a count badge in the Gantt toolbar
* **Config Script Error:** prefix identifies errors from this script
* **Markers Script Error:** prefix identifies errors from the markers script
* **Item Script Error:** prefix identifies errors from the Item Script
* Errors appear in both view mode and wiki editor mode with different messages

## Configuration Example

A complete Gantt Config Script for a project tracking view:

```javascript theme={null}
// Disable progress drag (calculated in Item Script)
gantt.config.drag_progress = false;

// Set custom working hours
gantt.config.workingHoursPerDay = 7;

// Custom right-side text showing progress info
gantt.templates.rightside_text = function(start, end, task) {
    return "<b><img src='" + task.fields.statusIcon + "'/> "
        + task.fields.statusName + "</b> "
        + (task.progress != null ? task.fields.progressString : "");
};
```

## Related Pages

* [Item Script API](/gantt/reference/api/item-script-api) -- server-side script for data preparation
* [Velocity Context Variables](/gantt/reference/api/velocity-context) -- server-side variables for dynamic script generation
* [Item Color Legend](/gantt/reference/item-color-legend) -- how `show_progress_colors` affects task colors
* [Default Configuration Values](/gantt/reference/configuration/default-values) -- server-level property defaults
* [Dependency Types Reference](/gantt/reference/dependency-types) -- advanced dependency link types

<LastReviewed date="2026-07-02" />
