You are here

function pSurface::writeYLabels in Visitors 7

Same name and namespace in other branches
  1. 7.2 pChart/class/pSurface.class.php \pSurface::writeYLabels()

File

pChart/class/pSurface.class.php, line 111

Class

pSurface

Code

function writeYLabels($Format = "") {
  $R = isset($Format["R"]) ? $Format["R"] : $this->pChartObject->FontColorR;
  $G = isset($Format["G"]) ? $Format["G"] : $this->pChartObject->FontColorG;
  $B = isset($Format["B"]) ? $Format["B"] : $this->pChartObject->FontColorB;
  $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : $this->pChartObject->FontColorA;
  $Angle = isset($Format["Angle"]) ? $Format["Angle"] : 0;
  $Padding = isset($Format["Padding"]) ? $Format["Padding"] : 5;
  $Position = isset($Format["Position"]) ? $Format["Position"] : LABEL_POSITION_LEFT;
  $Labels = isset($Format["Labels"]) ? $Format["Labels"] : NULL;
  $CountOffset = isset($Format["CountOffset"]) ? $Format["CountOffset"] : 0;
  if ($Labels != NULL && !is_array($Labels)) {
    $Label = $Labels;
    $Labels = "";
    $Labels[] = $Label;
  }
  $Y0 = $this->pChartObject->GraphAreaY1;
  $YSize = ($this->pChartObject->GraphAreaY2 - $this->pChartObject->GraphAreaY1) / ($this->GridSizeY + 1);
  $Settings = array(
    "Angle" => $Angle,
    "R" => $R,
    "G" => $G,
    "B" => $B,
    "Alpha" => $Alpha,
  );
  if ($Position == LABEL_POSITION_LEFT) {
    $XPos = $this->pChartObject->GraphAreaX1 - $Padding;
    $Settings["Align"] = TEXT_ALIGN_MIDDLERIGHT;
  }
  elseif ($Position == LABEL_POSITION_RIGHT) {
    $XPos = $this->pChartObject->GraphAreaX2 + $Padding;
    $Settings["Align"] = TEXT_ALIGN_MIDDLELEFT;
  }
  else {
    return -1;
  }
  for ($Y = 0; $Y <= $this->GridSizeY; $Y++) {
    $YPos = floor($Y0 + $Y * $YSize + $YSize / 2);
    if ($Labels == NULL || !isset($Labels[$Y])) {
      $Value = $Y + $CountOffset;
    }
    else {
      $Value = $Labels[$Y];
    }
    $this->pChartObject
      ->drawText($XPos, $YPos, $Value, $Settings);
  }
}