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

Source for file AreaChart.php

Documentation is available at AreaChart.php

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

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