Chartjs-Chartjs Exporting ImageExports Empty Dark Image

0👍

I added this piece of code to make the background white:

Chart.plugins.register({
    afterRender: function(c) {
        var ctx = c.chart.ctx;
        ctx.save();

        ctx.globalCompositeOperation = 'destination-over';
        ctx.fillStyle = 'white';
        ctx.fillRect(0, 0, c.chart.width, c.chart.height);
        ctx.restore();
    }
});

Leave a comment