Skip to main content
Configure the Markers Script in Widget Parameters > Advanced > Markers Script.

Script Variables

The following variables are available in the Markers Script scope:
VariableTypeDescription
markerFactoryMarkerFactoryFactory object for creating and registering timeline markers.
trackerServiceITrackerServicePolarion tracker service for querying work items and projects via Lucene queries.
configConfiguration objectThe current Gantt configuration, including page parameters and context project ID.

MarkerFactory Methods

MethodReturn TypeDescription
markerFactory.addMarker()MarkerCreate and register a new empty marker object. Set its properties using the marker methods below.
markerFactory.addMarker(text, date)MarkerUtility method that creates a marker with the specified text label and date string. Date format: "YYYY-MM-DD".
markerFactory.addPlanMarkers(query, color)voidQuery Polarion plans matching the Lucene query and add a marker for each plan’s start or end date.
markerFactory.addWorkItemMarkers(query, dateProperty, color)voidQuery Polarion work items matching the Lucene query and add a marker for each work item using the specified date property.

Marker Object Methods

The marker object returned by addMarker() provides these methods:
MethodParameter TypeDescription
marker.setText(text)StringSet the text label displayed on the marker line.
marker.setTitle(tooltip)StringSet the tooltip text displayed when hovering over the marker.
marker.setDate(date)java.util.DateSet the marker date using a Java Date object.
marker.setDate(dateStr)StringSet the marker date using a date string. Format: "YYYY-MM-DD".
marker.setColor(color)StringSet the marker color. Must be one of the 16 basic HTML color names (e.g., "red", "blue", "green", "fuchsia").
Hovering over a milestone marker displays a tooltip in the format: Milestone: <name> followed by Due Date: <YYYY-MM-DD>.

Marker Positioning

Markers render at the end of the specified date by convention. If you need a marker to appear at the start of a date, subtract one day from the date value.
By design, a marker set to "2025-08-04" renders at the end of August 4th. To position it at the start of August 4th, set the date to "2025-08-03" instead.

Manually Adding a Marker

Create a marker with explicit values:
var marker = markerFactory.addMarker();
marker.setText("20.0");
marker.setDate("2025-08-04");
marker.setColor("green");
Using the shorthand method:
markerFactory.addMarker("test", "2019-01-30");

Adding Markers from Plans

Pull markers automatically from Polarion plans matching a Lucene query:
markerFactory.addPlanMarkers("template.id:iteration AND project.id:gantt2", "blue");
  • template.id:iteration — filters plans by template ID
  • project.id:gantt2 — restricts to a specific project
Plan-based markers receive the CSS class plan, enabling distinct visual styling.

Adding Markers from Work Items

Pull markers from Polarion work items matching a Lucene query:
markerFactory.addWorkItemMarkers("type:release AND project.id:gantt2", "publicLaunch", "blue");
  • type:release — filters work items by type
  • "publicLaunch" — the date field on the work item used to position the marker
  • "blue" — the marker color

Dynamic Project ID

Use config.getContextProjectId() to reference the current project instead of hardcoding:
markerFactory.addWorkItemMarkers(
    "type:release AND project.id:" + config.getContextProjectId(),
    "publicLaunch",
    "blue"
);

Dynamic Markers with Polarion API

Use trackerService for full scripting control over marker creation. This approach supports filtering, conditional coloring, and custom tooltip content.

Loading Time Points

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());
    }
}
Since Polarion version 2304, use getter methods instead of direct property access. Use tp.getName() instead of tp.name. Use tp.getTime().getDate() instead of tp.time.date.

Polarion 22 R2 and Older

For older Polarion versions, use direct property access:
var timePoints = trackerService.getTrackerProject("GANTT").getTimePoints().iterator();
while (timePoints.hasNext()) {
    var tp = timePoints.next();
    var marker = markerFactory.addMarker();
    marker.setText(tp.name);
    marker.setDate(tp.time.date);
    marker.setColor("fuchsia");
    var desc = tp.description;
    if (desc != null) {
        marker.setTitle(desc.content);
    }
}

Dynamic Marker Customization with Page Parameters

Combine trackerService with page parameters to let users control which markers appear:
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());
    var productType = tp.getValue('productType');
    marker.setColor("blue");

    if (productType !== null && productType.getId() === 'typeB') {
        marker.setColor("fuchsia");
    }
}

Marker CSS Classes

CSS ClassApplied ToDescription
gantt_markerAll markersBase class applied to every marker element.
todayToday markerApplied to the automatic today-date marker line.
planPlan markersApplied to markers created by addPlanMarkers().
Named color class (e.g., blue)Custom markersApplied when a color is specified via setColor().
diagram

Error Handling

  • Script errors display as a warning indicator with a count badge in the Gantt toolbar
  • The error message includes the prefix Markers Script Error:
  • Errors appear in both view mode and wiki editor mode

Configuration Example

A complete Markers Script combining plan markers, work item markers, and a manual milestone:
// Add iteration boundary markers
markerFactory.addPlanMarkers(
    "template.id:iteration AND project.id:" + config.getContextProjectId(),
    "blue"
);

// Add release markers from work items
markerFactory.addWorkItemMarkers(
    "type:release AND project.id:" + config.getContextProjectId(),
    "start",
    "red"
);

// Add a manual milestone
var marker = markerFactory.addMarker();
marker.setText("Go-Live");
marker.setDate("2025-12-01");
marker.setColor("green");
KB ArticlesSupport TicketsSource Code
  • prod-gantt-src/com.nextedy.polarion.gantt/src/com/nextedy/polarion/gantt/model/MarkerFactory.java
  • prod-gantt-src/com.nextedy.polarion.gantt.client/cypress/e2e/ganttCheckWarningInfo.cy.ts
  • prod-gantt-src/com.nextedy.polarion.gantt.client/cypress/e2e/milestones/milestone-tooltip-date.cy.ts
  • prod-gantt-src/com.nextedy.polarion.gantt.client/cypress/e2e/view/markersStyles.cy.ts
  • prod-gantt-src/com.nextedy.polarion.gantt.client/cypress/e2e/milestones/marker-colors.cy.ts