Skip to main content

How Plan Progress Works

In the Plans Gantt, plan bars do not have a built-in progress calculation. You use an Item Script to query work items assigned to each plan, compute a completion ratio, and display it on the Gantt chart. The script runs server-side for each plan item, calculating progress as the ratio of resolved work items to total work items in the plan.

Step 1: Add the Gantt Config Script

Open the Plans Gantt widget parameters and navigate to Advanced > Gantt Config Script. Add the following script to display progress as right-side text on each plan bar:
gantt.templates.rightside_text = function(start, end, task) {
    return (task.progress > 0
        ? "Progress: <b>" + Math.round(task.progress * 100) + " % (" + task.fields.progressString + ")</b>"
        : "");
};
This script renders progress text to the right of each plan bar, showing both the percentage and the resolved/total count.

Step 2: Add the Item Script

Navigate to Advanced > Item Script and add the server-side computation:
var allitems = trackerService.queryWorkItems(
    "PLAN:(" + plan.getProjectId() + "/" + plan.getId() + ")", "id"
).size();
var openitems = trackerService.queryWorkItems(
    "PLAN:(" + plan.getProjectId() + "/" + plan.getId() + ") AND HAS_VALUE:resolution", "id"
).size();
if (allitems > 0) {
    task.progress = openitems / allitems;
} else {
    task.progress = 0;
}
task.getFields().put("progressString", openitems + " / " + allitems + " done");
This script:
  1. Queries all work items assigned to the current plan
  2. Queries work items with a resolution (resolved items)
  3. Computes progress as the ratio of resolved to total
  4. Stores a human-readable string for display
diagram

Step 3: Derive Work Item Schedule from Plans

If work items under your plans are unplanned (no start/end dates), you can derive their schedule from the plan assignment. Add this to the Item Script section of your Work Items configuration:
if (typeof wi !== 'undefined') {
    if (task.unplanned) {
        task.deriveScheduleFromPlans(wi, "iteration");
    }
}
Always wrap work item script logic with a typeof wi !== 'undefined' check. If the script runs on a plan item that has no backing work item, wi is undefined and the script throws an error. See Migrate Scripts for Polarion 2304+ for details.
The progress value is computed each time the Gantt loads or refreshes data. Editing work item resolution status outside the Gantt requires a Gantt refresh to update the progress display.

Customizing the Progress Query

You can adjust the progress calculation by modifying the Lucene query in the item script. For example, to count only items with status “done” instead of any resolution:
var openitems = trackerService.queryWorkItems(
    "PLAN:(" + plan.getProjectId() + "/" + plan.getId() + ") AND status:done", "id"
).size();

Verification

You should now see progress percentages displayed to the right of each plan bar in the Plans Gantt, showing text like “Progress: 75% (3 / 4 done)”. Plans with no assigned work items show no progress text.

See Also

KB ArticlesSupport TicketsSource Code
  • prod-gantt-src/com.nextedy.polarion.gantt.client/cypress/e2e/Rewritten Tests/testGanttCreatePlan.cy.ts
  • prod-gantt-src/com.nextedy.polarion.gantt/src/com/nextedy/polarion/gantt/model/impl/CustomFieldService.java
  • prod-gantt-src/com.nextedy.polarion.gantt.client/cypress/e2e/Rewritten Tests/testGanttPlansInInline.cy.ts
  • prod-gantt-src/com.nextedy.polarion.gantt/src/com/nextedy/polarion/gantt/model/impl/WorkItemsGanttDataService.java
  • prod-gantt-src/com.nextedy.polarion.gantt.client/cypress/e2e/GanttCreatePlan.cy.ts