As per chartjs version has changed,The dataset values display on bar itself has not working.The existing code has working with V1.0.2. Ref: how to display data values on Chart.js
var ctx = document.getElementById("myChart2").getContext("2d");
var myBar = new Chart(ctx).Bar(chartData, {
showTooltips: false,
onAnimationComplete: function () {
var ctx = this.chart.ctx;
ctx.font = this.scale.font;
ctx.fillStyle = this.scale.textColor
ctx.textAlign = "center";
ctx.textBaseline = "bottom";
this.datasets.forEach(function (dataset) {
dataset.bars.forEach(function (bar) {
ctx.fillText(bar.value, bar.x, bar.y - 5);
});
})
}
});
Now what will be modification which must work with ChartJs V2.1.6? The current bar graph syntax has working with V2.1.6 given below.
var myBarChart = new Chart(ctx, {
type: 'bar',
data: datasets,
options: {
responsive: true,
tooltips: {
enabled: false
},
legend: {
display: false
},
//what should add to display values on bar?
}
});