Changeset View
Changeset View
Standalone View
Standalone View
src/applications/fact/chart/PhabricatorFactChartFunction.php
- This file was moved from src/applications/fact/function/PhabricatorFactChartFunction.php.
Show First 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | final class PhabricatorFactChartFunction | ||||
} | } | ||||
public function getDatapoints($limit) { | public function getDatapoints($limit) { | ||||
$points = $this->datapoints; | $points = $this->datapoints; | ||||
if (!$points) { | if (!$points) { | ||||
return array(); | return array(); | ||||
} | } | ||||
$axis = $this->getXAxis(); | |||||
$x_min = $axis->getMinimumValue(); | |||||
$x_max = $axis->getMaximumValue(); | |||||
if ($x_min !== null) { | |||||
foreach ($points as $key => $point) { | |||||
if ($point['x'] < $x_min) { | |||||
unset($points[$key]); | |||||
} | |||||
} | |||||
} | |||||
if ($x_max !== null) { | |||||
foreach ($points as $key => $point) { | |||||
if ($point['x'] > $x_max) { | |||||
unset($points[$key]); | |||||
} | |||||
} | |||||
} | |||||
// If we have too many data points, throw away some of the data. | // If we have too many data points, throw away some of the data. | ||||
$count = count($points); | $count = count($points); | ||||
if ($count > $limit) { | if ($count > $limit) { | ||||
$ii = 0; | $ii = 0; | ||||
$every = ceil($count / $limit); | $every = ceil($count / $limit); | ||||
foreach ($points as $key => $point) { | foreach ($points as $key => $point) { | ||||
$ii++; | $ii++; | ||||
if (($ii % $every) && ($ii != $count)) { | if (($ii % $every) && ($ii != $count)) { | ||||
unset($points[$key]); | unset($points[$key]); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
return $points; | return $points; | ||||
} | } | ||||
public function hasDomain() { | |||||
return true; | |||||
} | |||||
public function getDomain() { | |||||
// TODO: We can examine the data to fit a better domain. | |||||
$now = PhabricatorTime::getNow(); | |||||
return array($now - phutil_units('90 days in seconds'), $now); | |||||
} | |||||
} | } |