Changeset View
Changeset View
Standalone View
Standalone View
src/applications/fact/chart/PhabricatorShiftChartFunction.php
<?php | <?php | ||||
final class PhabricatorShiftChartFunction | final class PhabricatorShiftChartFunction | ||||
extends PhabricatorChartFunction { | extends PhabricatorChartFunction { | ||||
const FUNCTIONKEY = 'shift'; | const FUNCTIONKEY = 'shift'; | ||||
protected function newArguments() { | protected function newArguments() { | ||||
return array( | return array( | ||||
$this->newArgument() | $this->newArgument() | ||||
->setName('x') | |||||
->setType('function') | |||||
->setIsSourceFunction(true), | |||||
$this->newArgument() | |||||
->setName('shift') | ->setName('shift') | ||||
->setType('number'), | ->setType('number'), | ||||
); | ); | ||||
} | } | ||||
protected function canEvaluateFunction() { | public function evaluateFunction(array $xv) { | ||||
return true; | $shift = $this->getArgument('shift'); | ||||
$yv = array(); | |||||
foreach ($xv as $x) { | |||||
$yv[] = $x + $shift; | |||||
} | } | ||||
protected function evaluateFunction($x) { | return $yv; | ||||
return $x * $this->getArgument('shift'); | |||||
} | } | ||||
} | } |