Last release: 1.27d
a PHP Class to build Charts
pChart 2.x is born, you can start moving your script to this new version. The new website is at
Overview  |  Screenshots  |  Download  |  Add-ons  |  Demonstration  |  Support  |  :: Documentation ::
Documentation Contents
Class definition
Using pChart with MySQL
Playing with colors
Setting X labels
Series are drawn black?
Debugging charts
Call to undefined function
Digging with pChart
Basic Examples
Advanced Examples
Setting X Labels

It can be usefull / mandatory to define what will be the X labels displayed on the graphs (line, curve, bar, ..). In a basic configuration we do not care of this, the pData class automaticaly create a 'Name' serie incrementing a value for each new point, in results, X labels are numeric values. It is hopefully possible for you to manually define this labels creating a dedicated serie!

Create your X Labels data serie

The creation of this serie will be done exactly the same way you are creating your data series. You can do this using different pData functions. Let's first try with the AddPoint method adding one label per call :
you can also use an array :
We now have a data serie containing the labels.

Use a serie as X Labels

The pData class embed a function named SetAbsciseLabelSerie(). This method can be used to set which serie will be used for X Labels. By default, calling it with no parameters will set the inbuild 'Name' serie to be used. To set the serie we've previously populated :
Be careful if you are using the AddAllSeries to mark all your series as graphable. The XLabel serie will also be drawn and we don't want that. You have two possibilies. First one would be to remove this serie from the graphable list :
The other solution would be to not use the AddAllSeries but add manually each series :

Last updated on 07/18/2008