Home Forums Chart Support jsPDF export renders black charts

jsPDF export renders black charts

Viewing 3 posts - 1 through 3 (of 3 total)
  • #37285

    Using current (v2.2) version of jsPDF with chartJS, the chartJS charts all come up black (backgrounds) in the PDF.

    Here is the JSFiddle showing the issue. I have spent 2 days and cannot find a solution. Please help.

    https://jsfiddle.net/d72rva36/1

    #37297

    Update: I intended to say canvasJS rather than chartJS above.

    #37300

    @marcmnich,

    jsPDF doesn’t support exporting canvas to pdf directly, please refer to this Stackoverflow thread for more information. Instead you can add chart image to PDF using addImage method of jsPDF. Please find the code-snippet below.

    var canvas = $("#chartContainer .canvasjs-chart-canvas").get(0);
    var dataURL = canvas.toDataURL();
    
    var pdf = new jsPDF();
    pdf.addImage(dataURL, 'JPEG', 0, 0);
    pdf.save("download.pdf");

    Please take a look at this JSFiddle for complete code.
    Export chart to PDF using jsPDF


    Vishwas R
    Team CanvasJS

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.