You are here

function pChart::drawGrid in Visitors 7.0

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

File

pchart/pChart.inc, line 495

Class

pChart

Code

function drawGrid($LineWidth, $Mosaic = TRUE, $R = 220, $G = 220, $B = 220, $Alpha = 100) {

  /* Draw mosaic */
  if ($Mosaic) {
    $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_Rectangle = imagecolorallocate($this->Layers[0], 250, 250, 250);
    $YPos = $LayerHeight;

    //$this->GArea_Y2-1;
    $LastY = $YPos;
    for ($i = 0; $i <= $this->DivisionCount; $i++) {
      $LastY = $YPos;
      $YPos = $YPos - $this->DivisionHeight;
      if ($YPos <= 0) {
        $YPos = 1;
      }
      if ($i % 2 == 0) {
        imagefilledrectangle($this->Layers[0], 1, $YPos, $LayerWidth - 1, $LastY, $C_Rectangle);
      }
    }
    imagecopymerge($this->Picture, $this->Layers[0], $this->GArea_X1, $this->GArea_Y1, 0, 0, $LayerWidth, $LayerHeight, $Alpha);
    imagedestroy($this->Layers[0]);
  }

  /* Horizontal lines */
  $YPos = $this->GArea_Y2 - $this->DivisionHeight;
  for ($i = 1; $i <= $this->DivisionCount; $i++) {
    if ($YPos > $this->GArea_Y1 && $YPos < $this->GArea_Y2) {
      $this
        ->drawDottedLine($this->GArea_X1, $YPos, $this->GArea_X2, $YPos, $LineWidth, $R, $G, $B);
    }
    $YPos = $YPos - $this->DivisionHeight;
  }

  /* Vertical lines */
  if ($this->GAreaXOffset == 0) {
    $XPos = $this->GArea_X1 + $this->DivisionWidth + $this->GAreaXOffset;
    $ColCount = $this->DataCount - 2;
  }
  else {
    $XPos = $this->GArea_X1 + $this->GAreaXOffset;
    $ColCount = $this->DataCount;
  }
  for ($i = 1; $i <= $ColCount; $i++) {
    if ($XPos > $this->GArea_X1 && $XPos < $this->GArea_X2) {
      $this
        ->drawDottedLine(floor($XPos), $this->GArea_Y1, floor($XPos), $this->GArea_Y2, $LineWidth, $R, $G, $B);
    }
    $XPos = $XPos + $this->DivisionWidth;
  }
}