跳到主要内容

posFromDate

Description

在图表区域中获取指定日期的相对水平位置

posFromDate: (date: Date) => number

Parameters

  • date - (required) Date - 你想要知道位置的日期

Returns

  • position - (number) - 时间线中指定日期的 x 坐标(以像素为单位)

Example

gantt.posFromDate(new Date());

Details

注释

该方法返回当前在 Gantt 图中呈现的日期的位置。如果在图表中未呈现某日期,该方法将返回 'null'。

例如,对于上面的甘特图,该方法将返回以下值:

gantt.posFromDate(new Date(2023,02,31)); // -> 0
gantt.posFromDate(new Date(2023,03,1)); // -> 74
gantt.posFromDate(new Date(2023,03,2)); // -> 148
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.