I have an app (using Vue) that renders a number of different graphs on different pages. I am adding a PDF download feature that allows on to download all of the graphs in a single PDF. For Pdf generation I am using JsPDF.
Currently all the charts are being rendered on the client side, when the page containing the graph is opened. Within Chart.js you can save the base64 encoded string data of any chart. I am trying to figure out how to get this base64 string data without actually rendering the graph. For chart.js to create a new graph, you need to provide it with a context, an html element. When I set this element's css display property to none, the base64 string data is nothing. When I try turning the visibility of the element to hidden, I see a massive mount of blank space show up beneath the download pdf
button where the graph element exists.
Is it possible to "draw" the chart.js graph (for the purpose of the getting the base64 string) without it rendering or showing up at all on my screen? Or is this a wrong approach to turning a Chart.js graph into a PDF?
Any help is appreciated.