The event markers in the Gantt component is used to highlight the important events in a project. Event markers can be initialized by using the eventMarkers
property, and you can define date and label for the event markers using the day
and label
properties. You can also customize it using the cssClass
properties. The following code example shows how to add event markers in the Gantt component.
To highlight the days, inject the DayMarkers
module into the Gantt component.
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { GanttComponent, Inject, DayMarkers, EventMarkersDirective, EventMarkerDirective } from '@syncfusion/ej2-react-gantt';
import { data } from './datasource';
class App extends React.Component {
constructor() {
super(...arguments);
this.taskFields = {
id: 'TaskID',
name: 'TaskName',
startDate: 'StartDate',
duration: 'Duration',
progress: 'Progress',
child: 'subtasks'
};
this.eventMarkerDay = new Date('4/10/2019');
}
render() {
return <GanttComponent dataSource={data} taskFields={this.taskFields} height='450px'>
<EventMarkersDirective>
<EventMarkerDirective day={this.eventMarkerDay} cssClass='e-custom-event-marker' label='Project approval and kick-off'></EventMarkerDirective>
</EventMarkersDirective>
<Inject services={[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/20.1.57/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%;
}
.e-gantt .e-gantt-chart .e-custom-event-marker {
width: 1px;
border-left: 2px green dotted;
}
</style>
</head>
<body>
<div id='root'>
<div id='loader'>Loading....</div>
</div>
</body>
</html>
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { GanttComponent, Inject, DayMarkers, EventMarkersDirective, EventMarkerDirective } from '@syncfusion/ej2-react-gantt';
import { data } from './datasource';
class App extends React.Component<{}, {}>{
public taskFields: any = {
id: 'TaskID',
name: 'TaskName',
startDate: 'StartDate',
duration: 'Duration',
progress: 'Progress',
child: 'subtasks'
};
public eventMarkerDay: Date = new Date('4/10/2019');
render() {
return <GanttComponent dataSource={data} taskFields={this.taskFields} height = '450px'>
<EventMarkersDirective>
<EventMarkerDirective day={this.eventMarkerDay} cssClass='e-custom-event-marker' label='Project approval and kick-off' ></EventMarkerDirective>
</EventMarkersDirective>
<Inject services={[DayMarkers]} />
</GanttComponent>
}
};
ReactDOM.render(<App />, document.getElementById('root'));