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