如何在Vis.js时间轴中按年显示时间轴?

时间:2019-03-05 06:29:20

标签: vis.js vis.js-timeline

我第一次使用Vis.js时间轴时,我希望按年而不是合并的年时线。我在Vis.js中尝试了 groups 选项,而不是 items ,但是没有用。 页面刷新后,我得到这样的时间表:

After page refreshing i'm getting timeline like this.

但是我想要这样的时间表:enter image description here

您能帮我解决这个问题吗? 谢谢

enter image description here 代码:

var container = document.getElementById('visualization');

  // Create a DataSet (allows two way data-binding)
  var items = new vis.DataSet(
    [
    {
        "content": "Application 31 August 2004 - 0.0 ",
        "start": "2004-08-31",
        "id": 0
    },
    {
        "content": "cricket 10 October 2007 - 3.11 Years",
        "start": "2007-10-10",
        "id": 1
    },
    {
        "content": "Inter 09 January 2008 - 3.36 Years",
        "start": "2008-01-09",
        "id": 2
    },
    {
        "content": "Final 09 April 2008 - 3.61 Years",
        "start": "2008-04-09",
        "id": 3
    },
    {
        "content": "exam 07 July 2008 - 3.85 Years",
        "start": "2008-07-07",
        "id": 4
    },
    {
        "content": "asf 18 July 2008 - 3.88 Years",
        "start": "2008-07-18",
        "code": "all",
        "id": 5
    },
    {
        "content": "pal 01 August 2008 - 3.92 Years",
        "start": "2008-08-01",
        "id": 6
    },
    {
        "content": "Final 08 January 2009 - 4.36 Years",
        "start": "2009-01-08",
        "id": 7
    },
    {
        "content": "App 01 June 2009 - 4.75 Years",
        "start": "2009-06-01",
        "id": 8
    },
    {
        "content": "N 31 August 2009 - 5.0 Years",
        "start": "2009-08-31",
        "id": 9
    },
    {
        "content": "Fl 09 March 2010 - 5.52 Years",
        "start": "2010-03-09",
        "id": 10
    },
    {
        "content": "Request  10 June 2010 - 5.78 Years",
        "start": "2010-06-10",
        "id": 11
    },
    {
        "content": "Abn 15 June 2010 - 5.79 Years",
        "start": "2010-06-15",
        "id": 12
    },
    {
        "content": "Non-Final 17 November 2010 - 6.22 Years",
        "start": "2010-11-17",
        "id": 13
    },
    {
        "content": "Final R13 April 2011 - 6.62 Years",
        "start": "2011-04-13",
        "id": 14
    },
    {
        "content": "App 07 September 2011 - 7.02 Years",
        "start": "2011-09-07",
        "id": 15,
    }
    ]
    );
  // Configuration for the Timeline
  var options = {
    min: new Date(2000, 1, 5), 
    max: new Date(209,3,2),
    // autoResize: false,
    height: '200px'
  };

  // Create a Timeline
  var timeline = new vis.Timeline(container, items, options);

0 个答案:

没有答案