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
Digging with pChart
Basic Examples
Advanced Examples
pCache.class - Compute one time, spread everywhere

Saving web server speed and CPU is something that matter to us. We've created the pCache class to help you dealing with the fact that a chart can be computed once and displayed many times by different users. The pCache class can be used to simplify server side cache management. In green, the normal process : retrieve data, compute and display, in orange the cost saving path, retrieve the data, check if we have already computed it and display it!

An example of how to use the pCache class can be found here. You'll find bellow a short summary of all the embeded function and their related parameters. Functions categories :

Class initialisation
Cache management

void pCache($CacheFolder="Cache/")

This function create a new pCache object. This object will be used to access the processed data cache. You can optionnaly specify the cache folder to use.
  // This will create a new pCache object with default cache folder
  $MyCache = new pCache();

  // This will create a new pCache object setting the cache folder to /tmp/
  $MyCache = new pCache("/tmp/");
void IsInCache($ID,$Data,$Hash="")

This function can be used to check if the dataseries you're currently working on has already been computed and is stored in the cache. This will return TRUE or FALSE. This function accept a Dataset as first parameter, see the pData class for more informations. ID is used to uniquely indentify your drawing script.
  // This will return TRUE if this chart has already been rendered
void GetFromCache($ID,$Data)

This function will retrieve a chart from the cache if it already exists. The picture will be sent to the browser the same way as if you're invoking the Stroke() function of the pChart class. ID is used to uniquely indentify your drawing script. If the cache can be used, the picture will be send to the browser the same way then calling the Stroke() function, no other lines of your script will be processed after this line.
  // This will check the cache for an existing copy and Stroke it.
void WriteToCache($ID,$Data,$Picture)

Use this function to make a copy of the rendered chart to your cache folder. This function is mandatory for the pCache to work properly. This function must be called at the end of your rendering script before the Stroke() or Render() call. ID is used to uniquely indentify your drawing script. $Data is the dataset used to draw the chart. $Picture is the name of the pChart object containing the chart.
  // This will save the rendered picture in the cache folder.
void DeleteFromCache($ID,$Data)

This function can be used to delete the cached copy of the chart ( if it exists ). ID is used to uniquely indentify your drawing script.
  // This will delete any cached copy of this chart.
void ClearCache()

Calling this function will clear the cache folder.
  // This will cleanup the cache folder.
Last updated on 06/17/2008