> ## 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.

# Create and Configure Markers

> This guide shows you how to add vertical timeline markers in Nextedy GANTT to highlight key dates such as version releases, iteration boundaries, and project deadlines.

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>;
};

## Access the Markers Script

Markers are defined in the **Markers Script**, located under **Widget Properties > Advanced > Markers Script**. This server-side script runs each time the Gantt loads and produces the set of marker lines displayed on the timeline.

<Frame>
  <img src="https://mintcdn.com/none-17b4493f/E5md2k2_IvgOAoTX/gantt/images/48001274428/1.png?fit=max&auto=format&n=E5md2k2_IvgOAoTX&q=85&s=3f17be0f54e422c312aafebedc894529" alt="Gantt timeline showing vertical milestone marker lines across the chart" width="1050" height="276" data-path="gantt/images/48001274428/1.png" />
</Frame>

The script has access to the `markerFactory` object, which provides methods for creating markers manually and from Polarion data.

## Add a Marker Manually

To create a single marker at a specific date, use the `markerFactory.addMarker()` method:

```javascript theme={null}
var marker = markerFactory.addMarker();
marker.setText("20.0");
marker.setDate("2025-08-04");
marker.setColor("green");
```

This creates a green vertical line labeled "20.0" on August 4, 2025.

<Frame>
  <img src="https://mintcdn.com/none-17b4493f/E5md2k2_IvgOAoTX/gantt/images/48001274428/2.png?fit=max&auto=format&n=E5md2k2_IvgOAoTX&q=85&s=528bfa2453ed0133cb5544bf2285caaf" alt="Green milestone marker labeled 20.0 on the August 4 column of the Gantt timeline" width="687" height="268" data-path="gantt/images/48001274428/2.png" />
</Frame>

The marker object provides these methods:

| Method                         | Description                                                 |
| :----------------------------- | :---------------------------------------------------------- |
| `setText(String text)`         | Set the marker label displayed on the timeline              |
| `setTitle(String tooltip)`     | Set the tooltip text shown on hover                         |
| `setDate(String dateStr)`      | Set the marker date (format: `"YYYY-MM-DD"`)                |
| `setDate(java.util.Date date)` | Set the marker date from a Java Date object                 |
| `setColor(String color)`       | Set the marker color (one of the 16 basic HTML color names) |

<Warning title="Marker position follows end-of-day convention">
  Markers render at the end of the specified date. If you set a marker to "2025-08-04", the vertical line appears at the end of August 4th. To position a marker at the start of a date, subtract one day from the date value in your script.
</Warning>

## Add Markers from Plans

Use `addPlanMarkers` to automatically create markers from Polarion Plan items matching a Lucene query:

```javascript theme={null}
markerFactory.addPlanMarkers("template.id:iteration AND project.id:gantt2", "blue")
```

This creates a blue marker for each iteration plan in the project "gantt2". The marker date is taken from the plan's date range.

## Add Markers from Work Items

Use `addWorkItemMarkers` to create markers from work items, specifying which date field to use:

```javascript theme={null}
markerFactory.addWorkItemMarkers("type:release AND project.id:gantt2", "start", "red")
```

| Parameter       | Description                                                                     |
| :-------------- | :------------------------------------------------------------------------------ |
| First argument  | Lucene query filtering which work items to include                              |
| Second argument | The date field to read the marker date from (e.g., `"start"`, `"publicLaunch"`) |
| Third argument  | Marker color                                                                    |

<Frame>
  <img src="https://mintcdn.com/none-17b4493f/E5md2k2_IvgOAoTX/gantt/images/48001274428/3.png?fit=max&auto=format&n=E5md2k2_IvgOAoTX&q=85&s=e57fb7cac4e30644b32249fb5b7dd610" alt="Blue markers generated from release-type work items, dated from their Public Launch custom field" width="696" height="238" data-path="gantt/images/48001274428/3.png" />
</Frame>

To reference the current project dynamically instead of hard-coding the project ID:

```javascript theme={null}
markerFactory.addWorkItemMarkers(
    "type:release AND project.id:" + config.getContextProjectId(),
    "publicLaunch",
    "blue"
)
```

<Tip title="Use custom date fields for release markers">
  When marking version releases, point the date field parameter to a custom field like `publicLaunch` rather than the task's scheduling dates. This lets you track external release dates independently from the work item's planned schedule.
</Tip>

<Frame>
  <img src="https://mintcdn.com/none-17b4493f/E5md2k2_IvgOAoTX/gantt/images/48001274428/4.png?fit=max&auto=format&n=E5md2k2_IvgOAoTX&q=85&s=49e6f13168d512a6f410414e1d55ad32" alt="Marker for Version 3.0 positioned at 2025-06-02, the value of its Public Launch field" width="1082" height="324" data-path="gantt/images/48001274428/4.png" />
