Baseline in Angular Gantt component
26 Aug 20257 minutes to read
The baseline feature in the Gantt component enables comparison between original planned schedules and actual task execution timelines. This visualization provides clear insights into schedule deviations, helping assess project performance and identify areas requiring attention. Baseline functionality displays both the original planned timeline and current progress side-by-side for comprehensive project tracking.
Before implementing baseline functionality, ensure the data source includes baseline date fields and configure the taskFields
object with appropriate field mappings. The baseline feature requires proper field mapping to display planned versus actual timelines effectively.
Baseline fields:
- baselineStartDate: Represents the originally planned start date of a task. This value is used to compare against the actual start date to identify schedule deviations.
- baselineEndDate: Represents the originally planned end date of a task. It is used to compare against the actual end date.
-
baselineDuration: Represents the total planned duration of the task. This value is critical for baseline visualization. To represent a baseline milestone, this property must be explicitly set to 0. Setting
baselineStartDate
andbaselineEndDate
to the same value without setting baselineDuration to 0 will result in a one-day baseline task, not a milestone.
Implement baseline
To enable baseline, configure the Gantt component by setting renderBaseline
to true
, mapping baselineStartDate
, baselineEndDate
, and optionally baselineDuration
in taskFields
. To customize appearance set the baselineColor
property or the .e-baseline-bar
CSS class for advanced styling.
export let projectData = [
{
TaskID: 1,
TaskName: 'Project Planning',
StartDate: new Date('02/04/2019'),
EndDate: new Date('02/08/2019'),
baselineStartDate: new Date('02/02/2019'),
baselineEndDate: new Date('02/06/2019'),
baselineDuration: '5' // Regular baseline
},
{
TaskID: 2,
TaskName: 'Milestone Review',
StartDate: new Date('02/10/2019'),
EndDate: new Date('02/10/2019'),
baselineStartDate: new Date('02/09/2019'),
baselineEndDate: new Date('02/09/2019'),
baselineDuration: '0' // Milestone baseline
}
];
public baselineColor: string = 'rgba(255, 107, 107, 0.8)'; // Semi-transparent red baseline
.e-gantt .e-gantt-chart .e-baseline-bar {
height: 4px;
border-radius: 2px;
opacity: 0.9;
background-color: #4CAF50;
}
The following example demonstrates complete baseline configuration with proper field mapping:
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { GanttModule } from '@syncfusion/ej2-angular-gantt'
import { SelectionService } from '@syncfusion/ej2-angular-gantt'
import { Component, ViewEncapsulation, OnInit } from '@angular/core';
import { Gantt } from '@syncfusion/ej2-gantt';
import { baselineData } from './data';
@Component({
imports: [GanttModule],
providers: [SelectionService],
standalone: true,
selector: 'app-root',
template:
`<ejs-gantt id="ganttDefault" height="430px" [dataSource]="data" [taskFields]="taskSettings" [columns]="columns" [timelineSettings]="timelineSettings" [renderBaseline]="true" [treeColumnIndex]="1" height="450px" [allowSelection]="true" durationUnit="Minute" dateFormat="hh:mm a" [projectStartDate]="projectStartDate" [projectEndDate]="projectEndDate" [dayWorkingTime]="dayWorkingTime" [includeWeekend]="true" baselineColor='red'></ejs-gantt>`,
encapsulation: ViewEncapsulation.None
})
export class AppComponent{
// Data for Gantt
public data?: Object[];
public taskSettings?: object;
public columns?: object[];
public timelineSettings?: object;
public labelSettings?: object;
public tooltipSettings?: object;
public projectStartDate?: Date;
public projectEndDate?: Date;
public dayWorkingTime?: object[];
public ngOnInit(): void {
this.data = baselineData;
this.taskSettings = {
id: 'TaskId',
name: 'TaskName',
startDate: 'StartDate',
endDate: 'EndDate',
progress: 'Progress',
baselineStartDate: 'BaselineStartDate',
baselineEndDate: 'BaselineEndDate',
child: 'subtasks'
};
this.columns = [
{ field: 'TaskName', headerText: 'Service Name', width: '250' },
{ field: 'BaselineStartDate', headerText: 'Planned start time' },
{ field: 'BaselineEndDate', headerText: 'Planned end time' },
{ field: 'StartDate', headerText: 'Start time' },
{ field: 'EndDate', headerText: 'End time' },
];
this.dayWorkingTime = [{ from: 0, to: 24 }];
this.timelineSettings = {
timelineUnitSize: 70,
topTier: {
unit: 'None',
},
bottomTier: {
unit: 'Minutes',
count: 15,
format: 'hh:mm a'
},
};
this.projectStartDate= new Date('03/05/2018 09:30:00 AM');
this.projectEndDate= new Date('03/05/2018 7:00:00 PM');
}
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
For a comprehensive demonstration of baseline functionality, explore the interactive sample.