, 1 min read

Graphs with JpGraph by Asial

Original post is here eklausmeier.goip.de/blog/2013/09-18-graphs-with-jpgraph-by-asial.


JpGraph is a library of PHP code to draw a variety of graphs:

  1. line+bar+pie charts
  2. radar+polar+contour graphs
  3. bar+QR codes
  4. Gantt charts
  5. a couple of other chart types

Here are two examples:

Pie ChartGantt Chart

JpGraph is a free product by Asial if used in a non-commercial context.

Installation is quite easy on Ubuntu because all the software can readily be installed by apt-get. You need:

  1. lighttpd (or another web-server, like Apache)
  2. php5-common, php5-cgi, php5-gd
  3. JpGraph

After installing php5-gd restart the web-server. Failing to do so will make JpGraph fail.

Unpack JpGraph in your web directory, i.e., /var/www.

cd /var/www
tar zxf ~/Downloads/jpgraph-3.5.0b1.tar.gz
mv jpgraph-3.5.0b1/src/ .
mv src/ jpgraph
ln -s jpgraph-3.5.0b1/docs/ jpgraph-doc

To work around the font problem either use

DEFINE("TTF_DIR","/usr/share/fonts/truetype/ttf-bitstream-vera/");

in the beginning of your PHP code, or change TTF_DIR in jpg-config.inc.php

Google Charts lacks support for Gantt charts, although it supports timelines. Google Charts is based upon JavaScript, while JpGraph is based upon PHP.

Added 01-Mar-2017: In Arch Linux you install php-gd, and ttf-ms-fonts (AUR). In /etc/php/php.ini you uncomment gd.so.