Documentation:

Back
phpchartPlus Documentation
Tsiavos Chris <[email protected]>
Date: 24-Jan-2005
License: GPL
3.2.1 Using the PHPData Strategy
To use the PHPData Strategy you have to follow 3 steps
1. Include the appropriate file
2. Initialize the PHPData Strategy class
3. Strategize the DataParser instance with the PHPData Strategy instance
4. Pass the array of the chart data values as a parameter to the strategized DataParser instance
code portion from file: "Examples/example.php"
include("../Sources/phpchartPlus.php");
include("../Sources/NullCache_Strategy.php");

include("../Sources/PHPData_Strategy.php");
include("../Sources/PHPConfig_Strategy.php");

$Group1=array("GroupName"=>"12:00", "Items"=>array( array("ItemName"=>"Talos","ItemValue"=>40), array("ItemName"=>"Dilos","ItemValue"=>60)));

$Group2=array("GroupName"=>"13:00", "Items"=>array( array("ItemName"=>"Talos","ItemValue"=>30), array("ItemName"=>"Dilos","ItemValue"=>70)));

$DataParams=array($Group1,$Group2);


$ConfigParams=array("ImageWidth"=>420,
"ImageHeight"=>300,
"ImageOutputType"=>"png",
"ChartTitle"=>"Web Servers Usage",
"ChartType"=>"Pie",
"ChartUseBlending"=>"Yes",
"ChartUseAntialias"=>"Yes",
"ChartHmargin"=>30,
"ChartVmargin"=>30,
"ChartUseStatus"=>"Yes",
"ImageColor_Start"=>"DimGray",
"ImageColor_Finish"=>"DimGray",
"ImageColor_Alpha"=>0,
"ChartColor_Start"=>"DimGray",
"ChartColor_Finish"=>"FloralWhite",
"ChartColor_Alpha"=>0,
"FontColor"=>"White",
"FontWidth"=>3,
"FontHeight"=>3,
"FontFileLocation"=>"../Fonts/ActionMan.ttf",
"FontSize"=>9,
"LegendColors"=> array("DarkRed,Yellow","Black,DarkGreen"),
"LegendColors_Alpha"=>array(0,0),
"GridNum"=>4,
"GridMinValue"=>0,
"GridMaxValue"=>100,
"GridColor"=>"Black");


$DataStrategy=new PHPData_Strategy(); $ConfigStrategy=new PHPConfig_Strategy();
$CacheStrategy=new NullCache_Strategy();
$im=new phpchartPlus();
$im->DataParser_->strategize($DataStrategy);
$im->DataParser_->parse($DataParams);
try
   {
     $im->ConfigParser_->strategize($ConfigStrategy);
     $im->ConfigParser_->parse($ConfigParams);
   }
   catch (ConfigParser_Exception $e) 
   {
     print $e->getMessage();
     exit();
   }
   catch (ConfigStrategy_Exception $f) 
   {
     print $f->getMessage();
     exit();
   } 
   
try
   { 
     $im->get_Instance();
   }
   catch (ImageSupport_Exception $e)
   {
     print $e->getMessage();
     exit();
   }
   catch (FontSupport_Exception $f)
   {
     print $f->getMessage();
     exit();
   }
   
$im->Chart_->set_CachingStrategy($CacheStrategy);
$im->Chart_->draw_Chart(); 

 

 
Hosted by www.Geocities.ws

1