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

Source for file LineChart.php

Documentation is available at LineChart.php

  1. <?php
  2.  
  3. /*
  4. **************************************************
  5. Class: LineChart.php
  6. **************************************************
  7. Author: Tsiavos Chris <jaames@freemail.gr>
  8. Date: October 2004
  9. **************************************************/
  10.  
  11. /**
  12. *Includes the Line class
  13. */
  14. require_once("Line.php");
  15.  
  16. /**
  17. *Includes the Rectangle class
  18. */
  19. require_once("Rectangle.php");
  20.  
  21. /**
  22. *Includes the chart base class
  23. */
  24. require_once("Chart.php");
  25.  
  26. /**
  27. *LineChart generation
  28. */
  29. class LineChart extends Chart {
  30.  
  31. public function draw() {
  32. $ItemArea=$this->Area_xsize/$this->DataParser_->get_GroupsNum();
  33. $ItemNames=$this->DataParser_->get_GroupItemsName();
  34. $ItemColors=$this->ConfigParser_->get_LegendColors();
  35. $ItemColorsAlpha=$this->ConfigParser_->get_LegendColors_Alpha();
  36. $GroupNames=$this->DataParser_->get_GroupsName();
  37. $ChartData=array();
  38. for ($group=0;$group<$this->DataParser_->get_GroupsNum();$group++) {
  39. $DashedLineX=$this->ConfigParser_->get_ChartHmargin()+$ItemArea*$group+($ItemArea/2);
  40. $DashedLineYStart=$this->ConfigParser_->get_ChartVmargin();
  41. $DashedLineYFinish=$DashedLineYStart+$this->Area_ysize;
  42. $DashedLine=new Line($this->Chart_Image,$this->ColorAllocator_,$this->ConfigParser_->get_ChartUseAntialias());
  43. $DashedLine->add_Point("$DashedLineX,$DashedLineYStart");
  44. $DashedLine->add_Point("$DashedLineX,$DashedLineYFinish");
  45. $DashedLine->draw_Dashed($this->ConfigParser_->get_GridColor(),0);
  46. }
  47. for ($item=0;$item<$this->DataParser_->get_GroupItemsNum();$item++) {
  48. $Line=new Line($this->Chart_Image,$this->ColorAllocator_,$this->ConfigParser_->get_ChartUseAntialias(),8);
  49. $ChartData=$this->DataParser_->get_ItemFromGroups($ItemNames[$item]);
  50. for ($group=0;$group<$this->DataParser_->get_GroupsNum();$group++) {
  51. $PointXPos=$this->ConfigParser_->get_ChartHmargin()+$ItemArea*$group+($ItemArea/2);
  52. $FontColor=$this->ConfigParser_->get_FontColor();
  53. $FontMetrics=$this->Font_->get_FontMetrics($GroupNames[$group]);
  54. $GroupName_YPos=$this->ConfigParser_->get_ChartVmargin()+$this->Area_ysize+2;
  55. $GroupName_XPos=$PointXPos-($FontMetrics["FontWidth"]/2);
  56. $this->Font_->draw_String($GroupName_XPos,$GroupName_YPos,$GroupNames[$group],$FontColor);
  57. if ($ChartData[$group]>=0)
  58. $PointYPos=$this->Chart_ZeroPos-$ChartData[$group]*$this->Chart_Yscale;
  59. else
  60. $PointYPos=$this->Chart_ZeroPos+abs($ChartData[$group])*$this->Chart_Yscale;
  61.  
  62. $Line->add_Point("$PointXPos,$PointYPos");
  63. }
  64. $LineColor=explode(",",$ItemColors[$item]);
  65. $Line->draw_Filled($LineColor[0],$LineColor[1],$ItemColorsAlpha[$item]);
  66. $Line->draw($this->ConfigParser_->get_GridColor(),0);
  67. if ($this->ConfigParser_->get_ChartUseStatus()=="Yes") {
  68. $LinePoints=$Line->get_Points();
  69. for ($point=0;$point<count($LinePoints);$point++) {
  70. $LinePoint=explode(",",$LinePoints[$point]);
  71. $Status=new Rectangle($this->Chart_Image,$this->ColorAllocator_,$this->ConfigParser_->get_ChartUseAntialias(),$LinePoint[0]-5,$LinePoint[1],$LinePoint[0]+5,$LinePoint[1]+10);
  72. $Status->set_Caption($this->Font_,$ChartData[$point],$LineColor[0]);
  73. $Status->draw_Filled($LineColor[0],$LineColor[1],$ItemColorsAlpha[$item]);
  74. $Status->draw($this->ConfigParser_->get_GridColor(),0);
  75. }
  76. }
  77. }
  78. }
  79. }
  80.  
  81.  
  82. ?>

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