Changeset View
Changeset View
Standalone View
Standalone View
src/applications/fact/chart/PhabricatorConstantChartFunction.php
- This file was added.
<?php | |||||
final class PhabricatorConstantChartFunction | |||||
extends PhabricatorChartFunction { | |||||
const FUNCTIONKEY = 'constant'; | |||||
private $value; | |||||
protected function newArguments(array $arguments) { | |||||
if (count($arguments) !== 1) { | |||||
throw new Exception( | |||||
pht( | |||||
'Chart function "constant(...)" expects one argument, got %s. '. | |||||
'Pass a constant.', | |||||
count($arguments))); | |||||
} | |||||
if (!is_int($arguments[0])) { | |||||
throw new Exception( | |||||
pht( | |||||
'First argument for "fact(...)" is invalid: expected int, '. | |||||
'got %s.', | |||||
phutil_describe_type($arguments[0]))); | |||||
} | |||||
$this->value = $arguments[0]; | |||||
} | |||||
public function getDatapoints($limit) { | |||||
amckinley: Not sure how I feel about passing `$limit` here. Won't every chart function basically… | |||||
$axis = $this->getXAxis(); | |||||
$x_min = $axis->getMinimumValue(); | |||||
$x_max = $axis->getMaximumValue(); | |||||
amckinleyUnsubmitted Not Done Inline ActionsAlso it's not obvious to me why $limit gets passed as an argument but the axis is an instance variable on this object. amckinley: Also it's not obvious to me why `$limit` gets passed as an argument but the axis is an instance… | |||||
epriestleyAuthorUnsubmitted Done Inline ActionsYeah, this changes in the ~next diff. epriestley: Yeah, this changes in the ~next diff. | |||||
$points = array(); | |||||
$steps = $this->newLinearSteps($x_min, $x_max, 2); | |||||
foreach ($steps as $step) { | |||||
$points[] = array( | |||||
'x' => $step, | |||||
'y' => $this->value, | |||||
); | |||||
} | |||||
return $points; | |||||
} | |||||
public function hasDomain() { | |||||
return false; | |||||
} | |||||
} |
Not sure how I feel about passing $limit here. Won't every chart function basically copy/paste the rest of the code in this function?