How can I help you?
Timeline in React Gantt Chart Component
17 Mar 202624 minutes to read
The timeline in the React Gantt Chart component represents project durations as cells with defined units and formats, supporting in-built view modes like Hour-Minute, Day-Hour, Week-Day, Month-Week, Year-Month, and Minutes for flexible visualization. Configure modes using the timelineViewMode property, with top and bottom tiers customized via topTier.unit and bottomTier.unit in timelineSettings. This enables detailed views, such as weekly overviews with daily breakdowns for projects, ensuring accurate timeline representation.
Configure timeline view modes
Set the timeline view mode using the timelineViewMode property. This property allows you to switch the timeline between different units such as Day, Week, Month, and Year, where the top tier displays a broader unit and the bottom tier displays a finer one.
When both the topTier and bottomTier settings are defined, they take precedence over the timelineViewMode property. In this case, the timelineViewMode value will be ignored. To apply the timelineViewMode setting, ensure that topTier and bottomTier are assigned a null value or not configured.
Week timeline mode
In Week mode, the top tier shows weeks and the bottom tier days, suitable for short-term project tracking.
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { GanttComponent } from '@syncfusion/ej2-react-gantt';
import { data } from './datasource';
function App() {
const taskFields = {
id: 'TaskID',
name: 'TaskName',
startDate: 'StartDate',
endDate: 'EndDate',
duration: 'Duration',
progress: 'Progress',
parentID: 'ParentID'
};
const timelineSettings = {
timelineViewMode: 'Week'
};
return (
<GanttComponent
height="430px"
dataSource={data}
taskFields={taskFields}
timelineSettings={timelineSettings}
>
</GanttComponent>
);
}
ReactDOM.render(<App />, document.getElementById('root'));import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { GanttComponent, TaskFieldsModel, TimelineSettingsModel } from '@syncfusion/ej2-react-gantt';
import { data } from './datasource';
function App() {
const taskFields: TaskFieldsModel = {
id: 'TaskID',
name: 'TaskName',
startDate: 'StartDate',
endDate: 'EndDate',
duration: 'Duration',
progress: 'Progress',
parentID: 'ParentID'
};
const timelineSettings: TimelineSettingsModel = {
timelineViewMode: 'Week'
};
return (
<GanttComponent
height="430px"
dataSource={data}
taskFields={taskFields}
timelineSettings={timelineSettings}
>
</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/33.1.44/tailwind3.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>
</head>
<body>
<div id='root'>
<div id='loader'>Loading....</div>
</div>
</body>
</html>Month timeline mode
In Month mode, the top tier shows months and the bottom tier weeks, ideal for medium-term planning.
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { GanttComponent } from '@syncfusion/ej2-react-gantt';
import { data } from './datasource';
function App() {
const taskFields = {
id: 'TaskID',
name: 'TaskName',
startDate: 'StartDate',
endDate: 'EndDate',
duration: 'Duration',
progress: 'Progress',
parentID: 'ParentID'
};
const timelineSettings = {
timelineViewMode: 'Month',
timelineUnitSize: 150
};
return (
<GanttComponent
height="430px"
dataSource={data}
taskFields={taskFields}
timelineSettings={timelineSettings}
>
</GanttComponent>
);
}
ReactDOM.render(<App />, document.getElementById('root'));import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { GanttComponent, TaskFieldsModel, TimelineSettingsModel } from '@syncfusion/ej2-react-gantt';
import { data } from './datasource';
function App() {
const taskFields: TaskFieldsModel = {
id: 'TaskID',
name: 'TaskName',
startDate: 'StartDate',
endDate: 'EndDate',
duration: 'Duration',
progress: 'Progress',
parentID: 'ParentID'
};
const timelineSettings: TimelineSettingsModel = {
timelineViewMode: 'Month',
timelineUnitSize: 150
};
return (
<GanttComponent
height="430px"
dataSource={data}
taskFields={taskFields}
timelineSettings={timelineSettings}
>
</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/33.1.44/tailwind3.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>
</head>
<body>
<div id='root'>
<div id='loader'>Loading....</div>
</div>
</body>
</html>Year timeline mode
In Year mode, the top tier shows years and the bottom tier months, suitable for long-term projects.
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { GanttComponent } from '@syncfusion/ej2-react-gantt';
import { data } from './datasource';
function App() {
const taskFields = {
id: 'TaskID',
name: 'TaskName',
startDate: 'StartDate',
endDate: 'EndDate',
duration: 'Duration',
progress: 'Progress',
parentID: 'ParentID'
};
const timelineSettings = {
timelineViewMode: 'Year',
timelineUnitSize: 70
};
return (
<GanttComponent
id="ganttDefault"
height="430px"
dataSource={data}
taskFields={taskFields}
timelineSettings={timelineSettings}
>
</GanttComponent>
);
}
ReactDOM.render(<App />, document.getElementById('root'));import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { GanttComponent, TaskFieldsModel, TimelineSettingsModel } from '@syncfusion/ej2-react-gantt';
import { data } from './datasource';
function App() {
const taskFields: TaskFieldsModel = {
id: 'TaskID',
name: 'TaskName',
startDate: 'StartDate',
endDate: 'EndDate',
duration: 'Duration',
progress: 'Progress',
parentID: 'ParentID'
};
const timelineSettings: TimelineSettingsModel = {
timelineViewMode: 'Year',
timelineUnitSize: 70
};
return (
<GanttComponent
id="ganttDefault"
height="430px"
dataSource={data}
taskFields={taskFields}
timelineSettings={timelineSettings}
>
</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/33.1.44/tailwind3.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>
</head>
<body>
<div id='root'>
<div id='loader'>Loading....</div>
</div>
</body>
</html>Day timeline mode
In Day mode, the top tier shows days and the bottom tier hours, ideal for detailed daily scheduling.
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { GanttComponent } from '@syncfusion/ej2-react-gantt';
import { data } from './datasource';
function App() {
const taskFields = {
id: 'TaskID',
name: 'TaskName',
startDate: 'StartDate',
endDate: 'EndDate',
duration: 'Duration',
progress: 'Progress',
dependency: 'Predecessor',
parentID: 'ParentID'
};
const timelineSettings = {
timelineViewMode: 'Day'
};
return (
<GanttComponent
height="430px"
dataSource={data}
taskFields={taskFields}
timelineSettings={timelineSettings}
>
</GanttComponent>
);
}
ReactDOM.render(<App />, document.getElementById('root'));import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { GanttComponent, TaskFieldsModel, TimelineSettingsModel } from '@syncfusion/ej2-react-gantt';
import { data } from './datasource';
function App() {
const taskFields: TaskFieldsModel = {
id: 'TaskID',
name: 'TaskName',
startDate: 'StartDate',
endDate: 'EndDate',
duration: 'Duration',
progress: 'Progress',
dependency: 'Predecessor',
parentID: 'ParentID'
};
const timelineSettings: TimelineSettingsModel = {
timelineViewMode: 'Day'
};
return (
<GanttComponent
height="430px"
dataSource={data}
taskFields={taskFields}
timelineSettings={timelineSettings}
>
</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/33.1.44/tailwind3.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>
</head>
<body>
<div id='root'>
<div id='loader'>Loading....</div>
</div>
</body>
</html>Hour timeline mode
In Hour mode, the top tier shows hours and the bottom tier minutes, perfect for minute-level task tracking.
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { GanttComponent } from '@syncfusion/ej2-react-gantt';
import { data } from './datasource';
function App() {
const taskFields = {
id: 'TaskID',
name: 'TaskName',
startDate: 'StartDate',
duration: 'Duration',
progress: 'Progress',
parentID: 'ParentID'
};
const timelineSettings = {
timelineViewMode: 'Hour'
};
return (
<GanttComponent
id="ganttDefault"
height="430px"
dataSource={data}
taskFields={taskFields}
timelineSettings={timelineSettings}
>
</GanttComponent>
);
}
ReactDOM.render(<App />, document.getElementById('root'));import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { GanttComponent, TaskFieldsModel, TimelineSettingsModel } from '@syncfusion/ej2-react-gantt';
import { data } from './datasource';
function App() {
const taskFields: TaskFieldsModel = {
id: 'TaskID',
name: 'TaskName',
startDate: 'StartDate',
duration: 'Duration',
progress: 'Progress',
parentID: 'ParentID'
};
const timelineSettings: TimelineSettingsModel = {
timelineViewMode: 'Hour'
};
return (
<GanttComponent
id="ganttDefault"
height="430px"
dataSource={data}
taskFields={taskFields}
timelineSettings={timelineSettings}
>
</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/33.1.44/tailwind3.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>
</head>
<body>
<div id='root'>
<div id='loader'>Loading....</div>
</div>
</body>
</html>Minutes timeline mode
In Minutes timeline mode, the tier displays minute-level intervals, ideal for tracking short-duration tasks with high precision.
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { GanttComponent } from '@syncfusion/ej2-react-gantt';
import { data } from './datasource';
function App() {
const taskFields = {
id: 'TaskID',
name: 'TaskName',
startDate: 'StartDate',
endDate: 'EndDate',
duration: 'Duration',
progress: 'Progress',
parentID: 'ParentID'
};
const timelineSettings = {
timelineViewMode: 'Minutes'
};
return (
<GanttComponent
id="ganttDefault"
height="430px"
dataSource={data}
taskFields={taskFields}
timelineSettings={timelineSettings}
>
</GanttComponent>
);
}
ReactDOM.render(<App />, document.getElementById('root'));import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { GanttComponent, TaskFieldsModel, TimelineSettingsModel } from '@syncfusion/ej2-react-gantt';
import { data } from './datasource';
function App() {
const taskFields: TaskFieldsModel = {
id: 'TaskID',
name: 'TaskName',
startDate: 'StartDate',
endDate: 'EndDate',
duration: 'Duration',
progress: 'Progress',
dependency: 'Predecessor',
parentID: 'ParentID'
};
const timelineSettings: TimelineSettingsModel = {
timelineViewMode: 'Minutes'
};
return (
<GanttComponent
id="ganttDefault"
height="430px"
dataSource={data}
taskFields={taskFields}
timelineSettings={timelineSettings}
>
</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/33.1.44/tailwind3.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>
</head>
<body>
<div id='root'>
<div id='loader'>Loading....</div>
</div>
</body>
</html>Timeline view dates
The Gantt Chart control supports rendering a fixed timeline range using the viewStartDate and viewEndDate properties. These properties allow the visible portion of the timeline to be explicitly defined and locked within the Gantt chart UI, independent of the project’s overall scheduling boundaries defined by projectStartDate and projectEndDate. The projectStartDate and projectEndDate values represent the full scheduling window for the project and are used for baseline processing, critical-path calculations, and project-level reporting. By default, both viewStartDate and viewEndDate are set to auto. The following example demonstrates how to configure a custom timeline view range.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { GanttComponent, Inject } from "@syncfusion/ej2-react-gantt";
import { data } from "./datasource";
function App() {
const taskFields = {
id: "TaskID",
name: "TaskName",
startDate: "StartDate",
duration: "Duration",
progress: "Progress",
parentID: "ParentID"
};
const timelineSettings = {
viewStartDate: new Date("04/03/2019"),
viewEndDate: new Date("04/07/2019")
};
const projectStartDate = new Date("03/31/2019");
const projectEndDate = new Date("04/13/2019");
return (
<GanttComponent
height="430px"
dataSource={data}
taskFields={taskFields}
timelineSettings={timelineSettings}
projectStartDate={projectStartDate}
projectEndDate={projectEndDate}
>
<Inject services={[]} />
</GanttComponent>
);
}
ReactDOM.render(<App />, document.getElementById("root"));import * as React from "react";
import * as ReactDOM from "react-dom";
import { GanttComponent, Inject, TimelineSettings, TaskFieldsModel } from "@syncfusion/ej2-react-gantt";
import { data } from "./datasource";
function App() {
const taskFields: TaskFieldsModel = {
id: "TaskID",
name: "TaskName",
startDate: "StartDate",
duration: "Duration",
progress: "Progress",
parentID: "ParentID"
};
const timelineSettings: TimelineSettings = {
viewStartDate: new Date("04/03/2019"),
viewEndDate: new Date("04/07/2019")
};
const projectStartDate: Date = new Date("03/31/2019");
const projectEndDate: Date = new Date("04/13/2019");
return (
<GanttComponent
height="430px"
dataSource={data}
taskFields={taskFields}
timelineSettings={timelineSettings}
projectStartDate={projectStartDate}
projectEndDate={projectEndDate}
>
<Inject services={[]} />
</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/33.1.44/tailwind3.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>
</head>
<body>
<div id='root'>
<div id='loader'>Loading....</div>
</div>
</body>
</html>Key behaviors
When viewStartDate and viewEndDate are set to concrete Date values, the timeline rendering is restricted to the inclusive range [viewStartDate, viewEndDate].
- When
viewStartDateis set to auto:- If
projectStartDateis defined, the timeline begins atprojectStartDate. - If
projectStartDateis not defined, the earliest task start date is used as the beginning of the visible range.
- If
- When
viewEndDateis set to auto:- If
projectEndDateis defined, the timeline ends atprojectEndDate. - If
projectEndDateis not defined, the maximum task end date is used. If this end date leaves visible white‑space in the timeline area, the end date is automatically extended to fill the chart width.
- If
Note: The
ZoomToFitfeature usesprojectStartDateandprojectEndDateto fit the entire project within the available timeline viewport.
Customize week start day
In the Gantt Chart component, you can customize the starting day of the week using the weekStartDay property. By default, the weekStartDay value is set to 0, which specifies Sunday as the first day of the week. You can change this value to any number from 0 to 6 to set a different start day.
The weekStartDay property will take effect only when the timeline displays weeks. To enable this, set the timelineViewMode to Week, or configure topTier.unit as Week and bottomTier.unit as Day.
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { GanttComponent } from '@syncfusion/ej2-react-gantt';
import { data } from './datasource';
function App() {
const taskFields = {
id: 'TaskID',
name: 'TaskName',
startDate: 'StartDate',
endDate: 'EndDate',
duration: 'Duration',
progress: 'Progress',
parentID: 'ParentID'
};
const timelineSettings = {
timelineViewMode: 'Week',
weekStartDay: 3
};
return (
<GanttComponent
height="430px"
dataSource={data}
taskFields={taskFields}
timelineSettings={timelineSettings}
>
</GanttComponent>
);
}
ReactDOM.render(<App />, document.getElementById('root'));import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { GanttComponent, TaskFieldsModel, TimelineSettingsModel } from '@syncfusion/ej2-react-gantt';
import { data } from './datasource';
function App() {
const taskFields: TaskFieldsModel = {
id: 'TaskID',
name: 'TaskName',
startDate: 'StartDate',
endDate: 'EndDate',
duration: 'Duration',
progress: 'Progress',
parentID: 'ParentID'
};
const timelineSettings: TimelineSettingsModel = {
timelineViewMode: 'Week',
weekStartDay: 3
};
return (
<GanttComponent
height="430px"
dataSource={data}
taskFields={taskFields}
timelineSettings={timelineSettings}
>
</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/33.1.44/tailwind3.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>
</head>
<body>
<div id='root'>
<div id='loader'>Loading....</div>
</div>
</body>
</html>Customize automatic timescale update action
In the Gantt Chart component, the schedule timeline will be automatically updated when the tasks date values are updated beyond the project start date and end date ranges. This can be enabled or disabled using the updateTimescaleView property.
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { GanttComponent, Edit, Inject } from '@syncfusion/ej2-react-gantt';
import { data } from './datasource';
function App() {
const taskFields = {
id: 'TaskID',
name: 'TaskName',
startDate: 'StartDate',
duration: 'Duration',
progress: 'Progress',
parentID: 'ParentID'
};
const timelineSettings = {
updateTimescaleView: false
};
const editSettings = {
allowEditing: true,
allowTaskbarEditing: true
};
return (
<GanttComponent
height="430px"
dataSource={data}
taskFields={taskFields}
timelineSettings={timelineSettings}
editSettings={editSettings}
>
<Inject services={[Edit]} />
</GanttComponent>
);
}
ReactDOM.render(<App />, document.getElementById('root'));import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { GanttComponent, TaskFieldsModel, TimelineSettingsModel, EditSettings, Edit, Inject } from '@syncfusion/ej2-react-gantt';
import { data } from './datasource';
function App() {
const taskFields: TaskFieldsModel = {
id: 'TaskID',
name: 'TaskName',
startDate: 'StartDate',
duration: 'Duration',
progress: 'Progress',
parentID: 'ParentID'
};
const timelineSettings: TimelineSettingsModel = {
updateTimescaleView: false
};
const editSettings: EditSettings = {
allowEditing: true,
allowTaskbarEditing: true
};
return (
<GanttComponent
height="430px"
dataSource={data}
taskFields={taskFields}
timelineSettings={timelineSettings}
editSettings={editSettings}
>
<Inject services={[Edit]} />
</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/33.1.44/tailwind3.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>
</head>
<body>
<div id='root'>
<div id='loader'>Loading....</div>
</div>
</body>
</html>Dynamically change timeline mode
You can dynamically change the timeline mode in the Gantt Chart by updating the timelineSettings.timelineViewMode property using the change event of the ComboBox component.
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { GanttComponent } from '@syncfusion/ej2-react-gantt';
import { ComboBoxComponent } from '@syncfusion/ej2-react-dropdowns';
import { data } from './datasource';
function App() {
let ganttInstance;
let comboInstance;
const taskFields = {
id: 'TaskID',
name: 'TaskName',
startDate: 'StartDate',
duration: 'Duration',
progress: 'Progress',
parentID: 'ParentID'
};
const timelineSettings = {
timelineViewMode: 'Week'
};
const timelineOptions = [
{ Id: 'Week', Value: 'Week' },
{ Id: 'Day', Value: 'Day' },
{ Id: 'Month', Value: 'Month' }
];
const onTimelineChange = (args) => {
if (ganttInstance) {
ganttInstance.timelineSettings.timelineViewMode = args.value;
ganttInstance.refresh();
}
};
return (
<div>
<ComboBoxComponent
ref={(combo) => (comboInstance = combo)}
dataSource={timelineOptions}
width="200px"
fields=
index={0}
change={onTimelineChange}
/>
<GanttComponent
ref={(gantt) => (ganttInstance = gantt)}
height="430px"
dataSource={data}
taskFields={taskFields}
timelineSettings={timelineSettings}
>
</GanttComponent>
</div>
);
}
ReactDOM.render(<App />, document.getElementById('root'));import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { GanttComponent, TaskFieldsModel, TimelineSettingsModel } from '@syncfusion/ej2-react-gantt';
import { ComboBoxComponent, ChangeEventArgs } from '@syncfusion/ej2-react-dropdowns';
import { data } from './datasource';
function App() {
let ganttInstance: GanttComponent | null;
let comboInstance: ComboBoxComponent | null;
const taskFields: TaskFieldsModel = {
id: 'TaskID',
name: 'TaskName',
startDate: 'StartDate',
duration: 'Duration',
progress: 'Progress',
parentID: 'ParentID'
};
const timelineSettings: TimelineSettingsModel = {
timelineViewMode: 'Week'
};
const timelineOptions = [
{ Id: 'Week', Value: 'Week' },
{ Id: 'Day', Value: 'Day' },
{ Id: 'Month', Value: 'Month' }
];
const onTimelineChange = (args: ChangeEventArgs): void => {
if (ganttInstance) {
ganttInstance.timelineSettings.timelineViewMode = args.value as 'Week' | 'Day' | 'Month';
ganttInstance.refresh();
}
};
return (
<div>
<ComboBoxComponent
ref={(combo) => (comboInstance = combo)}
dataSource={timelineOptions}
width="200px"
fields=
index={0}
change={onTimelineChange}
/>
<GanttComponent
ref={(gantt) => (ganttInstance = gantt)}
height="430px"
dataSource={data}
taskFields={taskFields}
timelineSettings={timelineSettings}
>
</GanttComponent>
</div>
);
}
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/33.1.44/tailwind3.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>
</head>
<body>
<div id='root'>
<div id='loader'>Loading....</div>
</div>
</body>
</html>Timeline cells tooltip
In the Gantt Chart component, you can enable or disable the mouse hover tooltip of timeline cells using the timelineSettings.showTooltip property. The default value of this property is true.
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { GanttComponent } from '@syncfusion/ej2-react-gantt';
import { data } from './datasource';
function App() {
const taskFields = {
id: 'TaskID',
name: 'TaskName',
startDate: 'StartDate',
endDate: 'EndDate',
duration: 'Duration',
progress: 'Progress',
parentID: 'ParentID'
};
const columns = [
{ field: 'TaskID', headerText: 'Task ID', textAlign: 'Left', width: '100' },
{ field: 'TaskName', headerText: 'Task Name', width: '250' },
{ field: 'StartDate', headerText: 'Start Date', width: '150' },
{ field: 'Duration', headerText: 'Duration', width: '150' },
{ field: 'Progress', headerText: 'Progress', width: '150' }
];
const timelineSettings = {
showTooltip: true
};
return (
<GanttComponent
height="430px"
dataSource={data}
taskFields={taskFields}
columns={columns}
timelineSettings={timelineSettings}
>
</GanttComponent>
);
}
ReactDOM.render(<App />, document.getElementById('root'));import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { GanttComponent, TaskFieldsModel, TimelineSettingsModel, ColumnModel } from '@syncfusion/ej2-react-gantt';
import { data } from './datasource';
function App() {
const taskFields: TaskFieldsModel = {
id: 'TaskID',
name: 'TaskName',
startDate: 'StartDate',
endDate: 'EndDate',
duration: 'Duration',
progress: 'Progress',
parentID: 'ParentID'
};
const columns: ColumnModel[] = [
{ field: 'TaskID', headerText: 'Task ID', textAlign: 'Left', width: '100' },
{ field: 'TaskName', headerText: 'Task Name', width: '250' },
{ field: 'StartDate', headerText: 'Start Date', width: '150' },
{ field: 'Duration', headerText: 'Duration', width: '150' },
{ field: 'Progress', headerText: 'Progress', width: '150' }
];
const timelineSettings: TimelineSettingsModel = {
showTooltip: true
};
return (
<GanttComponent
height="430px"
dataSource={data}
taskFields={taskFields}
columns={columns}
timelineSettings={timelineSettings}
>
</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/33.1.44/tailwind3.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>
</head>
<body>
<div id='root'>
<div id='loader'>Loading....</div>
</div>
</body>
</html>Highlight weekends
Highlight weekends by setting showWeekend to true and workWeek to define weekdays, aiding in identifying non-working days in a project schedule.
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { GanttComponent, ColumnsDirective, ColumnDirective, Inject } from '@syncfusion/ej2-react-gantt';
import { data } from './datasource';
function App() {
const taskSettings = {
id: 'TaskID',
name: 'TaskName',
startDate: 'StartDate',
endDate: 'EndDate',
duration: 'Duration',
progress: 'Progress',
parentID: 'ParentID'
};
const timelineSettings = {
showWeekend: false
};
return (
<GanttComponent
height="430px"
dataSource={data}
taskFields={taskSettings}
timelineSettings={timelineSettings}
>
<ColumnsDirective>
<ColumnDirective field="TaskID" headerText="Task ID" textAlign="Left" width="100" />
<ColumnDirective field="TaskName" headerText="Task Name" width="250" />
<ColumnDirective field="StartDate" headerText="Start Date" width="150" />
<ColumnDirective field="Duration" headerText="Duration" width="150" />
<ColumnDirective field="Progress" headerText="Progress" width="150" />
</ColumnsDirective>
<Inject services={[]} />
</GanttComponent>
);
}
ReactDOM.render(<App />, document.getElementById('root'));import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { GanttComponent, ColumnsDirective, ColumnDirective, Inject } from '@syncfusion/ej2-react-gantt';
import { data } from './datasource';
import { TaskFieldsModel, TimelineSettingsModel } from '@syncfusion/ej2-gantt';
function App() {
const taskSettings: TaskFieldsModel = {
id: 'TaskID',
name: 'TaskName',
startDate: 'StartDate',
endDate: 'EndDate',
duration: 'Duration',
progress: 'Progress',
parentID: 'ParentID'
};
const timelineSettings: TimelineSettingsModel = {
showWeekend: false
};
return (
<GanttComponent
height="430px"
dataSource={data}
taskFields={taskSettings}
timelineSettings={timelineSettings}
>
<ColumnsDirective>
<ColumnDirective field="TaskID" headerText="Task ID" textAlign="Left" width="100" />
<ColumnDirective field="TaskName" headerText="Task Name" width="250" />
<ColumnDirective field="StartDate" headerText="Start Date" width="150" />
<ColumnDirective field="Duration" headerText="Duration" width="150" />
<ColumnDirective field="Progress" headerText="Progress" width="150" />
</ColumnsDirective>
<Inject services={[]} />
</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/33.1.44/tailwind3.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>
</head>
<body>
<div id='root'>
<div id='loader'>Loading....</div>
</div>
</body>
</html>Limitations:
- The
showWeekendfeature does not support baselines and not compatible with the manual task mode. - Non-working hours cannot be excluded when
showWeekendis set to false. - Holidays are not excluded from the timeline if
showWeekendis set to false.
Navigating Gantt Chart Timeline
You can adjust the Gantt Chart view by shifting the timeline forward or backward by one unit using the following methods:
-
previousTimeSpan: Moves the timeline backward by one unit from the current start point.
-
nextTimeSpan: Moves the timeline forward by one unit from the current end point.
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { GanttComponent, ColumnsDirective, ColumnDirective, Inject } from '@syncfusion/ej2-react-gantt';
import { data } from './datasource';
import { ButtonComponent } from '@syncfusion/ej2-react-buttons';
function App() {
let ganttRef = null;
const taskSettings = {
id: 'TaskID',
name: 'TaskName',
startDate: 'StartDate',
endDate: 'EndDate',
duration: 'Duration',
progress: 'Progress',
parentID: 'ParentID'
};
const timelineSettings = {
timelineViewMode: 'Week'
};
const columns = [
{ field: 'TaskID', headerText: 'Task ID', width: '100' },
{ field: 'TaskName', headerText: 'Task Name', width: '150' },
{ field: 'StartDate', headerText: 'Start Date', width: '150' },
{ field: 'Duration', headerText: 'Duration', width: '150' },
{ field: 'Progress', headerText: 'Progress', width: '150' }
];
const goToPreviousTimeSpan = () => {
if (ganttRef) ganttRef.previousTimeSpan();
};
const goToNextTimeSpan = () => {
if (ganttRef) ganttRef.nextTimeSpan();
};
return (
<div>
<div style=>
<ButtonComponent style= onClick={goToPreviousTimeSpan}>Previous Week</ButtonComponent>
<ButtonComponent onClick={goToNextTimeSpan}>Next Week</ButtonComponent>
</div>
<GanttComponent
ref={gantt => ganttRef = gantt}
height="430px"
dataSource={data}
taskFields={taskSettings}
timelineSettings={timelineSettings}
columns={columns}
>
<ColumnsDirective>
<ColumnDirective field="TaskID" headerText="Task ID" width="100" />
<ColumnDirective field="TaskName" headerText="Task Name" width="150" />
<ColumnDirective field="StartDate" headerText="Start Date" width="150" />
<ColumnDirective field="Duration" headerText="Duration" width="150" />
<ColumnDirective field="Progress" headerText="Progress" width="150" />
</ColumnsDirective>
<Inject services={[]} />
</GanttComponent>
</div>
);
}
ReactDOM.render(<App />, document.getElementById('root'));import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { GanttComponent, ColumnsDirective, ColumnDirective, Inject } from '@syncfusion/ej2-react-gantt';
import { data } from './datasource';
import { TaskFieldsModel, TimelineSettingsModel } from '@syncfusion/ej2-gantt';
import { ButtonComponent } from '@syncfusion/ej2-react-buttons';
function App() {
let ganttRef: GanttComponent | null = null;
const taskSettings: TaskFieldsModel = {
id: 'TaskID',
name: 'TaskName',
startDate: 'StartDate',
endDate: 'EndDate',
duration: 'Duration',
progress: 'Progress',
parentID: 'ParentID'
};
const timelineSettings: TimelineSettingsModel = {
timelineViewMode: 'Week'
};
const columns = [
{ field: 'TaskID', headerText: 'Task ID', width: '100' },
{ field: 'TaskName', headerText: 'Task Name', width: '150' },
{ field: 'StartDate', headerText: 'Start Date', width: '150' },
{ field: 'Duration', headerText: 'Duration', width: '150' },
{ field: 'Progress', headerText: 'Progress', width: '150' }
];
const goToPreviousTimeSpan = () => {
if (ganttRef) ganttRef.previousTimeSpan();
};
const goToNextTimeSpan = () => {
if (ganttRef) ganttRef.nextTimeSpan();
};
return (
<div>
<div style=>
<ButtonComponent style= onClick={goToPreviousTimeSpan}>Previous Week</ButtonComponent>
<ButtonComponent onClick={goToNextTimeSpan}>Next Week</ButtonComponent>
</div>
<GanttComponent
ref={gantt => ganttRef = gantt}
height="430px"
dataSource={data}
taskFields={taskSettings}
timelineSettings={timelineSettings}
columns={columns}
>
<ColumnsDirective>
<ColumnDirective field="TaskID" headerText="Task ID" width="100" />
<ColumnDirective field="TaskName" headerText="Task Name" width="150" />
<ColumnDirective field="StartDate" headerText="Start Date" width="150" />
<ColumnDirective field="Duration" headerText="Duration" width="150" />
<ColumnDirective field="Progress" headerText="Progress" width="150" />
</ColumnsDirective>
<Inject services={[]} />
</GanttComponent>
</div>
);
}
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/33.1.44/tailwind3.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>
</head>
<body>
<div id='root'>
<div id='loader'>Loading....</div>
</div>
</body>
</html>Timeline template
In the Gantt Chart component, you can customize timeline cells using the timelineTemplate property, allowing for the customization of HTML content within timeline cells. This feature enhances the visual appeal and enables personalized functionality.
When designing the timeline cells, you can utilize the following context properties within the template:
-
date: Defines the date of the timeline cells. -
value: Defines the formatted date value that will be displayed in the timeline cells. -
tier: Defines whether the cell is part of the top or bottom tier.
The following code example how to customize the top tier to display the week’s weather details and the bottom tier to highlight working and non-working days, with formatted text for holidays.
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { GanttComponent, Inject, Selection, DayMarkers, ColumnsDirective, ColumnDirective, HolidaysDirective, HolidayDirective } from '@syncfusion/ej2-react-gantt'
import {timelineTemplateData} from './datasource'
function App() {
let ganttInstance ;
const taskFields = {
id: 'TaskID',
name: 'TaskName',
startDate: 'StartDate',
duration: 'Duration',
progress: 'Progress',
dependency: 'Predecessor',
parentID: 'ParentID'
};
const bgColor = (value, date) => {
if (value === "S") {
return "#7BD3EA"
}
const parsedDate = new Date(date);
for (let i = 0; i < ganttInstance.holidays.length; i++) {
const holiday = ganttInstance.holidays[i];
const fromDate = new Date(holiday.from);
const toDate = new Date(holiday.to)
if (parsedDate >= fromDate && parsedDate <= toDate) {
return "#97E7E1";
}
}
return "#E0FBE2"
};
const imagedate = () => {
const getImage = Math.floor(Math.random() * 5) + 1;
return getImage + ".svg";
}
const holidayValue = (value, date) => {
const parsedDate = new Date(date);
for (let i = 0; i < ganttInstance.holidays.length; i++) {
const holiday = ganttInstance.holidays[i];
const fromDate = new Date(holiday.from);
const toDate = new Date(holiday.to)
if (parsedDate >= fromDate && parsedDate <= toDate) {
const options = { weekday: 'short' };
return parsedDate.toLocaleDateString('en-US', options).toLocaleUpperCase();
}
}
return value
}
const timelineTemplate = (props) => {
if (props.tier == 'topTier') {
return (<div
className="e-header-cell-label e-gantt-top-cell-text"
style={{
width: '100%',
backgroundColor: '#FBF9F1',
fontWeight: 'bold',
height: '100%',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}}
title={props.date}
>
<div>{props.value}</div>
<div
style={{
width: '30px',
height: '30px',
lineHeight: 'normal',
paddingLeft: '10px',
}}
>
<img style={{ width: '100%', height: '100%' }} src={imagedate()} alt="Image" />
</div>
</div>)
}
if (props.tier == 'bottomTier') {
return (<div
className="e-header-cell-label e-gantt-top-cell-text"
style={{
width: '100%',
backgroundColor: bgColor(props.value, props.date),
textAlign: 'center',
height: '100%',
display: 'flex',
alignItems: 'center',
fontWeight: 'bold',
justifyContent: 'center',
}}
title={props.date}
>
{holidayValue(props.value, props.date)}
</div>)
}
}
const splitterSettings = {
columnIndex: 1
};
const timelineSettings = {
topTier: {
unit: 'Week',
format: 'dd/MM/yyyy'
},
bottomTier: {
unit: 'Day',
count: 1
},
timelineUnitSize: 100
};
const labelSettings = {
leftLabel: 'TaskName',
};
const projectStartDate = new Date('03/31/2019');
const projectEndDate = new Date('04/23/2019');
return <GanttComponent id='Timeline' ref={g => ganttInstance = g} dataSource={timelineTemplateData} timelineTemplate={timelineTemplate}
splitterSettings={splitterSettings}
taskFields={taskFields} height='550px'
projectStartDate={projectStartDate} projectEndDate={projectEndDate} timelineSettings={timelineSettings}
labelSettings={labelSettings} treeColumnIndex={1}>
<ColumnsDirective>
<ColumnDirective field='TaskID' visible={false}></ColumnDirective>
<ColumnDirective field='TaskName' width={300} ></ColumnDirective>
<ColumnDirective field='StartDate'></ColumnDirective>
<ColumnDirective field='EndDate' ></ColumnDirective>
<ColumnDirective field='Duration' ></ColumnDirective>
<ColumnDirective field='Progress' ></ColumnDirective>
</ColumnsDirective>
<HolidaysDirective>
<HolidayDirective from='04/04/2019' to='04/05/2019' label='Public Holiday'></HolidayDirective>
<HolidayDirective from='04/12/2019' to='04/12/2019' label='Good Friday'></HolidayDirective>
</HolidaysDirective>
<Inject services={[Selection, DayMarkers]} />
</GanttComponent>
};
ReactDOM.render(<App />, document.getElementById('root'));import * as React from 'react';
import { useRef } from 'react';
import * as ReactDOM from 'react-dom';
import { GanttComponent, Inject, Selection, DayMarkers, ColumnsDirective, ColumnDirective, HolidaysDirective, HolidayDirective } from '@syncfusion/ej2-react-gantt';
import {timelineTemplateData} from './datasource'
function App() {
let ganttInstance :any ;
const taskFields: any = {
id: 'TaskID',
name: 'TaskName',
startDate: 'StartDate',
duration: 'Duration',
progress: 'Progress',
dependency: 'Predecessor',
parentID: 'ParentID'
};
const bgColor = (value: string, date: string): string => {
if (value === "S") {
return "#7BD3EA"
}
const parsedDate = new Date(date);
for (let i = 0; i < ganttInstance.holidays.length; i++) {
const holiday = ganttInstance.holidays[i];
const fromDate = new Date(holiday.from);
const toDate = new Date(holiday.to)
if (parsedDate >= fromDate && parsedDate <= toDate) {
return "#97E7E1";
}
}
return "#E0FBE2"
};
const imagedate = () => {
const getImage = Math.floor(Math.random() * 5) + 1;
return getImage + ".svg";
}
const holidayValue = (value: string, date: string): string => {
const parsedDate = new Date(date);
for (let i = 0; i < ganttInstance.holidays.length; i++) {
const holiday = ganttInstance.holidays[i];
const fromDate = new Date(holiday.from);
const toDate = new Date(holiday.to)
if (parsedDate >= fromDate && parsedDate <= toDate) {
const options: any = { weekday: 'short' };
return parsedDate.toLocaleDateString('en-US', options).toLocaleUpperCase();
}
}
return value
}
const timelineTemplate = (props): any => {
if (props.tier == 'topTier') {
return (<div
className="e-header-cell-label e-gantt-top-cell-text"
style={{
width: '100%',
backgroundColor: '#FBF9F1',
fontWeight: 'bold',
height: '100%',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}}
title={props.date}
>
<div>{props.value}</div>
<div
style={{
width: '30px',
height: '30px',
lineHeight: 'normal',
paddingLeft: '10px',
}}
>
<img style={{ width: '100%', height: '100%' }} src={imagedate()} alt="Image" />
</div>
</div>)
}
if (props.tier == 'bottomTier') {
return (<div
className="e-header-cell-label e-gantt-top-cell-text"
style={{
width: '100%',
backgroundColor: bgColor(props.value, props.date),
textAlign: 'center',
height: '100%',
display: 'flex',
alignItems: 'center',
fontWeight: 'bold',
justifyContent: 'center',
}}
title={props.date}
>
{holidayValue(props.value, props.date)}
</div>)
}
}
const splitterSettings: any = {
columnIndex: 1
};
const timelineSettings: any = {
topTier: {
unit: 'Week',
format: 'dd/MM/yyyy'
},
bottomTier: {
unit: 'Day',
count: 1
},
timelineUnitSize: 100
};
const labelSettings: any = {
leftLabel: 'TaskName',
};
const projectStartDate = new Date('03/31/2019');
const projectEndDate = new Date('04/23/2019');
return <GanttComponent id='Timeline' ref={g => ganttInstance = g} dataSource={timelineTemplateData} timelineTemplate={timelineTemplate}
splitterSettings={splitterSettings}
taskFields={taskFields} height='550px'
projectStartDate={projectStartDate} projectEndDate={projectEndDate} timelineSettings={timelineSettings}
labelSettings={labelSettings} treeColumnIndex={1}>
<ColumnsDirective>
<ColumnDirective field='TaskID' visible={false}></ColumnDirective>
<ColumnDirective field='TaskName' width={300} ></ColumnDirective>
<ColumnDirective field='StartDate'></ColumnDirective>
<ColumnDirective field='EndDate' ></ColumnDirective>
<ColumnDirective field='Duration' ></ColumnDirective>
<ColumnDirective field='Progress' ></ColumnDirective>
</ColumnsDirective>
<HolidaysDirective>
<HolidayDirective from='04/04/2019' to='04/05/2019' label='Public Holiday'></HolidayDirective>
<HolidayDirective from='04/12/2019' to='04/12/2019' label='Good Friday'></HolidayDirective>
</HolidaysDirective>
<Inject services={[Selection, DayMarkers]} />
</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/33.1.44/tailwind3.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>
</head>
<body>
<div id='root'>
<div id='loader'>Loading....</div>
</div>
</body>
</html>