You are here

function pChart::drawLimitsGraph in Visitors 7.0

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

File

pchart/pChart.inc, line 1427

Class

pChart

Code

function drawLimitsGraph(&$Data, &$DataDescription, $R = 0, $G = 0, $B = 0) {

  /* Validate the Data and DataDescription array */
  $this
    ->validateDataDescription("drawLimitsGraph", $DataDescription);
  $this
    ->validateData("drawLimitsGraph", $Data);
  $XWidth = $this->DivisionWidth / 4;
  $XPos = $this->GArea_X1 + $this->GAreaXOffset;
  foreach ($Data as $Key => $Values) {
    $Min = $Data[$Key][$DataDescription["Values"][0]];
    $Max = $Data[$Key][$DataDescription["Values"][0]];
    $GraphID = 0;
    $MaxID = 0;
    $MinID = 0;
    foreach ($DataDescription["Values"] as $Key2 => $ColName) {
      if (isset($Data[$Key][$ColName])) {
        if ($Data[$Key][$ColName] > $Max && is_numeric($Data[$Key][$ColName])) {
          $Max = $Data[$Key][$ColName];
          $MaxID = $GraphID;
        }
      }
      if (isset($Data[$Key][$ColName]) && is_numeric($Data[$Key][$ColName])) {
        if ($Data[$Key][$ColName] < $Min) {
          $Min = $Data[$Key][$ColName];
          $MinID = $GraphID;
        }
        $GraphID++;
      }
    }
    $YPos = $this->GArea_Y2 - ($Max - $this->VMin) * $this->DivisionRatio;
    $X1 = floor($XPos - $XWidth);
    $Y1 = floor($YPos) - 0.2;
    $X2 = floor($XPos + $XWidth);
    if ($X1 <= $this->GArea_X1) {
      $X1 = $this->GArea_X1 + 1;
    }
    if ($X2 >= $this->GArea_X2) {
      $X2 = $this->GArea_X2 - 1;
    }
    $YPos = $this->GArea_Y2 - ($Min - $this->VMin) * $this->DivisionRatio;
    $Y2 = floor($YPos) + 0.2;
    $this
      ->drawLine(floor($XPos) - 0.2, $Y1 + 1, floor($XPos) - 0.2, $Y2 - 1, $R, $G, $B, TRUE);
    $this
      ->drawLine(floor($XPos) + 0.2, $Y1 + 1, floor($XPos) + 0.2, $Y2 - 1, $R, $G, $B, TRUE);
    $this
      ->drawLine($X1, $Y1, $X2, $Y1, $this->Palette[$MaxID]["R"], $this->Palette[$MaxID]["G"], $this->Palette[$MaxID]["B"], FALSE);
    $this
      ->drawLine($X1, $Y2, $X2, $Y2, $this->Palette[$MinID]["R"], $this->Palette[$MinID]["G"], $this->Palette[$MinID]["B"], FALSE);
    $XPos = $XPos + $this->DivisionWidth;
  }
}