- <?php
-
- /*
- **************************************************
- Class: AreaChart.php
- **************************************************
- Author: Tsiavos Chris <jaames@freemail.gr>
- Date: October 2004
- **************************************************/
-
- /**
- *Includes the Chart base class
- */
- require_once("Chart.php");
-
- /**
- *Includes the Polygon class
- */
- require_once("Polygon.php");
-
- /**
- *AreaChart generation
- */
- class AreaChart extends Chart {
-
- public function draw() {
-
- $ItemArea=$this->Area_xsize/$this->DataParser_->get_GroupsNum();
- $ItemNames=$this->DataParser_->get_GroupItemsName();
- $ItemColors=$this->ConfigParser_->get_LegendColors();
- $ItemColorsAlpha=$this->ConfigParser_->get_LegendColors_Alpha();
- $GroupNames=$this->DataParser_->get_GroupsName();
- $ChartData=array();
-
- for ($item=0;$item<$this->DataParser_->get_GroupItemsNum();$item++) {
-
- $ChartData=$this->DataParser_->get_ItemFromGroups($ItemNames[$item]);
- $Area=new Polygon($this->Chart_Image,$this->ColorAllocator_,$this->ConfigParser_->get_ChartUseAntialias());
-
- for ($group=0;$group<$this->DataParser_->get_GroupsNum();$group++) {
-
- $PointXPos=$this->ConfigParser_->get_ChartHmargin()+$ItemArea*$group+($ItemArea/2);
- $FontColor=$this->ConfigParser_->get_FontColor();
- $FontMetrics=$this->Font_->get_FontMetrics($GroupNames[$group]);
- $GroupName_YPos=$this->ConfigParser_->get_ChartVmargin()+$this->Area_ysize+2;
- $GroupName_XPos=$PointXPos-($FontMetrics["FontWidth"]/2);
- $this->Font_->draw_String($GroupName_XPos,$GroupName_YPos,$GroupNames[$group],$FontColor);
-
- if ($ChartData[$group]>=0)
- $PointYPos=$this->Chart_ZeroPos-$ChartData[$group]*$this->Chart_Yscale;
- else
- $PointYPos=$this->Chart_ZeroPos+abs($ChartData[$group])*$this->Chart_Yscale;
-
- $Area->add_Vertex("$PointXPos,$PointYPos");
- }
-
- $ZeroPos=$this->Chart_ZeroPos;
-
- $PointXFinish=$this->ConfigParser_->get_ChartHmargin()+$ItemArea*($this->DataParser_->get_GroupsNum()-1)+($ItemArea/2);
- $PointXStart=$this->ConfigParser_->get_ChartHmargin()+($ItemArea/2);
- $Area->add_Vertex("$PointXFinish,$ZeroPos");
- $Area->add_Vertex("$PointXStart,$ZeroPos");
-
- $AreaColor=explode(",",$ItemColors[$item]);
-
- if ($this->ConfigParser_->get_ChartUseStatus()=="Yes") {
- $Area->set_CaptionProperties($this->Font_,$AreaColor[0]);
-
- for ($point=0;$point<$this->DataParser_->get_GroupsNum();$point++)
- $Area->set_CaptionVertex($ChartData[$point]);
- }
-
- $Area->draw_Filled($AreaColor[0],$AreaColor[1],$ItemColorsAlpha[$item]);
- $Area->draw($this->ConfigParser_->get_GridColor,0);
- }
-
- }
-
- }
-
-
- ?>