SourceForge.net  |  Sunyday.net
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 www.pchart.net.
Overview  |  Screenshots  |  Download  |  Add-ons  |  Demonstration  |  Support  |  :: Documentation ::
Documentation Contents
Overview
Class definition
FAQ
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 #8 - Creating a filled radar graph

This example shows how to create a simple filled radar graph containing two data series. Data are manualy set using the AddPoint() method of the pData class.

The first step consist in calling the drawRadarAxis() function to prepare the graph area by drawing the Axis. You can specify the MaxValue or keep the automatic scaling mode.

The first step consist in calling the drawFilledRadar() function to draw the radar graph over the Axis layer with a transparency of 60%. ( default is 50% )

Running this script will create a example8.png file in the current directory.

Source code :
 <?php
  // Standard inclusions   
  include("pChart/pData.class");
  include("pChart/pChart.class");

  // Dataset definition 
  $DataSet = new pData;
  $DataSet->AddPoint(array("Memory","Disk","Network","Slots","CPU"),"Label");
  $DataSet->AddPoint(array(1,2,3,4,3),"Serie1");
  $DataSet->AddPoint(array(1,4,2,6,2),"Serie2");
  $DataSet->AddSerie("Serie1");
  $DataSet->AddSerie("Serie2");
  $DataSet->SetAbsciseLabelSerie("Label");


  $DataSet->SetSerieName("Reference","Serie1");
  $DataSet->SetSerieName("Tested computer","Serie2");

  // Initialise the graph
  $Test = new pChart(400,400);
  $Test->setFontProperties("Fonts/tahoma.ttf",8);
  $Test->drawFilledRoundedRectangle(7,7,393,393,5,240,240,240);
  $Test->drawRoundedRectangle(5,5,395,395,5,230,230,230);
  $Test->setGraphArea(30,30,370,370);
  $Test->drawFilledRoundedRectangle(30,30,370,370,5,255,255,255);
  $Test->drawRoundedRectangle(30,30,370,370,5,220,220,220);

  // Draw the radar graph
  $Test->drawRadarAxis($DataSet->GetData(),$DataSet->GetDataDescription(),TRUE,20,120,120,120,230,230,230);
  $Test->drawFilledRadar($DataSet->GetData(),$DataSet->GetDataDescription(),50,20);

  // Finish the graph
  $Test->drawLegend(15,15,$DataSet->GetDataDescription(),255,255,255);
  $Test->setFontProperties("Fonts/tahoma.ttf",10);
  $Test->drawTitle(0,22,"Example 8",50,50,50,400);
  $Test->Render("example8.png");
 ?>
 
If you want to send the picture directly in a browser, replace the Render() command by Stroke().


Last updated on 05/27/2008