Recently I have been coding alot. Reading other people’s code that is badly design is a pain. And worst still, working with people who stick to outdated development techniques.
Its a waste of time trying to convince people that they should look at Object-Oriented design, use code versioning, bugging tracking system etc. Let’s not even speak of design patterns when they don’t even apply basic stuff like generalization/specialization.
No point ranting any further here. So I decided to experiment with other more interesting stuff in other areas apart from applied cryptography which is pretty much revolving around messing up and “unmessing” information..*yawnz*. I must always remind myself that I don’t need a company to explore fun and interesting technologies.
Now to the actual topic. Graphing is an important form of visualization of data. Basically it turns data into information by making meaningful representations. What options do we have in PHP to generate graphs?
It seems like most libraries out there for PHP requires GD library. So make sure you have it! Btw, this is not another how-to or tutorial entries since there are plenty out there. This is just my entry to store links that I refer to and help me make an assessment of what to use for different applications.
Graphing libraries that I found useful are (not exhaustive list of course!):
JGraph http://www.aditus.nu/jpgraph/proversion.php
PHP/SWF Charts http://www.maani.us/charts/index.php?menu=Introduction
I will not discuss how to code with each library but rather compare the two in terms of:
- features
- ease of use
- licensing
Features
The key difference between the two is that SWF charts uses of flash for rendering of graphs and charts. In PHP/SWF charts introduction page, you will find people whining about Jgraph doesn’t work on PHP5 or it looks amatuerish etc. Most of the time, I dismiss such “testimonials” as it is no different from saying “O i think PC sux and Mac is cool or vice versa”. With the same pen, an artist can draw wonders and an idiot can scribble crap.
From this key difference one can infer that certain situation will rule out the use of SWF charts. For example if one is in intranet that has paranoid policies and denies applets and what not, including running of flash swf. JGraph will shine in such situations since the output is basically image file.
But if interactiveness and aesthetics are crucial, then SWF will be useful since its flash representations allow clickable charts and drill downs without page refresh. Something that JGraph is incapable of. Also the flash charts generally looks more “flashy” and prettier.
Documentation is important, JGraph is extensive in this respect while SWF chart’s is rather sparse. Usually the number features are proportional to the amount of documentation for most products. It is safe to conclude that JGraph has alot more than the flashy counterpart.
Ease of use
I haven’t gotten my hands dirty to test the libraries during the time of writing this entry. So all the comments/opinions are based on what I have read from tutorial sites pointed by JGraph main site and from SWF chart’s site tutorials.
SWF
From the surface, it seems inserting SWF charts is much easier and a little more MVC. The view and controller role is performed by “chart.swf” while data for the chart is fed in the third parameter of InsertChart(...). The configuration of chart is done mostly via assignment of variables. After more reading of the samples from the Gallery, I find it a little messy… Anyway most people like messy codes. Well heck!
JGraph
OO way of creating graphs and charts, very neat assignments of various attributes relevant to the graph/chart. With a little separation, one partition configuration of graph, data assignment and rendering neatly. With cool IDE such as PHPEdit, the coding is alot easier with code hinting rather than assignment of arrays in SWF.
I would prefer JGraph when it comes to good design of software. Then again most people wouldn’t care less so long the graph looks pretty…
Licensing
Both have some form of dual licensing scheme. “Free” and Commercial license. JGraph is stricter in a sense that you CANNOT use it for commercial if you don’t pay. SWF doesn’t have that restriction, but you have to registry. However, clicking on a SWF chart using the free version will lead the browser to PHP/SWF’s site.
The cost details can be found at both sites so I shall not repeat them here. In short, one can easily try out the two without forking a single cent.
Tutorials:
Jgraph: http://www.maani.us/charts/index.php?menu=Introduction
PHP/SWF charts: http://www.maani.us/charts/index.php?menu=Tutorial


Entries (RSS)