I am trying to create a bar chart using angular-chartjs and I need a data labels to be visible over each bar chart
Example: http://jsfiddle.net/uh9vw0ao/
I have tried following code in js:
$scope.pendedLineCountOption = {
series: ["series1", "series2"],
options: {
legend: {
display: false
},
showTooltips: false,
animation: {
onComplete: function () {
var ctx = this.chart.ctx;
ctx.font = this.scales.font;
ctx.fillStyle = this.scales.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);
});
})
}
},
},
data: [[10, 20, 30]], // data array
labels: ["one", "two", "Three"], //array
header: "Header"
};
Html Code is as follows:
<canvas id="pended_bar" class="chart chart-bar" chart-data="pendedLineCountOption.data" chart-labels="pendedLineCountOption.labels" chart-options="pendedLineCountOption.options" chart-series="pendedLineCountOption.series" chart-legend="true"></canvas>
above code is giving datasets undefined error. and data labels are not visible.
please help.