By default you can set the item progress manually by dragging the progress bar. In long-mid term planning this produces more reliable results, to have human in the loop and asses the progress manually.
For short-mid term items, you may want to calculate the progress automatically, to do so, you can use Gantt scripting.
Calculate the progress
Add following lines into Widget Properties > Advanced > Item Script
if(wi.getType().getId()==='workpackage'){ var all = ( wi.getRemainingEstimate()!=null ? wi.getRemainingEstimate().getHours() : 0 ) + ( wi.getTimeSpent()!=null ? wi.getTimeSpent().getHours() : 0 ); var done = ( wi.getTimeSpent()!=null ? wi.getTimeSpent().getHours() : 0 ); if(wi.getResolution()!=null){ task.progress = 1; }else if(all==0){ task.progress = 0; }else{ task.progress = done / all; } var progressString = ( wi.getTimeSpent()!=null ? wi.getTimeSpent() : "0h" ) + " | " + ( wi.getRemainingEstimate()!=null ? wi.getRemainingEstimate() : "0h" ) + " (" + Math.round(task.progress*100) + " %)"; task.getFields().put("progressString", progressString); }
Notes:
- The script above calculates the progress only for work items of type workpackage. You shall change the item type on line 1 or completely remove the IF statement.
- On line 14 we prepare a text, that we later can show on the gantt, see bellow.
- You can adjust the line 2 based on your preference - if the progress shall be calculated as timeSpent/initialEstimate , or as proposed above timeSpent / (remainingEstimate + timeSpent)
Disable the progress drag
As we are calculating the progress automatically we need to disable progress drag.
Add following line into Widget Properties > Advanced > Gantt Config Script
gantt.config.drag_progress = false;
Show the progress in the Gantt
You may want to show the progress information in the gantt:
To do so add following fragment into Widget Properties > Advanced > Gantt Config Script
gantt.config.drag_progress = false; 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 : ""); };
The text was prepared in the Item Script, line 14. So it shows:
#Status #TimeSpent | #Remaining Estimate | ( #Progress %)
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article