Can anybody suggest me what should I do ?
I am generating the PDF report and in the report, I have to print the high chart graph. As high chart uses the javascript which will not execute in PDF file, So I have to create the graph on the server.
I read many posts, they suggest me that i have to create the image of that graph, but my question is how will I create the image to that graph ?
You could try using server-side "browser" or JS engine to generate your graphs; there are tools that can be used for that.
For that purpose I used those:
PhantomJS: some quirks regarding header/footers but a nice lot of examples on website
WkHTMLToPDF: highly customisable, but I had trouble setting timeouts properly so graphs are fully generated before PDF output
But there are others.
As Preuk says, phantomjs is a good choice and what I use, here's a guide to it on the Highcharts site: http://www.highcharts.com/news/56-improved-image-export-with-phantomjs
It can be fiddly to get going but works well once you get it up and running.
Related
I'm looking for quite a specific technique.
The short of it:
I need HTML which can generate a line chart, as shown below (but without the background image. That is totally irrelevant)
However, I want to make it in HTML, without Javascript or Flash and in a way that the dots can be hovered to show more information.
The long of it:
The image shown above comes from the website jpgraph.net. That is a PHP library for creating charts. The downside of that however, is that it generates images. Since you have no clue of knowing where the dots are going to end up, you can't estimate where the hovers should be made.
Ofcourse there are also loads of javascript ways of doing this, but the graph should also work without javascript.
Flash is out of the question, since it should also work on tablets (read iPads)... And because it is flash...
All the information shown in the graph is generated by an external system. That means that the code should work and change the graph, depending on the information put in there.
EDIT:
I'm aware of the fact that it is easily done with javascript, and my fallback would be to offer a javascript version and as a fallback the php version. However, I'm hoping to find a way which doesn't need a fallback. Using 1 script to do the same task would be better than using two.
You should check out Charts.js by Nick Downie.
It has simple HTML5 Charts using the canvas element -
Charts and Graphs Included:
Bar Chart
Doughnut Chart
Line Graph
Pie Chart
Polar-area Chart
Radar Chart
Read the documentation here: http://www.chartjs.org/docs/
and download on GitHub here: https://github.com/nnnick/Chart.js
Hope I Helped
For those still interested: I fixed this using the jpgraph.net library. It's a php library which allows you to draw graphs on the server using data you get from somewhere else.
As enhzflep pointed out, since you have the data, you can calculate where the points will end up. This is however, quite a tedious job, but it's working in javascript-less browsers.
I have written an app for an ipad that once used sends data to an sql server. I can access this data using a web page, currently using php but this is not fixed, and I would like to be able to then click a button on the web page and generate a pdf report from the data in the sql database.
I am not really sure where to start looking so any pointers much appreciated.
There are lot of libraries available.
http://www.fpdf.org/
https://github.com/dompdf/dompdf
Google it you can get lot more. Personally i have used fpdf.Its little bit difficult to implement but flexible.
You should retrieve de data you want to show from de database first and then create the .pdf file using a class like FPDF (http://www.fpdf.org/) or similar. *You can easily find it in google.
You wish to generate a PDF, you got some options:
http://php.net/manual/en/book.pdf.php Never used this
http://www.fpdf.org/ I used this one myself, works nice :)
And probably you'll be able to find loads more if you Google search for "PHP PDF library"
I have two basic bar charts and I am currently using XML/SWF Charts which is great but the problem I have is I need to be able to send these graphs via email to the user. As well as display them on the site.
I know sending Flash is a bad idea, I would love to find a way to convert my current graphs to an image, but am pretty certain there is no quick fix without building a work around myself.
Therefore what are the best open source or closed solutions for this problem.
I need to be able to display two graphs dynamically and then email them to users.
Any advice is appreciated.
You may want to check out the "Google Image Chart Api" (not to be confused with the Google Chart API).
http://code.google.com/apis/chart/image/
It allows you to generate numerious different types of charts just from the URL.
For example:
https://chart.googleapis.com/chart?cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World
That URL could also be put into an HTML e-mail.
Alternatively, looking at this stackoverflow quesiton FLASH save frame, to image (tiff, bmp, jpg, gif, png)
If you can modify the flash movie. It appears that you can save frames in AS3 via BitmapData. So you may be able to send the data back to the server for processing (emailing). But I can't vouch for this as I haven't tried it.
jqPlot seems pretty good. Piwik uses it. http://www.jqplot.com/
I would recommend using gRaphael. It is a javascript library for rendering graphs using svg(or vml for IE8 and below). I've personally use it and it is quite good.
This probably won't work for you since you're not running .net, but for anyone else who's looking for resources for generating charts there's the MS Chart controls.
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/
I am working on a project that dynamically generates graphs using data from a MySQL database. Ideally I would like to do this in PHP, but my my school's server does not have GD libraries installed. Does anyone know of a method of dynamically generating graphs without using a graph library (such as jpgraph) that depends on GD--perhaps I should resort to someone else's applet?
Thanks,
Colorado
EDIT: Specifically, I'm looking to generate scatter plots.
Charts you could use: http://code.google.com/p/flot/
You could invoke an external program such as Gnuplot.
Demo
Since most modern browser support svg/canvas. You could draw it with javascript on the client side.
There are many flash based (Open Flash Charts) and javascript-jquery (jqplot) based charting modules. You can use one of them.