You are here

function pChart::drawLineGraph in Visitors 8

Same name and namespace in other branches
  1. 7.0 pchart/pChart.inc \pChart::drawLineGraph()
1 call to pChart::drawLineGraph()
pChart::drawFilledLineGraph in pchart/pChart.inc

File

pchart/pChart.inc, line 878

Class

pChart

Code

function drawLineGraph(&$Data, &$DataDescription, $SerieName = "") {

  /* Validate the Data and DataDescription array */
  $this
    ->validateDataDescription("drawLineGraph", $DataDescription);
  $this
    ->validateData("drawLineGraph", $Data);
  $GraphID = 0;
  foreach ($DataDescription["Values"] as $Key2 => $ColName) {
    $ID = 0;
    foreach ($DataDescription["Description"] as $keyI => $ValueI) {
      if ($keyI == $ColName) {
        $ColorID = $ID;
      }
      $ID++;
    }
    if ($SerieName == "" || $SerieName == $ColName) {
      $XPos = $this->GArea_X1 + $this->GAreaXOffset;
      $XLast = -1;
      foreach ($Data as $Key => $Values) {
        if (isset($Data[$Key][$ColName])) {
          $Value = $Data[$Key][$ColName];
          $YPos = $this->GArea_Y2 - ($Value - $this->VMin) * $this->DivisionRatio;
          if (!is_numeric($Value)) {
            $XLast = -1;
          }
          if ($XLast != -1) {
            $this
              ->drawLine($XLast, $YLast, $XPos, $YPos, $this->Palette[$ColorID]["R"], $this->Palette[$ColorID]["G"], $this->Palette[$ColorID]["B"], TRUE);
          }
          $XLast = $XPos;
          $YLast = $YPos;
          if (!is_numeric($Value)) {
            $XLast = -1;
          }
        }
        $XPos = $XPos + $this->DivisionWidth;
      }
      $GraphID++;
    }
  }
}