Skip to main content

addMarker

Description​

Adds a marker to the timeline area

addMarker: (marker: MarkerConfig) => number | string

Parameters​

  • marker - (required) MarkerConfig - the marker's configuration object

Returns​

  • markerId - (number|string) - optional, the marker's id

Example​

const dateToString = gantt.date.date_to_str(gantt.config.task_date);
const markerId = gantt.addMarker({
start_date: new Date(),
css: "today",
title: dateToString(new Date())
});

setInterval(() => {
const marker = gantt.getMarker(markerId);
marker.start_date = new Date();
marker.title = dateToString(marker.start_date);
gantt.updateMarker(markerId);
}, 1000 * 60);

Details​

note

This method is defined in the marker extension, so you need to enable the marker plugin. Read the details in the Adding Vertical Markers article.

The configuration object has the following properties:

  • id? - (string | number) - the marker id
  • start_date - (Date) - a Date object that sets the marker's start date
  • end_date? - (Date) - a Date object that sets the marker's end date
  • css? - (string) - a CSS class applied to the marker
  • text? - (string | number) - the marker title
  • title? - (string | number) - the marker's tooltip
Need help?
Got a question about the documentation? Reach out to our technical support team for help and guidance. For custom component solutions, visit the Services page.