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
Line graph
Cubic curve graph
Bar Graph
Stacked Bar Graph
Overlay Bar graph
Line + Area
Limits graph
Filled line graph
Filled cubic graph
Radar graph
Basic Pie graph
Exploded Pie graph
3D Pie graph
Scatter charts
Advanced Examples
Example #4 - Creating a line graph with a greyed area

This example shows how to create a line graph on top of a greyed area. To achieve this example we need to have 3 data series : 2 are used for the max/min values of the area and 1 for the line graph itself. The area is drawn using the drawArea() function giving the color & the alpha transparency level. To draw only one serie calling the drawLineGraph() we must first remove the 2 others used by the area with the RemoveSerie() function. The graph function called is drawBarGraph() without extended parameters. Running this script will create a example4.png file in the current directory.

Output :

Note on the dataset

Data are retrieved from a CSV file named datawithtitle.csv. This file contains 4 colums : Column 0 is used as index, Column 1-2-3 are used as data series. This file does contains a header defining series name.

Click here to download datawithtitle.csv

Source code :
  // Standard inclusions   

  // Dataset definition 
  $DataSet = new pData;

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

  // Draw the 0 line

  // Draw the area

  // Draw the line graph

  // Finish the graph
  $Test->drawTitle(60,22,"Example 4",50,50,50,585);
If you want to send the picture directly in a browser, replace the Render() command by Stroke().

Last updated on 05/15/2008