[Chartjs]-Chart.JS – show values on top of points

1👍

Call a function during and after animation

var options = {
    onAnimationProgress: function() { drawDatasetPointsLabels() },
    onAnimationComplete: function() { drawDatasetPointsLabels() }
}

function drawDatasetPointsLabels() {
        ctx.font = '.9rem sans-serif';
        ctx.fillStyle = '#AAA';
        ctx.textAlign="center";
        $(Trends.datasets).each(function(idx,dataset){
            $(dataset.points).each(function(pdx,pointinfo){
                // First dataset is shifted off the scale line. 
                // Don't write to the canvas for the null placeholder.
                if ( pointinfo.value !== null ) { 
                    ctx.fillText(pointinfo.value,pointinfo.x,pointinfo.y - 15);
                }
            });
        });         
     }

Leave a comment