Just another WordPress.com site

Posts tagged “Website Graphs

PHP: pChart


I am finishing up the beginning course for PHP and was asked to write a blog on a related topic.  I came across an article from Smashing Magazine about 50 useful tools for PHP developers. You can find the article here.  (the article is from 2009, but many of the technologies are still being updated/supported today)

There were tools for everything.. Debugging, Testing/Optimization, Documentation, Security, Code Compression, Version-Control, etc.  While many of these would probably be far more useful, far more often for any PHP developer, the creative/designer side of me was drawn to the Graphical tools mentioned in the article.

The first one I read about was pChart. It is a “class oriented framework designed to create aliased charts.”  This tool allows you to pull data from SQL queries to populate and construct a graphical chart.  Some of the core features of pChart are:

  • Native anti-aliasing (for all basic objects)
  • Shadow support (drawn using the internal anti-alias algorithm)
  • Alpha-transparency (directly computed by GD binaries for performance)
  • Spline, cubic curves

pChart has created classes that allow you to “fully configure your series and axis” so the raw data is stored with clean and efficient code. The site provides documentation for these classes on their website. There are custom classes for:

  • Building your data series (addPoints)
  • Defining the name of X/Y Axis (setAxisUnit)
  • Define the way to show values (setAxisDisplay)
  • Bind a series to one axis (setSerieOnAxis)
  • Name axis (setAxisName)
  • Set position of axis (setAxisPosition)
  • and many more..

There are mutiple chart formats you can create with pChart. You can create a standard chart such as plot, line or curve charts.  You can also create bar and stacked bar charts, radar and polar charts, 2D and 3D pie charts, linear bubble charts and more!  Sample documentation is given for these individual chart types on the website as well.

Some of the extended functionalities of the pChart library are pSpring that allows you to create a visual rendition of a network, sandbox engine that allows you to design a chart and generate the code, and pCache that allows you to store a cached version of previously created charts (from SQL queries already generated by other users) and output it directly for better performance on frequently viewed data sets.

For more information or help on setting up pChart on your server and generating charts for use on your sites, visit pChart’s forum support section at wiki.pchart.net/forum/.

Sources: http://www.SmashingMagazine.com, http://www.pChart.net