Documentation:

Back
phpchartPlus Documentation
Tsiavos Chris <[email protected]>
Date: 18-Feb-2005
License: GPL
3.1.2 Using the XMLConfig Strategy
requires SimpleXML Extension
To use the XMLConfig Strategy you have to follow 4 steps
1. Include the appropriate file
2. Initialize the XMLConfig Strategy class
3. Strategize the ConfigParser instance with the XMLConfig Strategy instance
4. Pass the filename of the xml configuration file as a parameter to the strategized ConfigParser instance
code portion from file: "Examples/example.php"
include("../Sources/phpchartPlus.php");
include("../Sources/CacheToFile_Strategy.php");
include("../Sources/PEARDBData_Strategy.php");
include("../Sources/XMLConfig_Strategy.php");

$DataParams=array("DB_Type"=>"", "DB_Username"=>"", "DB_Passwd"=>"", "DB_Host"=>"", "DB_Name"=>"", "Field_GroupName"=>"", "Field_ItemName"=>"", "Field_ItemValue"=>"");
$ConfigParams=array("filename"=>"../Data/phpchartplus.conf.xml");
$DataStrategy=new PEARDBData_Strategy();
$ConfigStrategy=new XMLConfig_Strategy();
$CacheStrategy=new CacheToFile_Strategy();
$im=new phpchartPlus();
                   
try
{
$im->DataParser_->strategize($DataStrategy,$DataParams);
$im->DataParser_->parse(array("Query"=>"SELECT * FROM my_table"));
}
catch (DataParser_Exception $e) 
{
  print $e->getMessage();
  exit();
}
catch (DataStrategy_Exception $f) 
{
  print $f->getMessage();
  exit();
}
   
try
{
$im->ConfigParser_->strategize($ConfigStrategy,$ConfigParams);
$im->ConfigParser_->parse();
}
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,2); 
//Cache for 2 minutes 
$im->Chart_->draw_Chart();
               
 
The XML configuration file must be valid against the following DTD:
<!ELEMENT GlobalSettings 
(ImageProperties,ChartProperties,GridProperties) >
<!ELEMENT ImageProperties (Width,Height,Output,ImageColor) >
<!ELEMENT Width (#PCDATA) >
<!ELEMENT Height (#PCDATA) >
<!ELEMENT Output (#PCDATA) >
<!ELEMENT ImageColor (StartColor,FinishColor) >
<!ELEMENT ChartProperties (Title,Type,Blending,
Antialiasing,Hmargin,Vmargin,StatusIndication,
ChartColor,BackgroundImage,Font,Legend) >
<!ELEMENT Title (#PCDATA) >
<!ELEMENT Type (#PCDATA) >
<!ELEMENT Blending (#PCDATA) >
<!ELEMENT Antialiasing (#PCDATA) >
<!ELEMENT Hmargin (#PCDATA) >
<!ELEMENT Vmargin (#PCDATA) >
<!ELEMENT StatusIndication (#PCDATA) >
<!ELEMENT ChartColor (StartColor,FinishColor) >
<!ELEMENT BackgroundImage (#PCDATA) >
<!ELEMENT Font (FileLocation,Color,Width,Height,Size) >
<!ELEMENT Legend (Items) >
<!ELEMENT FileLocation (#PCDATA) >
<!ELEMENT Color (#PCDATA) >
<!ELEMENT Width (#PCDATA) >
<!ELEMENT Height (#PCDATA) >
<!ELEMENT Size (#PCDATA) >
<!ELEMENT GridProperties 
(NumGrids,MinValue,MaxValue,GridColor) >
<!ELEMENT NumGrids (#PCDATA) >
<!ELEMENT MinValue (#PCDATA) >
<!ELEMENT MaxValue (#PCDATA) >
<!ELEMENT GridColor (#PCDATA) >
<!ELEMENT Items (Item)+ >
<!ELEMENT Item (StartColor,FinishColor) >
<!ELEMENT StartColor (#PCDATA) >
<!ELEMENT FinishColor (#PCDATA) >
<!ATTLIST ImageColor alpha CDATA #REQUIRED >
<!ATTLIST ChartColor alpha CDATA #REQUIRED >
<!ATTLIST Item alpha CDATA #REQUIRED > 
 

 
Hosted by www.Geocities.ws

1