Tracking Gant bar style

Hi,

I need to change the right-text on a Tracking Gantt. I would like to change the text for the bar style “Critical” from %completed to Duration10 (which contains values calculated via a formula). Can you please give me some pointers on how to do this?

Thanks in advance,

Hi Ian,


Thank you for writing to Aspose Support team.

Could you please elaborate your requirements with the help of a sample file that has this data available? We need to identify the requirement exactly in order to assist you further. If possible, please help us by elaborating the requirement with a screenshot. We’ll be thankful to you in this regard.

Hi Kashif,

The Gantt I’m having a problem with is the Tracking-Gantt. I’ve baselined the project, changed the start time for some of the tasks, and want to use the tracking-Gantt to illustrate the change. The user requirement is to change the default right bar text label from “%Complete” to either the “Duration10” field for tasks or to “Field5” for summary tasks.

I’ve attached a screen-shot from Project 2016 to help explain what I’m trying to achieve.

Thanks!

Hi Ian,

Thank you for the elaboration.

In order to achieve this, you need to change the bar style for the Tracking Gantt view of the project. The following code sample demonstrates this for “Task” by assigning “Text10” value to the right side of the bar. It assumes that:

  1. Project already has Tracking Gantt view
  2. The “Task” style is at index 3 of bar styles collection

Please try the code at your end and let us know your feedback.

Sample Code:

static void TrackingGanttBarStyles()
{
    Project project = new Project(“BarStyles.mpp”);
    //GanttChartView view = project.DefaultView as GanttChartView;
    GanttChartView view = project.Views.ToList()[3] as GanttChartView;
    DisplayViewBarStylesInformation(view);
    //take the Task style and change its RightField
    GanttBarStyle style = view.BarStyles[3];
    style.RightField = Field.TaskText10;
    MPPSaveOptions options = new MPPSaveOptions();
    options.WriteViewData = true;
    project.Save(“BarStylesModified.mpp”, options);
    Console.WriteLine("\nAfter loading the saved file…\n");
    project = new Project(“BarStylesModified.mpp”);
    view = project.Views.ToList()[3] as GanttChartView;
    DisplayViewBarStylesInformation(view);
}

static void DisplayViewBarStylesInformation(GanttChartView view)
{
    Console.WriteLine("View Name: " + view.Name);
    Console.WriteLine("Bar style count: " + view.BarStyles.Count);
    Console.WriteLine("Custom bar style count: " + view.CustomBarStyles.Count);
    //pick the Task style and set its RightField
    GanttBarStyle style = view.BarStyles[3];
    //foreach (GanttBarStyle style in view.BarStyles)
    {
        Console.WriteLine(style.Name + “—” +style.RightField);
    }
}