我寫了一個使用vis.js時間表,側重於當前日期上的一個按鈕的點擊的程序:如何自動立足當前日期vis.js時間表
<button type="button" class="btn btn-info" onclick="timeline.focus(0)">Focus on current date</button>
其中
var timeline = new vis.Timeline(container, data, options);
和
var data = [ //create an item in the dataset corresponding to the current date {id: 0, content: 'today', start: Date()},...];
現在我想讓時間線自動關注用戶更改範圍時的當前日期。我試圖用rangechange事件:
timeline.on('rangechange', function (properties) { timeline.focus(0); });
,
,但重點不按預期發生。
請你幫我理解發生了什麼,以及如何實現這個功能?