</Frame>

## Use the Polarion API for Dynamic Markers

For full scripting control, use the `trackerService` API to query Polarion data and build markers dynamically. This approach supports conditional logic, custom tooltips, and color-coding based on field values.

**Example: Load Time Points as markers:**

```javascript theme={null}
var timePoints = trackerService.getTrackerProject("GANTT")
    .getTimePoints().iterator();

while(timePoints.hasNext()) {
    var tp = timePoints.next();
    var marker = markerFactory.addMarker();
    marker.setText(tp.getName());
    marker.setDate(tp.getTime().getDate());
    marker.setColor("fuchsia");
    var desc = tp.getDescription();
    if(desc != null) {
        marker.setTitle(desc.getContent());
    }
}
```

<Frame>
  <img src="https://mintcdn.com/none-17b4493f/E5md2k2_IvgOAoTX/gantt/images/48001274428/5.png?fit=max&auto=format&n=E5md2k2_IvgOAoTX&q=85&s=ed18edead7d2840fd1482ddec1fbd29d" alt="Fuchsia markers on the timeline, one per Polarion Time Point" width="543" height="194" data-path="gantt/images/48001274428/5.png" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/none-17b4493f/E5md2k2_IvgOAoTX/gantt/images/48001274428/6.png?fit=max&auto=format&n=E5md2k2_IvgOAoTX&q=85&s=52f84fa248203b1e8e0c75f4f19a234b" alt="Time Points list defined in the Polarion Gantt project that drive the markers" width="545" height="181" data-path="gantt/images/48001274428/6.png" />
</Frame>

**Example: Dynamic markers from page parameters:**

```javascript theme={null}
var milestoneIds = config.pageParameters.milestone;
if(milestoneIds === null) {
    milestoneIds = "";
} else {
    milestoneIds = milestoneIds.replaceAll(',', ' ');
}

var milestones = trackerService.queryWorkItems(
    "project.id:Gantt3 AND type:milestone AND id:(" + milestoneIds + ")",
    "id"
).iterator();

while(milestones.hasNext()) {
    var tp = milestones.next();
    var marker = markerFactory.addMarker();
    marker.setText(tp.getTitle());
    marker.setDate(tp.getValue('releaseDate').getDate());
    marker.setColor("blue");
}
```

This example works with Milestone-type work items that carry two custom fields: `releaseDate` (a date) and `productType` (an enumeration with values such as typeA, typeB, and typeC).

<Frame>
  <img src="https://mintcdn.com/none-17b4493f/E5md2k2_IvgOAoTX/gantt/images/48001274428/7.png?fit=max&auto=format&n=E5md2k2_IvgOAoTX&q=85&s=727b90877e47b75211b41af2461b3eae" alt="Milestone work item showing the releaseDate and productType custom fields" width="1008" height="430" data-path="gantt/images/48001274428/7.png" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/none-17b4493f/E5md2k2_IvgOAoTX/gantt/images/48001274428/8.png?fit=max&auto=format&n=E5md2k2_IvgOAoTX&q=85&s=1b0593e9f419fc903d3c37c3ce951b0b" alt="productType enumeration values typeA, typeB and typeC on a milestone work item" width="996" height="518" data-path="gantt/images/48001274428/8.png" />
</Frame>

Define the page parameter that drives the query as an Enumeration-type parameter so editors get a dropdown of milestone work items. Its ID must match the one referenced in the script — here, `milestone`.

<Frame>
  <img src="https://mintcdn.com/none-17b4493f/E5md2k2_IvgOAoTX/gantt/images/48001274428/9.png?fit=max&auto=format&n=E5md2k2_IvgOAoTX&q=85&s=e78e2397b297343e2f7ef986e722411d" alt="Edit-mode dialog creating an Enumeration page parameter with ID milestone" width="914" height="868" data-path="gantt/images/48001274428/9.png" />
</Frame>

This reads a comma-separated list of work item IDs from the `milestone` page parameter, queries them, and renders each as a marker. Changing the page parameter updates which markers appear without editing the script.

As a result, only the selected work items appear as markers, dated from their `releaseDate` field. Milestones 1 and 3 appear blue because their `productType` has a value, while Milestone 2 is pink because its `productType` is typeB.

