- <?php
-
- /*
- **************************************************
- Class: LineChart.php
- **************************************************
- Author: Tsiavos Chris <jaames@freemail.gr>
- Date: October 2004
- **************************************************/
-
- /**
- *Includes the Line class
- */
- require_once("Line.php");
-
- /**
- *Includes the Rectangle class
- */
- require_once("Rectangle.php");
-
- /**
- *Includes the chart base class
- */
- require_once("Chart.php");
-
- /**
- *LineChart generation
- */
- class LineChart 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 ($group=0;$group<$this->DataParser_->get_GroupsNum();$group++) {
-
- $DashedLineX=$this->ConfigParser_->get_ChartHmargin()+$ItemArea*$group+($ItemArea/2);
- $DashedLineYStart=$this->ConfigParser_->get_ChartVmargin();
- $DashedLineYFinish=$DashedLineYStart+$this->Area_ysize;
-
- $DashedLine=new Line($this->Chart_Image,$this->ColorAllocator_,$this->ConfigParser_->get_ChartUseAntialias());
- $DashedLine->add_Point("$DashedLineX,$DashedLineYStart");
- $DashedLine->add_Point("$DashedLineX,$DashedLineYFinish");
- $DashedLine->draw_Dashed($this->ConfigParser_->get_GridColor(),0);
-
- }
-
- for ($item=0;$item<$this->DataParser_->get_GroupItemsNum();$item++) {
-
- $Line=new Line($this->Chart_Image,$this->ColorAllocator_,$this->ConfigParser_->get_ChartUseAntialias(),8);
- $ChartData=$this->DataParser_->get_ItemFromGroups($ItemNames[$item]);
-
- 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;
-
- $Line->add_Point("$PointXPos,$PointYPos");
- }
-
- $LineColor=explode(",",$ItemColors[$item]);
- $Line->draw_Filled($LineColor[0],$LineColor[1],$ItemColorsAlpha[$item]);
- $Line->draw($this->ConfigParser_->get_GridColor(),0);
-
- if ($this->ConfigParser_->get_ChartUseStatus()=="Yes") {
- $LinePoints=$Line->get_Points();
-
- for ($point=0;$point<count($LinePoints);$point++) {
- $LinePoint=explode(",",$LinePoints[$point]);
- $Status=new Rectangle($this->Chart_Image,$this->ColorAllocator_,$this->ConfigParser_->get_ChartUseAntialias(),$LinePoint[0]-5,$LinePoint[1],$LinePoint[0]+5,$LinePoint[1]+10);
- $Status->set_Caption($this->Font_,$ChartData[$point],$LineColor[0]);
- $Status->draw_Filled($LineColor[0],$LineColor[1],$ItemColorsAlpha[$item]);
- $Status->draw($this->ConfigParser_->get_GridColor(),0);
- }
- }
- }
- }
- }
-
-
- ?>