creation of pie and bar charts in php website - php

HI. I wanted to know if we could create pie and bar charts based on info from the database on a php website. I want to grab some information from the database and show it as an image so better analysis. Is there anyway to do this?
Also, If i am using fpdf to generate pdfs from php and mysql, can i also design pie charts in that pdf and show it as an image in that?

You could use the Google Chart API

I'd recommend using tcpdf instead of fpdf. fpdf was pretty good, but is no longer actively developed. tcpdf is.
http://www.tecnick.com/public/code/cp_dpage.php?aiocp_dp=tcpdf
As for the graphs there are many libraries displaying image graphs like http://jpgraph.net/
or client side JS libraries that will create flash graphs like ExtJS

JpGraph is a pure php library for generating graphs which outputs an image. I'm not familiar with fpdf but if it can embed images then this solution should work out.
http://jpgraph.net/

I'm using ChartDirector (not free) and FPDF to do this (today as a matter of fact).
ChartDirector can write the chart to a file, which I stick in /tmp. Then I import the file into the PDF file. Then I delete the file from the disk. Then I do it twenty more times with different data.
I'm sure any chart library that can write to disk will work. With FPDF, you can set the size of the image you import. So here's a trick: create the chart image twice as large as you need it and tell FPDF to place it at the size you want. This way, you'll get an image in the PDF file at around 144 dpi (assuming your library exports at 72dpi for the screen). You'll have a PDF that doesn't look as pixelated when zoomed in, and it will print better.

Check out this article on A List Apart for a method using the Raphael javascript graphics library. It demonstrates how to take a generic HTML table and replace it with a cross-browser, dynamic, scalable pie chart. The same could probably be done for a bar chart.
The advantage of this method is semantically correct markup - useful for users without JavaScript, as well as bots and screen readers.

Related

Is there any way to export fusion chart in excel using custom export buttons?

I am using fusioncharts/3.2.4 library for rendering charts on webpage. I searched on google but could not find an answer to how can I export fusion charts in excel/PDF using custom export buttons?
Note: I dont want to use any builtin library aswell.
I searched and found that fusioncharts/3.2.4 does not provide native excel export functionality.
Thanks in advance.
i'm working with the 3.11.3 and doesn't appear any at the XLS but the PNG and PDF work well.
but this can answer your question: i found something that can help you
You can explicitly use action based framework for this and export the excel in the way you want. I have used Apache POI for this, but you can use any of the library for this.
If you want the image of this chart as a part of excel, you can create the string of chart with the use of any backend technology and embed it with a static html content, making static html file.
Test the file by opening in browser, if it is same as that of your application expectation.
Then use 'wkhtmltoimage-0.12.5-1.exe' to generate graph image with proper wait time, and embed this generated image inthe new sheet of the excel file.

Convert HTML5 Charts to PDF

I am making a tool that needs to generate a PDF report with charts and tables from data that was imported via excel upload.
I would like use HTML5 charts. We are currently using PHP.
I am looking for a a real browser (or something that behaves like a browser) in order to have those html5 charts rendered properly. The new html5 charts rely on javascript, so it's not just a matter of rendering html into pdf, but also executing javascript to generate the charts on the fly.
Any suggestions?
Thanks
ZingChart exports to PDF from canvas, SVG, and VML.
I'm on the team, so if you have any questions about implementation or other features, just reach out!
You might be able to convert the HTML to a CANVAS image (http://html2canvas.hertzen.com/), and then save via jsPDF (https://github.com/MrRio/jsPDF)
What have you tried?

Library to create print-ready charts in PDF using PHP 5.3

I have to create some nicely formatted charts (bar and 3D pie) from dynamic data using PHP 5.3 and for output as PDF report. The report is not to be rendered to the screen at all. I have made the charts using pChart2 as .png files and imported them using tcpdf. The system works, but the quality level is poor, rendering text as a graphic causes the font edges to be blurry etc. when printed. I tweaked the image size of the .PNG output, and it made some improvements but it increases the file size, and the text still looks blurry.
So what I am after is a library to create charts using PHP that can be exported to .svg or .eps format, so elements are drawn by the printer and render sharply for print. Using TCPDF I have imported our logos that are in .EPS format, and the difference between the images is quite marked.
I have seen there is a library called ezcomponents that i can give a try. But before I dive in, is there any advice on what to try before proceeding?
I have had reasonable success rendering the images on a canvas that is two to three times larger than what I ultimately need and then, once I'm finished, using the imagecopyrresampled() function to copy the large image onto a canvas with smaller dimensions, which I save as a png and add to the PDF file. The dithering is pretty good and curved lines, in particular, benefit greatly from this approach. Text might not benefit quite as much, but its worth trying, because it should require very few changes to your code to experiment with this approach.

PHP: How to render PDF reports containing charts?

I want to create PDF reports containing some pie/bar charts. I have to create them with my PHP web app and cannot use commandline tools. For the frontend I use flot. However, I don't know how to get these charts in a PDF, because my project is constrained to PHP.
How do I generate images from my charts to render a PDF?
Update: The solution has to be open source since my project will be open source, too.
Best,
Stefan
Of course you won't be able to use a javascript charting solution to generate graphics to be used directly in a PDF. What you could do however, is use a PHP charting solution to create the graphs. Provided you have GD support built-in (it usually is) you could use pChart or libChart to create GIF/PNG charts you can embed within your PDF.
And for PDF generation I would personally recommend using TCPDF.
Can you use PDFLib ?
http://php.net/manual/en/ref.pdf.php
http://www.pdflib.com/pdflib-cookbook/graphics/fill-pattern/

What PHP library or tool can scale the size of an existing PDF and its contents?

I have written an web application that dynamically creates PDFs that contain only 1-page that has various vector graphics in it, say for example a complex pie or bar chart. In the back-end I have need to scale this PDF and its contents programaticaly to a few different sizes for print.
The few tools I've looked at so far for PHP seem to generate an image out of the original PDF and scale that, which doesn't work for me, I need the contents to remain vectorized and scale with the document.
Any pointers?
probably the simples walkaround would be to generate different PDF files for different page sizes from your original web-application

Categories