Recently code-diesel posted 6 charting libraries, but I haven’t found JpGraph there. JpGraph was recommended to me some yeas ago by my good friend and I have been using it since then. It has some major disadvantages, but there are very big strengths also – all in this article.
Compared to other libraries, especially SWF ones, charts looks really bad. If you care how charts look, better choose other library. I only used it for back-end pages, so the look of charts doesn’t mattered that much.
However, JpGraph is awesome. In my opinion, main strength is flexibility – you can tweak almost everything. Starting from colours, fonts and positioning and finishing with different scales, ticks, filters, etc. Basically, you are not limited with anything, only the design is hard to make to look good. On the other hand, charts looks much more solid than most of other libraries (depends on taste).
Also, creating graphs is easy too. For example, simple line plot is created like this (from manual):
include ("../jpgraph.php"); include ("../jpgraph_line.php"); // Some data $ydata = array(11,3,8,12,5,1,9,13,5,7); // Create the graph. These two calls are always required $graph = new Graph(350,250,"auto"); $graph->SetScale("textlin"); // Create the linear plot $lineplot=new LinePlot($ydata); $lineplot->SetColor("blue"); // Add the plot to the graph $graph->Add($lineplot); // Display the graph $graph->Stroke();
Most of JpGraph code is deeply object oriented, so changing parameters of charts becomes really easy. For example, adding values to line plot code:
$lineplot->value->show();
Documentation is very rich and has a lot of examples – all charts in manual have link to its code. Starting with JpGraph maybe is not very easy, because there are so many different options, but since manual is constructed very logically (“Adding plot marks to line-plots XXX”, “Displaying the values for each data point”, “Adding several plots to the same graph”, etc.) it’s not that hard to reach your goal.
Currently, I have over 40 graphs running in one of my e-shops as statistics visualisation. The only thing I would like to have is client-side controls of data range, labels, etc. I especially would like to add time range selection to sales charts, because now I’m limited to using one chart for months and other for last 30 days. Nevertheless, it’s really good library, especially if you aim for flexibility and customization.








March 19th, 2009 - 5:27 pm
jpGraph reminds me of the 80’s..
March 19th, 2009 - 7:14 pm
Style Chart at this location could be a candidates for advanced charting. The examples shows many advanced visualization ability.