How to generate PDF with Chart.js

๐Ÿ‘:1

Save your Chart.js Canvas in Base64 on chart animation callback, eg:

var canvar_bar = document.createElement("canvas");
new Chart(canvar_bar, {
            type: 'bar',
            data: data,
            options: {  
                    maintainAspectRatio: false,
                    animation:{
                        onComplete: function(){
                            dataURL3 = canvar_bar.toDataURL('image/png');
                        }
                    }
                }
            }));

then use PDFMaker http://pdfmake.org/playground.html to test

Leave a comment