GanttBarStyle.TopBarTextConverter
Contents
[
Hide
]GanttBarStyle.TopBarTextConverter property
Gets or sets user-defined converter to get text to render on the top of the task’s bar. Overrides the value of TopField
property.
public TaskBarTextConverter TopBarTextConverter { get; set; }
Remarks
Is not persisted to MPP format.
Examples
Shows how to use custom bar styles of Gantt Chart view.
var project = new Project(DataDir + "Project2.mpp");
var ganttChartView = (GanttChartView)project.Views.First(v => v.Name == "Gantt &Chart");
PdfSaveOptions saveOptions = new PdfSaveOptions();
saveOptions.Timescale = Timescale.DefinedInView;
saveOptions.ViewSettings = ganttChartView;
// Bar styles can be either task-specific (located in GanttChartView.CustomBarStyles)
// of category-specific (located in GanttChartView.BarStyles)
foreach (GanttBarStyle ganttBarStyle in ganttChartView.CustomBarStyles)
{
if (ganttBarStyle.ShowForTaskUid != 4)
{
continue;
}
// For demonstration purposes we are modifying style for Task with Unique ID = 4
// Here we set field (TaskName) to render to the left of the task bar.
ganttBarStyle.LeftField = Field.TaskName;
// Here we set custom converter to control which text should be rendered inside the task bar.
ganttBarStyle.InsideBarTextConverter = task => "Hours rem.: " + (int)task.Get(Tsk.RemainingWork).TimeSpan.TotalHours;
ganttBarStyle.MiddleShapeColor = Color.Green;
ganttBarStyle.MiddleShape = GanttBarMiddleShape.LineTop;
ganttBarStyle.StartShape = GanttBarEndShape.LeftBracket;
ganttBarStyle.StartShapeColor = Color.Aqua;
ganttBarStyle.EndShape = GanttBarEndShape.RightBracket;
ganttBarStyle.EndShapeColor = Color.Aquamarine;
}
foreach (GanttBarStyle ganttBarStyle in ganttChartView.BarStyles)
{
if (!ganttBarStyle.ShowForCategories.Contains(GanttBarShowFor.Milestone))
{
continue;
}
// For demonstration purposes we are modifying styles applicable to milestone tasks.
ganttBarStyle.StartShape = GanttBarEndShape.Diamond;
ganttBarStyle.RightField = Field.TaskActualFinish;
ganttBarStyle.TopBarTextConverter = task => task.Get(Tsk.ActualStart).Day.ToString();
}
project.Save(OutDir + "WorkWithGanttChartViewBarStyles_out.pdf", saveOptions);
See Also
- delegate TaskBarTextConverter
- class GanttBarStyle
- namespace Aspose.Tasks.Visualization
- assembly Aspose.Tasks