[ class tree: phpchartPlus ] [ index: phpchartPlus ] [ all elements ]

Source for file BarChart.php

Documentation is available at BarChart.php

  1. <?php
  2.  
  3. /*
  4. **************************************************
  5. Class: BarChart.php
  6. **************************************************
  7. Author: Tsiavos Chris <jaames@freemail.gr>
  8. Date: October 2004
  9. **************************************************/
  10.  
  11. /**
  12. *Includes the Rectangle class
  13. */
  14. require_once("Rectangle.php");
  15.  
  16. /**
  17. *Includes the Chart base class
  18. */
  19. require_once("Chart.php");
  20.  
  21. /**
  22. *BarChart generation
  23. */
  24. class BarChart extends Chart {
  25.  
  26. protected function draw() {
  27. $GroupArea=$this->Area_xsize/$this->DataParser_->get_GroupsNum();
  28. $ItemArea=($GroupArea-5*2-3*($this->DataParser_->get_GroupItemsNum()-1))/$this->DataParser_->get_GroupItemsNum();
  29. $ChartData=array();
  30. $ItemColors=$this->ConfigParser_->get_LegendColors();
  31. $ItemColorsAlpha=$this->ConfigParser_->get_LegendColors_Alpha();
  32. $ItemNames=$this->DataParser_->get_GroupItemsName();
  33. $GroupNames=$this->DataParser_->get_GroupsName();
  34. for ($item=0;$item<$this->DataParser_->get_GroupItemsNum();$item++) {
  35. $ChartData=$this->DataParser_->get_ItemFromGroups($ItemNames[$item]);
  36. for ($group=0;$group<$this->DataParser_->get_GroupsNum();$group++) {
  37. $Bar_XStart=$this->ConfigParser_->get_ChartHmargin()+$GroupArea*$group+5+$ItemArea*$item+$item*3;
  38. $Bar_XFinish=$Bar_XStart+$ItemArea;
  39. $FontColor=$this->ConfigParser_->get_FontColor();
  40. $FontMetrics=$this->Font_->get_FontMetrics($GroupNames[$group]);
  41. $GroupName_YPos=$this->ConfigParser_->get_ChartVmargin()+$this->Area_ysize+2;
  42. $GroupName_XPos=$this->ConfigParser_->get_ChartHmargin()+$GroupArea*$group+($GroupArea-$FontMetrics["FontWidth"])/2;
  43. $this->Font_->draw_String($GroupName_XPos,$GroupName_YPos,$GroupNames[$group],$FontColor);
  44. if ($ChartData[$group]>=0) {
  45. $Bar_YFinish=$this->Chart_ZeroPos;
  46. $Bar_YStart=$Bar_YFinish-($ChartData[$group]*$this->Chart_Yscale);
  47. }
  48. else
  49. {
  50. $Bar_YStart=$this->Chart_ZeroPos;
  51. $Bar_YFinish=$Bar_YStart+(abs($ChartData[$group])*$this->Chart_Yscale);
  52. }
  53. $BarColor=explode(",",$ItemColors[$item]);
  54. $Bar=new Rectangle($this->Chart_Image,$this->ColorAllocator_,$this->ConfigParser_->get_ChartUseAntialias(),$Bar_XStart,$Bar_YStart,$Bar_XFinish,$Bar_YFinish);
  55. if ($this->ConfigParser_->get_ChartUseStatus()=="Yes")
  56. $Bar->set_Caption($this->Font_,$ChartData[$group],$BarColor[0]);
  57. $Bar->draw_Filled($BarColor[0],$BarColor[1],$ItemColorsAlpha[$item]);
  58. $Bar->draw($this->ConfigParser_->get_GridColor(),0);
  59. }
  60. }
  61. }
  62.  
  63. }
  64.  
  65. ?>

Documentation generated on Sun, 3 Oct 2004 14:58:49 +0300 by phpDocumentor 1.3.0RC3