Baseline in React Gantt component

11 Sep 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 and baselineEndDate 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.
    }
];

  const baselineColor = '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 * as React from 'react';
import * as ReactDOM from 'react-dom';
import { GanttComponent } from '@syncfusion/ej2-react-gantt';
import { baselineData } from './datasource';

function App (){
   const taskFields = {
      id: 'TaskID',
      name: 'TaskName',
      startDate: 'StartDate',
      progress:'Progress',
      duration:'Duration',
      baselineStartDate: 'BaselineStartDate',
      baselineEndDate: 'BaselineEndDate',
      baselineDuration: 'BaselineDuration',
      parentID: 'ParentID'
  };
  
    return <GanttComponent dataSource={baselineData} renderBaseline={true} baselineColor='red'
    taskFields={taskFields} height = '430px'>
        
    </GanttComponent>
    
};
ReactDOM.render(<App />, document.getElementById('root'));
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { GanttComponent } from '@syncfusion/ej2-react-gantt';
import { baselineData } from './datasource';

function App (){
   const taskFields: any = {
    id: 'TaskID',
    name: 'TaskName',
    startDate: 'StartDate',
    progress:'Progress',
    duration:'Duration',
    baselineStartDate: 'BaselineStartDate',
    baselineEndDate: 'BaselineEndDate',
    baselineDuration: 'BaselineDuration',
    parentID: 'ParentID'
  };
  
    return <GanttComponent dataSource={baselineData} renderBaseline={true} baselineColor='red'
    taskFields={taskFields} height = '430px'>
        
    </GanttComponent>
    
};
ReactDOM.render(<App />, document.getElementById('root'));
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Syncfusion React Gantt</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="Essential JS 2 for React Components" />
    <meta name="author" content="Syncfusion" />
    <link href="https://cdn.syncfusion.com/ej2/31.1.17/material.css" rel="stylesheet" type="text/css"/>
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
    <script src="systemjs.config.js"></script>
     <style>
        #loader {
            color: #008cff;
            height: 40px;
            left: 45%;
            position: absolute;
            top: 45%;
            width: 30%;
        }
    </style>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>

<body>
        <div id='root'>
            <div id='loader'>Loading....</div>
        </div>
</body>

</html>