2017-10-06 27 views
1

我有一个VisJS时间表,范围从2017年1月到2018年。时间表以年中三个月为中心开放,但我希望每次都以当前时间为中心开放。当前日期的公开时间表 - VisJS

min: new Date(2017, 1, 5),    // lower limit of visible range 
max: new Date(2018, 1, 11),    // upper limit of visible range 
zoomMin: 1000 * 60 * 60 * 24,   // one day in milliseconds 
zoomMax: 1000 * 60 * 60 * 24*31*3, // three months in milliseconds 

回答

0

您可以用这样的尝试(timeline.setWindow()):

const todayStart = new Date(); 
todayStart.setHours(8, 0, 0, 0); 
const todayEnd = new Date(); 
todayEnd.setHours(18, 0, 0, 0); 

console.log(todayStart, ':', todayEnd); 
setTimeout(_ => { 
    this.timeline.setWindow(todayStart, todayEnd, { animation: true }); 
}); 

或更好地与moveTo

this.timeline.moveTo(new Date());//or 
    this.timeline.moveTo(new Date(), { animation: true });//or 
    this.timeline.moveTo(new Date(), { animation: true }, (props) => { 
    console.log("movedTo", props); 
    }); 
+0

谢谢卢卡斯! – user7631026