You are here

function pChart::drawArea in Visitors 7.0

Same name and namespace in other branches
  1. 8 pchart/pChart.inc \pChart::drawArea()

File

pchart/pChart.inc, line 793

Class

pChart

Code

function drawArea(&$Data, $Serie1, $Serie2, $R, $G, $B, $Alpha = 50) {

  /* Validate the Data and DataDescription array */
  $this
    ->validateData("drawArea", $Data);
  $LayerWidth = $this->GArea_X2 - $this->GArea_X1;
  $LayerHeight = $this->GArea_Y2 - $this->GArea_Y1;
  $this->Layers[0] = imagecreatetruecolor($LayerWidth, $LayerHeight);
  $C_White = imagecolorallocate($this->Layers[0], 255, 255, 255);
  imagefilledrectangle($this->Layers[0], 0, 0, $LayerWidth, $LayerHeight, $C_White);
  imagecolortransparent($this->Layers[0], $C_White);
  $C_Graph = imagecolorallocate($this->Layers[0], $R, $G, $B);
  $XPos = $this->GAreaXOffset;
  $LastXPos = -1;
  foreach ($Data as $Key => $Values) {
    $Value1 = $Data[$Key][$Serie1];
    $Value2 = $Data[$Key][$Serie2];
    $YPos1 = $LayerHeight - ($Value1 - $this->VMin) * $this->DivisionRatio;
    $YPos2 = $LayerHeight - ($Value2 - $this->VMin) * $this->DivisionRatio;
    if ($LastXPos != -1) {
      $Points = "";
      $Points[] = $LastXPos;
      $Points[] = $LastYPos1;
      $Points[] = $LastXPos;
      $Points[] = $LastYPos2;
      $Points[] = $XPos;
      $Points[] = $YPos2;
      $Points[] = $XPos;
      $Points[] = $YPos1;
      imagefilledpolygon($this->Layers[0], $Points, 4, $C_Graph);
    }
    $LastYPos1 = $YPos1;
    $LastYPos2 = $YPos2;
    $LastXPos = $XPos;
    $XPos = $XPos + $this->DivisionWidth;
  }
  imagecopymerge($this->Picture, $this->Layers[0], $this->GArea_X1, $this->GArea_Y1, 0, 0, $LayerWidth, $LayerHeight, $Alpha);
  imagedestroy($this->Layers[0]);
}