Installing and Configuring PHP JpGraph on Linux

Last updated:

Installation and configuration

download the project file here (most recent release as of 12 Sep 2012)

extract the file:

tar -zxvf jpgraph-3.5.0b1.tar.gz

copy the src directory into your web project. Let's assume you have created a PHP project at /var/www/my_project

sudo cp jpgraph-3.5.0b1/src/ /var/www/my_project/ -r

now cd over to your project:

cd /var/www/my_project
Twitter Linkedin YC Hacker News Reddit

rename the src directory:

sudo mv src jpgraph

and set liberal permissions to avoid problems at this stage:

sudo chmod 777 jpgraph -R

now let's correct some bugs in the project:

head over to jpgraph/gd_image.inc.php and comment out this line: (on my version [jpgraph-3.5.0b1] it's line 110)

//  JpGraphError::RaiseL(25128);//('The function imageantialias() ...

Now we may need to install some Fonts which sometimes aren't available on Linux.

Twitter Linkedin YC Hacker News Reddit

The easiest way to get the fonts is to go to a Windows machine and go to C:\Windows\Fonts\Arial and copy all those .ttf files into /usr/share/fonts/truetype/

Done.

Troubleshooting

You can start using it. I recommend trying out some of the examples... Some of them probably won't work due to reasons I don't understand but, from my experience, it will help if, in the includes, you specify an absolute path rather than the relative pathing that comes in the Examples.

I think it might have something to do with the way they created a directory inside Examples which is a symlink to its parent directory... not sure how that is supposed to work.. The whole thing is a bit messy if you ask me. I'd use Highcharts if I could choose but for this project specifically I need to use JpGraph.. Anyway. Good luck.

Oh Yeah. If you run into other font problems you just do same process you did for Arial again.

Dialogue & Discussion