While working with chart/graphing solutions for creating good looking graphs, we face difficulty to embed the graphs into PDF reports. Charting solutions allow us to create HTML versions of charts and most of the good looking charts consist of basically javascript and flash content, which is normally difficult to embed into the PDFs.
I would like to introduce “Anychart” which provides us the facility to export the rendered graph into an image on the fly while rendering the charts, which is basically stored in any temporary location in the server using an Ajax request and can be easily used in our PDF reports. As most of the PDF generating library (like TCPDF, FPDF, TKPDF etc.) support embedding images into them.
Anychart provides a wide variety of charts “http://www.anychart.com/products/anychart/chart_types/“.
Also, it has a chart gallery “http://www.anychart.com/products/anychart/gallery/” where we can find all kinds of chart, along with XML codes being used to render it.
But we are concerned which the code that will allow us to export the graph as PNG image on the fly and will be embedded into the report from the temp location(where it was stored).
Steps:
Step 1: Download anychart autoload.zip from the link “http://www.anychart.com/products/anychart/docs/users-guide/livesamples/autosave/autosave.zip“. Step 2: Unzip it and keep it inside your test folder and please give write permission to the temp directory present inside the autosave folder.
Step 3: Access the index file (like http://localhost/test/autosave).
Step 4: You will see the PNG file of the rendered chart is stored inside the temp folder.
Step 5: Embed it into the reports by giving the path as required.
Just change the XML code and generate graphs according to your requirement.