간트 차트 렌더링
개요
Gantt 차트는 프로젝트 일정, 작업 계층, 기간 및 종속성을 시각화하는 데 널리 사용됩니다. aspose.tasks.
Microsoft Project를 사용하면 사용자가 Gantt 차트에 표시되는 타임 스케일을 설정할 수 있습니다. (TimesCale은 Gantt 차트보기의 상단에 표시됩니다.) 필요한 시간 분해능을 정확하게 제공하기 위해 최대 3 개의 타임 스케일을 가질 수 있습니다.
aspose.tasks for .NET 은이 기능을 지원하고 다양한 시간 확장 설정으로 Gantt 차트를 렌더링 할 수 있습니다. Gantt 차트는 이러한 옵션을 사용하여 1 페이지 이미지로 렌더링 할 수 있습니다.
지원되는 출력 형식
간트 차트는 다음으로 내보낼 수 있습니다.
- jpeg/png/bmp - 문서 나 보고서에 포함됩니다
- tiff (multipage) - 인쇄 또는 보관 용
- PDF-보고서 스타일 렌더링에
pdfsaveoptions
를 사용합니다
일반적인 사용 사례에는 다음이 포함됩니다.
- 내부 대시 보드 또는보고 엔진과 통합
- 이해 관계자를위한 인쇄용 비주얼
- 감사 목적으로 프로젝트 상태를 보관합니다
타임 스케일 설정 및 이미지에 저장
ImagesAveOptions 클래스의 시간 규모 속성은 프로젝트의 시간 규모 설정을 결정합니다. 타임 스케일은 기본적으로 며칠로 설정됩니다. 다른 옵션은 달과 3 개월입니다.
다음 코드 샘플 :
- 프로젝트 파일을 읽습니다.
- 각각의 다른 타임 스케일 설정을 설정합니다.
- 파일을 디스크에 JPG로 저장합니다.
Key Rendering Settings
Property | Description |
---|---|
ImageSaveOptions.Timescale | Defines timeline scale (Days, Months, etc.) |
RollUpGanttBars | Enables rolled-up summary bars |
DrawNonWorkingTime | Toggles rendering of non-working hours/days |
TextFormatter | Customizes task labels dynamically |
StringAlignment | Controls alignment of text in columns |
UseGradientBrush | Enables MS Project–like gradient fill |
Rolling Up Gantt Bars During Rendering
- If the SaveOptions.RollUpGanttBars property is set to true, any summary task in the project is marked by its visible subtasks, keeping into account the Task.HideBar property when rendering. (If Task.HideBar = true, the bar is not rendered on the Gantt chart.)
- If SaveOptions.RollUpGanttBars = false, the subtask will be shown on the summary task anyway, provided that subtask.IsRollup and subtask.ParentTask.IsRollup are set to true.
Also, if SaveOptions.DrawNonWorkingTime (default value = true) is set to false, non-working time will not be shown on the Gantt chart.
Example 1: Gantt Chart Bars Not Rolled Up
The output from example 1
Example 2: Rolling Up Gantt Chart Bars
In this example, SaveOptions.RollUpGanttBars = true, SaveOptions.DrawNonWorkingTime = true, and task.HideBar = false for hidden tasks.
The output from example 2
Customize Text with Task Bars
In this example, the text on the right of the taskbar can be customized by delegate instance. Here we customize the text on the critical tasks.
Align Cell Contents
Text can be aligned by GanttChartColumn.StringAlignment, ResourceViewColumn.StringAlignment properties. Alignment by default is StringAlignment.Near (left).
Changing Gantt Chart Bars Color Gradient
Microsoft Project allows users to render the output of Gantt charts using gradients. The same functionality is provided by Aspose.Tasks as shown in the following sample code.
Setting Start date of Gantt Chart View
The TimeScaleStart property exposed by Prj class allows to set the start date of the Gantt chart view. However, if the saved file is opened by MSP in maximized window mode then the timescale start date will not match.
Aspose.Tasks for .NET provides comprehensive capabilities for exporting Gantt charts with full control over layout, style, and visual logic. Whether you’re generating visual reports, printing schedules, or embedding task data into dashboards — the flexible rendering engine supports your use case.
You can further explore: