【问题标题】:No custom time bar found with id undefined - Vis js (while updating to the current version)未找到 ID 未定义的自定义时间栏 - Vis js(更新到当前版本时)
【发布时间】:2020-10-04 20:04:52
【问题描述】:

我将 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

【问题讨论】:

    标签: javascript jquery vis.js vis.js-network vis.js-timeline


    【解决方案1】:

    我认为你应该先添加CustomTime来添加元素,像这样

    让 customBar = document.querySelector( '.customDateBar' ); 自定义栏 === 空?时间线.addCustomTime(时间,'customDateBar'):时间线.setCustomTime(时间,'customDateBar');

    .customDateBar 是你的 ID

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-09-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-11
      • 2018-11-13
      • 1970-01-01
      相关资源
      最近更新 更多