Jump to content

FPDF with Graphs


aeroswat

Recommended Posts

Well, there are a few options.

 

Your best option is using a graphing library that outputs it as an image (which can then be added to FPDF)

 

jpgraph is a PHP based solution that uses GD to render the images, so it would probably be the easiest solution.  They have both a free and commercial license.

 

However, if you find yourself in a situation where you are running a lot of reports (typically reporting requests snowball after they get that first one.  Suddenly they are asking for a report for every damn thing under the sun) there are PLENTY of open source solutions that might make your life far easier.

 

OpenReports is decent..and just happens to be what my previous employer used.  I wasn't crazy about it (java based) but it did the job, and was easy

 

Hopefully some of what I just said points you in the right direction, and let me know if you have any problems :)

Link to comment
Share on other sites

Thank you. JpGraph isn't just an included library tho is it? I haven't been able to take a look in the compressed folder yet but it sounded like it from what I was reading. I don't have access to the server so it's not exactly an option. I'm trying to grab a program to un-compress it real fast tho.

Link to comment
Share on other sites

Um.

 

Well, jpgraph is just a file that you can include.  You dont' have to "install" anything.

 

Either way, if you don't have access to the server (to upload php files) then you can't really do anything

 

Not talking about to upload files lol. Was talking about to mess with the PHP configuration. I found out that really the only thing that's required is that the GD library be enabled on the PHP config. Now I have to go learn how to create pie charts with this thing. Know of any sites where I could go that could give me a little tutorial on it? Their documentation for this library is massive

Link to comment
Share on other sites

It's not hard.

 

Read the links before you ask more questions about configuration and setup..if you spent 1 minute you'd see it's a class library you just upload and include.

 

Seriously, it's not hard.

 

You're not reading what I'm typing -_-

I said that I figured out that it was a library... I asked for a tutorial on creating a pie graph. I didn't ask anything else about configuration and setup.

Link to comment
Share on other sites

Sorry, your first response was the one I was referring to.  I read your posts.

 

Seriously - read the documentation a bit.  They have a "how-to" section, and with a little googling I'm sure you can find some examples.  If you're just creating a pretty simple pie chart it shouldn't be a problem.  I love helping people learn - but I'm impatient when they don't fend for themselves at least a little bit.  If you become a serious developer, you will want to get VERY good at reading technical documentation (because you will spend hundreds of hours doing so as a professional)

 

Try first, and if you fail post your errors/code.  I'll then tell you how to fix it...I promise :)

Link to comment
Share on other sites

Sorry, your first response was the one I was referring to.  I read your posts.

 

Seriously - read the documentation a bit.  They have a "how-to" section, and with a little googling I'm sure you can find some examples.  If you're just creating a pretty simple pie chart it shouldn't be a problem.  I love helping people learn - but I'm impatient when they don't fend for themselves at least a little bit.  If you become a serious developer, you will want to get VERY good at reading technical documentation (because you will spend hundreds of hours doing so as a professional)

 

Try first, and if you fail post your errors/code.  I'll then tell you how to fix it...I promise :)

 

Gonna hold you to that because I have tried ;)

I have write permission errors its telling me. I want to save my pie graph to a file. At the end I do this

 

$graph->Stroke(getcwd() . "/graph1.png"); 

 

And it tells me that it can't write to file and to check that the process running php has the correct permissions. I can't seem to find in the documentation where to check for said permissions though. I've been looking since about 2 minutes after I wrote my last post :)

Anywho I'm heading to lunch and will be back in like an hour. I'll check back then. Thanks for the help and I don't mean to sound unappreciative so I apologize if I do.

Link to comment
Share on other sites

No sweat :)

 

Alright, so that does make sense tho (that error).  jpgraph is trying to write to the filesystem, and it doesn't look like it has access to. 

 

What you want to do is set write permissions for your web server user on that particular directory or file it's complaining about.  If you don't know that answer (what the web server is running under) go ahead and chmod 777 the file and see if that works. 

 

 

Link to comment
Share on other sites

No sweat :)

 

Alright, so that does make sense tho (that error).  jpgraph is trying to write to the filesystem, and it doesn't look like it has access to. 

 

What you want to do is set write permissions for your web server user on that particular directory or file it's complaining about.  If you don't know that answer (what the web server is running under) go ahead and chmod 777 the file and see if that works.

 

Err... I'm getting a strange error. Also in FileZilla I checked the write access under group permissions and do it to all sub-directories and files in the sub-directories. So it ran a chmod 777 on everything. Then I go to right click my public_html folder (main folder where everything is) and look at the permissions again. It has write unchecked ><

To complicate things further I now get this error when I run the script to create the pie chart

 

Fatal error: Unknown: Failed opening required '/www/www.****.com/create.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in Unknown on line 0

 

Here is the code that i'm using

 

include ("jpgraph/jpgraph.php" );
include ("jpgraph/jpgraph_pie.php");

$data  = array(40,60, 21,33);

$graph  = new PieGraph (300,200);
$graph->SetShadow();

$graph->title-> Set("A simple Pie plot");

$p1  = new PiePlot($data);
$graph->Add( $p1);
$graph->Stroke(getcwd() . "/graph1.png"); 

 

Fuck me >< Now everything that uses in include, require_once, etc on my site no longer works and gives that same error :(

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.