我将 vis.js 插件从 3.10.0 更新到 4.20.1。许多方法在新版本中已弃用。我把它们都修好了。最后我对这个问题感到震惊。
错误:未找到 ID 未定义的自定义时间栏
var container = document.getElementById('visualization');
var maxzoom = 7*24*60*60*1000;
var options = {
start : new Date(1950, 1, 10),
end: new Date(2020, 10, 10),
min: new Date(1950, 1, 10),
max: new Date(2020, 10, 10),
zoomMin: maxzoom,
showCurrentTime: true,
width: "100%",
editable: false,
zoomable: true,
orientation: 'top',
align: 'center',
margin: {
axis: 1,
item: {
horizontal: 1,
vertical: 1
}
}
};
var groups = new vis.DataSet([
{ id: 0, content: 'A1' },
{ id: 1, content: 'A2' },
{ id: 2, content: 'A3' },
{ id: 3, content: 'A4<br>Other' }]);
var items = new vis.DataSet([]);
var timeline = new vis.Timeline(container, items, options, groups);
timeline.setCustomTime("1958-07-06");
经过长时间的搜索,我发现这个引起了问题。
> timeline.setCustomTime("1958-07-06");
如何在setCustomTime中传递 id