function pData::createFunctionSerie in Visitors 7
Same name and namespace in other branches
- 7.2 pChart/class/pData.class.php \pData::createFunctionSerie()
File
- pChart/
class/ pData.class.php, line 704
Class
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);
}
}