Changeset View
Changeset View
Standalone View
Standalone View
src/applications/fact/chart/PhabricatorMinChartFunction.php
<?php | <?php | ||||
final class PhabricatorMinChartFunction | final class PhabricatorMinChartFunction | ||||
extends PhabricatorChartFunction { | extends PhabricatorPureChartFunction { | ||||
const FUNCTIONKEY = 'min'; | const FUNCTIONKEY = 'min'; | ||||
protected function newArguments() { | protected function newArguments() { | ||||
return array( | return array( | ||||
$this->newArgument() | $this->newArgument() | ||||
->setName('x') | |||||
->setType('function'), | |||||
$this->newArgument() | |||||
->setName('min') | ->setName('min') | ||||
->setType('number'), | ->setType('number'), | ||||
); | ); | ||||
} | } | ||||
public function getDomain() { | |||||
return $this->getArgument('x')->getDomain(); | |||||
} | |||||
public function newInputValues(PhabricatorChartDataQuery $query) { | |||||
return $this->getArgument('x')->newInputValues($query); | |||||
} | |||||
public function evaluateFunction(array $xv) { | public function evaluateFunction(array $xv) { | ||||
$yv = $this->getArgument('x')->evaluateFunction($xv); | |||||
$min = $this->getArgument('min'); | $min = $this->getArgument('min'); | ||||
foreach ($yv as $k => $y) { | $yv = array(); | ||||
if ($y < $min) { | foreach ($xv as $x) { | ||||
$yv[$k] = null; | if ($x < $min) { | ||||
$yv[] = null; | |||||
} else { | |||||
$yv[] = $x; | |||||
} | } | ||||
} | } | ||||
return $yv; | return $yv; | ||||
} | } | ||||
} | } |