View code:
Chartist.plugins.errorBars = function (options) {
options = Chartist.extend({}, defaultOptions, options);
function addErrorBar(lineLength, data){
var errBar = new Chartist.Svg('line', lineLength, 'ct-error');
data.element.parent().append(errBar);
}
return function errorBars(chart){
if( chart instanceof Chartist.Bar || chart instanceof Chartist.Line ){
chart.on('draw', function(data) {
var lengthCalculator = lineLengthCalculation[data.type] && lineLengthCalculation[data.type][options.orientation] || lineLengthCalculation[data.type];
if(lengthCalculator){
addErrorBar( lengthCalculator(data, options), data );
}
});
}
}
};