Search code examples
vis.jsvis.js-timeline

How to add a negative date to the timeline


How can I add a negative date to the timeline? My current code is:

let items = new vis.DataSet([
    {id: 1, content: 'today', start: '2018-11-02'}
])

new vis.Timeline(document.getElementById('timeline'), items, {})

To add an event to the timeline, I just add it to items:

items.add({id: 2 content: 'tomorrow', start: '2018-11-03'})

If I zoom the timeline out I see that it shows dates before year 1. How can I add an event to a negative date, without needing to drag the event?


Solution

  • I got it!

    new Date(-2018, 11, 26)
    

    This will produce a negative date.