- <?php
-
- /*
- **************************************************
- Class: BarChart.php
- **************************************************
- Author: Tsiavos Chris <jaames@freemail.gr>
- Date: October 2004
- **************************************************/
-
- /**
- *Includes the Rectangle class
- */
- require_once("Rectangle.php");
-
- /**
- *Includes the Chart base class
- */
- require_once("Chart.php");
-
- /**
- *BarChart generation
- */
- class BarChart extends Chart {
-
- protected function draw() {
-
- $GroupArea=$this->Area_xsize/$this->DataParser_->get_GroupsNum();
- $ItemArea=($GroupArea-5*2-3*($this->DataParser_->get_GroupItemsNum()-1))/$this->DataParser_->get_GroupItemsNum();
-
- $ChartData=array();
- $ItemColors=$this->ConfigParser_->get_LegendColors();
- $ItemColorsAlpha=$this->ConfigParser_->get_LegendColors_Alpha();
- $ItemNames=$this->DataParser_->get_GroupItemsName();
- $GroupNames=$this->DataParser_->get_GroupsName();
-
- for ($item=0;$item<$this->DataParser_->get_GroupItemsNum();$item++) {
- $ChartData=$this->DataParser_->get_ItemFromGroups($ItemNames[$item]);
-
- for ($group=0;$group<$this->DataParser_->get_GroupsNum();$group++) {
- $Bar_XStart=$this->ConfigParser_->get_ChartHmargin()+$GroupArea*$group+5+$ItemArea*$item+$item*3;
- $Bar_XFinish=$Bar_XStart+$ItemArea;
-
- $FontColor=$this->ConfigParser_->get_FontColor();
- $FontMetrics=$this->Font_->get_FontMetrics($GroupNames[$group]);
- $GroupName_YPos=$this->ConfigParser_->get_ChartVmargin()+$this->Area_ysize+2;
- $GroupName_XPos=$this->ConfigParser_->get_ChartHmargin()+$GroupArea*$group+($GroupArea-$FontMetrics["FontWidth"])/2;
- $this->Font_->draw_String($GroupName_XPos,$GroupName_YPos,$GroupNames[$group],$FontColor);
-
- if ($ChartData[$group]>=0) {
- $Bar_YFinish=$this->Chart_ZeroPos;
- $Bar_YStart=$Bar_YFinish-($ChartData[$group]*$this->Chart_Yscale);
- }
- else
- {
- $Bar_YStart=$this->Chart_ZeroPos;
- $Bar_YFinish=$Bar_YStart+(abs($ChartData[$group])*$this->Chart_Yscale);
- }
-
- $BarColor=explode(",",$ItemColors[$item]);
- $Bar=new Rectangle($this->Chart_Image,$this->ColorAllocator_,$this->ConfigParser_->get_ChartUseAntialias(),$Bar_XStart,$Bar_YStart,$Bar_XFinish,$Bar_YFinish);
-
- if ($this->ConfigParser_->get_ChartUseStatus()=="Yes")
- $Bar->set_Caption($this->Font_,$ChartData[$group],$BarColor[0]);
-
- $Bar->draw_Filled($BarColor[0],$BarColor[1],$ItemColorsAlpha[$item]);
- $Bar->draw($this->ConfigParser_->get_GridColor(),0);
- }
- }
-
- }
-
- }
-
- ?>