npm install d3-timeline-chart --save
'use strict';
const element = document.getElementById('chart');
const data = [{
label: 'Name',
data: [{
type: TimelineChart.TYPE.POINT,
at: new Date([2015, 1, 11])
}, {
type: TimelineChart.TYPE.POINT,
at: new Date([2015, 1, 15])
}, {
type: TimelineChart.TYPE.POINT,
at: new Date([2015, 3, 10])
}, {
label: 'I\'m a label',
type: TimelineChart.TYPE.INTERVAL,
from: new Date([2015, 2, 1]),
to: new Date([2015, 3, 1])
}, {
type: TimelineChart.TYPE.POINT,
at: new Date([2015, 6, 1])
}, {
type: TimelineChart.TYPE.POINT,
at: new Date([2015, 7, 1])
}]
}];
const timeline = new TimelineChart(element, data, {
tip: function(d) {
return d.at || `${d.from}<br>${d.to}`;
}
});