A timeline plugin for Chart.js Currently requires Chart.js >= 2.6.0
Support zoom and selection and change chart color brush
Out of the box examples are available here:https://heqingsong.github.io/chartjs-plugin-timeline/index.html
To configure the timeline and brush and zoom plugin, you can simply add new config options to your chart config.
{
title:{
...
},
scales: {
...
},
// Container for timeline options
timeline: {
// selected chart style
selected: {
style: [{
_id: 'line',
color: 'green'
}, {
_id: 'bar1',
color: 'rgb(255, 99, 132)'
}, {
_id: 'bar2',
color: 'rgb(200, 104, 204)'
}, {
_id: 'scatter',
color: 'rgb(200, 104, 204)'
}],
// open toggle style
toggleStyle: true
},
zoom: {
enabled: true,
sensitivity: 1
},
// brush default status
brushDisplay: false,
xAxesWidth: 60,
onSelected: function(data) {
console.log('selected data', data);
},
onClick: function(element) {
console.log('click data', element);
}
}
}
- npm install http-server -g
- http-server ./
- auto play brush
- npm install
- npm run watch
chartjs-plugin-timeline
is available under the MIT license.