Changeset View
Changeset View
Standalone View
Standalone View
src/applications/fact/chart/PhabricatorChartFunction.php
Show All 19 Lines | abstract class PhabricatorChartFunction | ||||
final public function setArguments(array $arguments) { | final public function setArguments(array $arguments) { | ||||
$this->newArguments($arguments); | $this->newArguments($arguments); | ||||
return $this; | return $this; | ||||
} | } | ||||
abstract protected function newArguments(array $arguments); | abstract protected function newArguments(array $arguments); | ||||
public function loadData() { | |||||
return; | |||||
} | |||||
final public function setXAxis(PhabricatorChartAxis $x_axis) { | final public function setXAxis(PhabricatorChartAxis $x_axis) { | ||||
$this->xAxis = $x_axis; | $this->xAxis = $x_axis; | ||||
return $this; | return $this; | ||||
} | } | ||||
final public function getXAxis() { | final public function getXAxis() { | ||||
return $this->xAxis; | return $this->xAxis; | ||||
} | } | ||||
final public function setYAxis(PhabricatorChartAxis $y_axis) { | final public function setYAxis(PhabricatorChartAxis $y_axis) { | ||||
$this->yAxis = $y_axis; | $this->yAxis = $y_axis; | ||||
return $this; | return $this; | ||||
} | } | ||||
final public function getYAxis() { | final public function getYAxis() { | ||||
return $this->yAxis; | return $this->yAxis; | ||||
} | } | ||||
protected function newLinearSteps($src, $dst, $count) { | |||||
$count = (int)$count; | |||||
$src = (int)$src; | |||||
$dst = (int)$dst; | |||||
if ($count === 0) { | |||||
throw new Exception( | |||||
pht('Can not generate zero linear steps between two values!')); | |||||
} | |||||
if ($src === $dst) { | |||||
return array($src); | |||||
} | |||||
if ($count === 1) { | |||||
return array($src); | |||||
} | |||||
$is_reversed = ($src > $dst); | |||||
if ($is_reversed) { | |||||
$min = (double)$dst; | |||||
$max = (double)$src; | |||||
} else { | |||||
$min = (double)$src; | |||||
$max = (double)$dst; | |||||
} | |||||
$step = (double)($max - $min) / (double)($count - 1); | |||||
$steps = array(); | |||||
for ($cursor = $min; $cursor <= $max; $cursor += $step) { | |||||
$x = (int)round($cursor); | |||||
if (isset($steps[$x])) { | |||||
continue; | |||||
} | |||||
$steps[$x] = $x; | |||||
} | |||||
$steps = array_values($steps); | |||||
if ($is_reversed) { | |||||
$steps = array_reverse($steps); | |||||
} | |||||
return $steps; | |||||
} | |||||
} | } |