I am trying to generate PDF using wkhtmltopdf , where there has chart js. Chart js version 3.4.x
I have written below html to generate chart
Hello
Js code :
<script type="text/javascript">
const labels = [
'January',
'February',
'March',
'April',
'May',
'June',
];
const data = {
labels: labels,
datasets: [{
label: 'My First dataset',
backgroundColor: 'rgb(255, 99, 132)',
borderColor: 'rgb(255, 99, 132)',
data: [0, 10, 5, 2, 20, 30, 45],
}]
};
const config = {
type: 'bar',
data,
options: {
animation: false,
scales: {
x: {
grid: {
tickColor: 'red'
},
ticks: {
color: 'blue',
}
}
}
}
};
var myChart = new Chart(
document.getElementById('myChart').getContext('2d'),
config
);
</script>
Chart is working fine in html
After give the command
wkhtmltopdf --javascript-delay 1000 http://localhost/pdf_test/index.html testpdf101
I got the paragraph but not chart. Same procedure I have tested for version chart js 2.9.4 where it's working fine. Why it's not working in version 3 ? How can I generate pdf for chart js version 3.4.x ?