You must be logged in to post your query.
Home › Forums › Chart Support › Convert chart to base64 image
Tagged: image, pdf
is it possible to convert the chart to base64 image from the chart, to be able to add it into a pdf with pdfmake as suggested in
https://stackoverflow.com/questions/56742889/how-to-automate-a-pdf-generation-including-some-js-charts-library/56743480#56743480
@lujakob
You can get base64 image data of a canvas by using toDataURL method. As CanvasJS charts are rendered on canvas, you can use toDataURL to get base64 image data of the chart. Please find the code-snippet below:
var base64Image = chart.canvas.toDataURL();
Please take a look at this JSFiddle for a working example.
— Ananya Deka Team CanvasJS
Thanks for the support!
You must be logged in to reply to this topic. Login/Register