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
Create multiple charts

It can be useful to draw multiple charts in a single picture. Some things like scaling need to be taken in consideration. While invoking the drawScale() function the chart area coordinates are computed including the maximum and minimum values of the dataset.

Before drawing another chart you must call the clearScale() function.

Drawing multiple chart with a single Data set

This example is showing how to draw multiple charts in a single picture using the same dataset.

  • We are drawing the stacked bar chart using an automatic scale including a left & right border. Nothing new here, everything is done like when rendering a simple chart.

  • Then we are clearing the scale calling the clearScale() function of the pChart class. This will reset all the dynamically computed variables (YStep,XStep, Margins,..)

  • We redefine the graph area calling the setGraphArea() function of the pChart class.

  • We draw the second chart.

It can be quite convenient to draw the same dataset with different chart type to highlight specific values or series. As the dataset is the same for the two chart, invoking the drawLegend legend function will write the accurate legend that will be the same for all the charts.

The sourcecode :
 // Standard inclusions   

 // Dataset definition 
 $DataSet = new pData;
 $DataSet->SetXAxisName("Samples IDs");
 $DataSet->SetYAxisName("Test Marker");

 // Initialise the graph
 $Test = new pChart(380,400);

 // Graph area setup

 // Draw the title   
 $Title = "  Average growth size for selected\r\n  DNA samples  ";   

 // Draw the bar graph

 // Second chart

 // Draw the line chart

 // Write the legend

 // Finish the graph

Last updated on 08/26/2008