Chart.js plugin to draw vertical crosshair, zoom, interpolate values and sync chart interactions.
Requires Chart.js 2.6.0 or later.
Documentation
Example
new Chart(ctx, {
options: {
tooltips: {
mode: 'interpolate',
intersect: false
},
plugins: {
crosshair: {
line: {
color: '#F66',
width: 1
},
sync: {
enabled: true,
group: 1,
suppressTooltips: false
},
zoom: {
enabled: true,
zoomboxBackgroundColor: 'rgba(66,133,244,0.2)',
zoomboxBorderColor: '#48F',
zoomButtonText: 'Reset Zoom',
zoomButtonClass: 'reset-zoom',
},
callbacks: {
beforeZoom: function(start, end) {
return true;
},
afterZoom: function(start, end) {
}
}
}
}
}
});
Development
You first need to install node dependencies (requires Node.js):
> npm install
The following commands will then be available from the repository root:
> gulp build // build dist files
> gulp build --watch // build and watch for changes
> gulp lint // perform code linting
> gulp docs // generate GitBook documentation (`dist/docs`)
> gulp samples // prepare samples for release (`dist/samples`)
> gulp package // create an archive with dist files and samples
> gulp netlify // prepare Netlify artifacts (`dist/www`)
License
chartjs-plugin-crosshair
is available under the MIT license.