You are here

function pChart::writeValues in Visitors 7.0

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

File

pchart/pChart.inc, line 841

Class

pChart

Code

function writeValues(&$Data, &$DataDescription, $Series) {

  /* Validate the Data and DataDescription array */
  $this
    ->validateDataDescription("writeValues", $DataDescription);
  $this
    ->validateData("writeValues", $Data);
  if (!is_array($Series)) {
    $Series = array(
      $Series,
    );
  }
  foreach ($Series as $Key => $Serie) {
    $ID = 0;
    foreach ($DataDescription["Description"] as $keyI => $ValueI) {
      if ($keyI == $Serie) {
        $ColorID = $ID;
      }
      $ID++;
    }
    $XPos = $this->GArea_X1 + $this->GAreaXOffset;
    $XLast = -1;
    foreach ($Data as $Key => $Values) {
      if (isset($Data[$Key][$Serie]) && is_numeric($Data[$Key][$Serie])) {
        $Value = $Data[$Key][$Serie];
        $YPos = $this->GArea_Y2 - ($Value - $this->VMin) * $this->DivisionRatio;
        $Positions = imagettfbbox($this->FontSize, 0, $this->FontName, $Value);
        $Width = $Positions[2] - $Positions[6];
        $XOffset = $XPos - $Width / 2;
        $Height = $Positions[3] - $Positions[7];
        $YOffset = $YPos - 4;
        $C_TextColor = imagecolorallocate($this->Picture, $this->Palette[$ColorID]["R"], $this->Palette[$ColorID]["G"], $this->Palette[$ColorID]["B"]);
        imagettftext($this->Picture, $this->FontSize, 0, $XOffset, $YOffset, $C_TextColor, $this->FontName, $Value);
      }
      $XPos = $XPos + $this->DivisionWidth;
    }
  }
}