function pData::createFunctionSerie

5.x pData.class.php pData::createFunctionSerie($SerieName, $Formula = "", $Options = "")

File

inc/pchart/pchart/class/pData.class.php, line 704

Class

pData

Code

function createFunctionSerie($SerieName, $Formula = "", $Options = "") 
 {
  $MinX = isset($Options ["MinX"]) ? $Options ["MinX"] : -10;
  $MaxX = isset($Options ["MaxX"]) ? $Options ["MaxX"] : 10;
  $XStep = isset($Options ["XStep"]) ? $Options ["XStep"] : 1;
  $AutoDescription = isset($Options ["AutoDescription"]) ? $Options ["AutoDescription"] : FALSE;
  $RecordAbscissa = isset($Options ["RecordAbscissa"]) ? $Options ["RecordAbscissa"] : FALSE;
  $AbscissaSerie = isset($Options ["AbscissaSerie"]) ? $Options ["AbscissaSerie"] : "Abscissa";

  if ($Formula == "") {
    return (0);
  }

  $Result = "";
  $Abscissa = "";
  for ($i = $MinX; $i <= $MaxX; $i = $i + $XStep) 
   {
    $Expression = "\$return = '!'.(" . str_replace("z", $i, $Formula) . ");";
    if (@eval($Expression) === FALSE) {
      $return = VOID;
    }
    if ($return == "!") {
      $return = VOID;
    }
    else {
      $return = $this->right($return, strlen($return) -1);
    }
    if ($return == "NAN") {
      $return = VOID;
    }
    if ($return == "INF") {
      $return = VOID;
    }
    if ($return == "-INF") {
      $return = VOID;
    }

    $Abscissa [] = $i;
    $Result [] = $return;
  }

  $this->addPoints($Result, $SerieName);
  if ($AutoDescription) {
    $this->setSerieDescription($SerieName, $Formula);
  }
  if ($RecordAbscissa) {
    $this->addPoints($Abscissa, $AbscissaSerie);
  }
}