This is a simple plugin for Chartist.js that will add a label at the top of each bar on bar charts. NB: This won't have a good looking on stacked bar charts
var defaultOptions = {
labelClass: 'ct-label',
labelOffset: {
x: 0,
y: -10
},
labelBgClass: 'ct-label-bg',
barWidth: 20,
textAnchor: 'middle'
};
var chart = new Chartist.Bar('.ct-chart', {
labels: [1, 2, 3, 4, 5, 6, 7],
series: [
[2, 4, 2, 5, 4, 3, 6]
]
}, {
plugins: [
Chartist.plugins.ctBarLabels({
labelClass: 'ct-label',
labelOffset: {
x: 0,
y: -10
},
labelBgClass: 'ct-label-bg',
barWidth: 20,
textAnchor: 'middle'
})
]
});