addMarker
Description
向时间线区域添加一个标记
addMarker: (marker: MarkerConfig) => number | string
Parameters
marker- (required) MarkerConfig - 标记的配置对象
Returns
markerId- (number|string) - 可选,标记的 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);
Related samples
Details
注释
此方法在 marker 扩展中定义,因此需要启用该 marker 插件。请阅读 Adding Vertical Markers 文章中的详细信息。
配置对象具有以下属性:
- id? - (string | number) - 标记的 id
- start_date - (Date) - 设置标记起始日期的 Date 对象
- end_date? - (Date) - 设置标记结束日期的 Date 对象
- css? - (string) - 应用于标记的 CSS 类
- text? - (string | number) - 标记标题
- title? - (string | number) - 标记的 tooltip
Related API
Related Guides
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.