You are here

function pData::AddPoint in Visitors 7.0

Same name and namespace in other branches
  1. 8 pchart/pData.inc \pData::AddPoint()
1 call to pData::AddPoint()
pData::ImportFromCSV in pchart/pData.inc

File

pchart/pData.inc, line 119

Class

pData

Code

function AddPoint($Value, $Serie = "Serie1", $Description = "") {
  if (is_array($Value) && count($Value) == 1) {
    $Value = $Value[0];
  }
  $ID = 0;
  for ($i = 0; $i <= count($this->Data); $i++) {
    if (isset($this->Data[$i]) && isset($this->Data[$i][$Serie])) {
      $ID = $i + 1;
    }
  }
  if (count($Value) == 1) {
    $this->Data[$ID][$Serie] = $Value;
    if ($Description != "") {
      $this->Data[$ID]["Name"] = $Description;
    }
    elseif (!isset($this->Data[$ID]["Name"])) {
      $this->Data[$ID]["Name"] = $ID;
    }
  }
  else {
    foreach ($Value as $key => $Val) {
      $this->Data[$ID][$Serie] = $Val;
      if (!isset($this->Data[$ID]["Name"])) {
        $this->Data[$ID]["Name"] = $ID;
      }
      $ID++;
    }
  }
}