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
Graphs labels
Small "Fast Graphs"
Using pCache
Line style, Pics inclusion
Importing CSV data
Error reporting
Missing values
Playing with axis formats
Playing with backgrounds
High quality graphics
Customizing plot charts
2nd Y axis and shadows
Example #23 - High quality graphics

Since release 1.27b it is now possible to customize backgrounds (Whole picture or only the graph area) by drawing gradient overlays. In this example we are filling the background calling drawGraphAreaGradient and specifying the target to be the background (Whole picture) TARGET_BACKGROUND. We are calling a second time this function specifying no target, by default it will be applyed to the graph area. The title of the graph is written calling the drawTextBox function specifying the box position to be on the left of the picture, the fill color, the text alignement. We're also applying a shading to the text and a 90 rotation. Transparency of the background box is set to 30%.

Finally we're calling the addBorder function to draw a 2px black border around the picture. This call must be done at the end of the chart drawing because it will resize the picture.

Output :

Source code :

  // Standard inclusions   

  // Dataset definition 
  $DataSet = new pData;

  // Initialise the graph
  $Test = new pChart(700,230);

  // Draw the bar chart

  // Draw the title
  $Title = "  Average Temperatures during\r\n  the first months of 2008  ";

  // Draw the legend

  // Render the picture
If you want to send the picture directly in a browser, replace the Render() command by Stroke().

Last updated on 07/27/2008