Skip to main content

Where to Add Marker Scripts

Open your Gantt widget parameters, expand the Advanced section, and locate the Markers Script field. All marker scripts go here. The script has access to markerFactory, trackerService, and config objects.

Marker Factory API

The markerFactory object provides these methods:
MethodPurpose
markerFactory.addMarker()Create a new empty marker object
markerFactory.addMarker(text, date)Create a marker with text and date string
markerFactory.addPlanMarkers(query, color)Add markers from Polarion plans matching a Lucene query
markerFactory.addWorkItemMarkers(query, dateField, color)Add markers from work items matching a Lucene query
The marker object returned by addMarker() has these setter methods:
MethodPurpose
marker.setText(String)Set the marker label
marker.setTitle(String)Set the tooltip text
marker.setDate(Date)Set the date (java.util.Date)
marker.setDate(String)Set the date as string ("2025-08-04" format)
marker.setColor(String)Set the color (one of the 16 basic HTML colors)

Add a Manual Marker

Create a fixed marker at a specific date:
var marker = markerFactory.addMarker();
marker.setText("20.0");
marker.setDate("2025-08-04");
marker.setColor("green");
This adds a green vertical line labeled “20.0” at August 4, 2025.

Add Markers from Plans

Automatically generate markers from Polarion plan boundaries (iterations, sprints):
markerFactory.addPlanMarkers(
    "template.id:iteration AND project.id:gantt2",
    "blue"
)
For the current project, use config.getContextProjectId() instead of a hardcoded project ID:
markerFactory.addPlanMarkers(
    "template.id:iteration AND project.id:" + config.getContextProjectId(),
    "blue"
)

Add Markers from Work Items

Generate markers from work items of a specific type using a date field:
markerFactory.addWorkItemMarkers(
    "type:release AND project.id:" + config.getContextProjectId(),
    "publicLaunch",
    "blue"
)
The second parameter ("publicLaunch") specifies which date field on the work item provides the marker date.

Use Polarion API for Dynamic Markers

For full scripting control, use trackerService to query work items and create markers programmatically. This example loads Polarion project 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());
    }
}
On Polarion 2304 and later, use tp.getName() and tp.getTime().getDate() instead of tp.name and tp.time.date. See Migrate Scripts for Polarion 2304+.

Filter Markers with Page Parameters

Use page parameters to let users control which markers appear. This example reads a milestone page parameter and renders matching work items as markers:
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");
}
Markers render at the end of the specified date. If you need a marker at the start of a day, subtract one day from the date value in your script.

Marker Styling

Markers automatically receive CSS classes based on their source:
Marker TypeCSS ClassDefault Appearance
Today markertodayHighlighted vertical line
Plan markersplanStyled as plan boundary lines
Custom markersgantt_marker + color classDefault styling with optional color
Hovering over a marker displays a tooltip showing the marker name and due date.

Handle Script Errors

If the Markers Script contains errors, the Gantt chart displays a warning indicator in the footer with the prefix Markers Script Error:. Check the browser console for details. See Debug Script Errors for systematic debugging.

Verify Your Changes

Save the page and reload the Gantt chart. You should now see vertical marker lines on the timeline at the specified dates, with labels and colors matching your script configuration. Hover over markers to confirm tooltip text displays correctly.

See Also

KB ArticlesSupport TicketsSource Code
  • prod-gantt-src/com.nextedy.polarion.gantt.client/cypress/e2e/ganttCheckWarningInfo.cy.ts
  • prod-gantt-src/com.nextedy.polarion.gantt/src/com/nextedy/polarion/gantt/model/MarkerFactory.java
  • prod-gantt-src/com.nextedy.polarion.gantt/src/com/nextedy/polarion/gantt/widget/PlansGanttWidget.java
  • prod-gantt-src/com.nextedy.polarion.gantt.client/src/js/nextedy.js
  • prod-gantt-src/com.nextedy.polarion.gantt.client/cypress/e2e/view/markersStyles.cy.ts