jsPDF Chart.js Tutorial to Solve Black Background of Charts issue in PDF Document Issue (Best Answer) Full Tutorial For Beginners

 

 

Maybe later, but I solved using PNG image:

 

var newCanvasImg = newCanvas.toDataURL("image/png", 1.0);

 

 

@PaulieScanlon the issue is that the canvas defaults to a transparent background.

In your codepen, I added the following before the chart is created and it worked just fine.

Chart.plugins.register({
  beforeDraw: function(chartInstance) {
    var ctx = chartInstance.chart.ctx;
    ctx.fillStyle = "white";
    ctx.fillRect(0, 0, chartInstance.chart.width, chartInstance.chart.height);
  }
});

Leave a Reply