[Chartjs]-Chart.js bar chart label gets hidden on hover

2👍

I’ve spent a little time on this and solved the issue.

What I gathered from studying the extension…

I moved the onAnimationComplete function into .extend:

Chart.types.Bar.extend({
    name: "BarAlt",
    draw: function () {
    Chart.types.Bar.prototype.draw.apply(this, arguments);
            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);
            });
        })
    }
});

http://jsfiddle.net/s8yfqvdc/10/

1👍

You’ll probably have to create a simple extension, since this seems to be a known issue in Chart.js: see this answer.

Leave a comment