<Frame>
  <img src="https://mintcdn.com/none-17b4493f/E5md2k2_IvgOAoTX/gantt/images/48001274428/10.png?fit=max&auto=format&n=E5md2k2_IvgOAoTX&q=85&s=d741e46081482423844d92a0d784d6c7" alt="Selected milestones rendered as markers, two blue and one pink, by productType value" width="1306" height="460" data-path="gantt/images/48001274428/10.png" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/none-17b4493f/E5md2k2_IvgOAoTX/gantt/images/48001274428/11.png?fit=max&auto=format&n=E5md2k2_IvgOAoTX&q=85&s=c7c73e7cca27f6f24b06e3ff8d717029" alt="Gantt timeline with blue Milestone 1 and 3 markers and a pink Milestone 2 marker" width="1046" height="1366" data-path="gantt/images/48001274428/11.png" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/none-17b4493f/E5md2k2_IvgOAoTX/gantt/images/48001274428/12.png?fit=max&auto=format&n=E5md2k2_IvgOAoTX&q=85&s=0deb6ddfb7bec73eb7f6fb4867fb16f3" alt="Close-up of the color-coded milestone markers placed at their releaseDate positions" width="1046" height="1366" data-path="gantt/images/48001274428/12.png" />
</Frame>

To switch the displayed markers quickly, add a Page Parameters Block widget to the same page as the Gantt and expose the `milestone` parameter there.

<Frame>
  <img src="https://mintcdn.com/none-17b4493f/E5md2k2_IvgOAoTX/gantt/images/48001274428/13.png?fit=max&auto=format&n=E5md2k2_IvgOAoTX&q=85&s=49d98edcf6456f537bce637f51bf5a3d" alt="Page Parameters Block widget configured with the milestone parameter" width="770" height="511" data-path="gantt/images/48001274428/13.png" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/none-17b4493f/E5md2k2_IvgOAoTX/gantt/images/48001274428/14.png?fit=max&auto=format&n=E5md2k2_IvgOAoTX&q=85&s=6c94c85130e36f7fcbed241bc8dcf47b" alt="Finished Gantt page with the milestone selector and color-coded markers in place" width="1978" height="868" data-path="gantt/images/48001274428/14.png" />
</Frame>

## Marker CSS Classes

Markers receive CSS classes based on their type, which you can use for custom styling:

| CSS Class      | Applied To                                           |
| :------------- | :--------------------------------------------------- |
| `today`        | The automatic today-date marker                      |
| `plan`         | Markers created from Plan items via `addPlanMarkers` |
| `gantt_marker` | All custom markers (base class)                      |

To keep only the marker line and hide its header label, add a script-block widget above the Gantt that sets `.gantt_marker_content { display: none; }`. The result shows the marker line without its text header.

<Frame>
  <img src="https://mintcdn.com/none-17b4493f/E5md2k2_IvgOAoTX/gantt/images/48001274428/16.png?fit=max&auto=format&n=E5md2k2_IvgOAoTX&q=85&s=892b4ab2ce91684ce6838fb31022eeb0" alt="Gantt marker rendered as a bare vertical line with its header label hidden" width="1073" height="180" data-path="gantt/images/48001274428/16.png" />
</Frame>

<Warning title="Markers Script errors are displayed to users">
  If the Markers Script contains a syntax or runtime error, the Gantt displays a warning indicator with the message prefix "Markers Script Error:". This warning is visible to all users viewing the page, not just to page editors. Test your scripts thoroughly before deploying.
</Warning>

## Marker Tooltips

Hovering over a marker line displays a tooltip showing the marker name and date. Set the tooltip content using `marker.setTitle()` for custom tooltip text, or let the Gantt generate a default tooltip from the marker text and date.

<Frame>
  <img src="https://mintcdn.com/none-17b4493f/E5md2k2_IvgOAoTX/gantt/images/48001274428/15.png?fit=max&auto=format&n=E5md2k2_IvgOAoTX&q=85&s=022b8cfc067eef94a47c0099b6fee692" alt="Marker tooltip shown on hover, displaying the marker title and due date" width="1924" height="840" data-path="gantt/images/48001274428/15.png" />
</Frame>

## Verification

You should now see vertical marker lines on the Gantt timeline at the configured dates. Hover over each marker to verify the tooltip displays the expected name and date. If markers do not appear, check the Markers Script for errors using the warning indicator in the Gantt toolbar area.

## See also

* [Configure Milestone Work Items](/gantt/guides/visualization/milestones)
* [Create Markers with Scripts](/gantt/guides/scripting/marker-scripts)
* [Configure Page Parameters](/gantt/guides/layout/page-parameters)
* [Customize Gantt Tooltips](/gantt/guides/visualization/tooltips)
* [Show Deadlines and Due Dates](/gantt/guides/visualization/deadlines)

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