Remove product literal strings in "pht()", part 18
[phabricator.git] / src / applications / fact / chart / PhabricatorChartDataQuery.php
blob7e92938e2c7fb3839089d7f587ac39c8f69762c9
1 <?php
3 final class PhabricatorChartDataQuery
4 extends Phobject {
6 private $limit;
7 private $minimumValue;
8 private $maximumValue;
10 public function setMinimumValue($minimum_value) {
11 $this->minimumValue = $minimum_value;
12 return $this;
15 public function getMinimumValue() {
16 return $this->minimumValue;
19 public function setMaximumValue($maximum_value) {
20 $this->maximumValue = $maximum_value;
21 return $this;
24 public function getMaximumValue() {
25 return $this->maximumValue;
28 public function setLimit($limit) {
29 $this->limit = $limit;
30 return $this;
33 public function getLimit() {
34 return $this->limit;
37 public function selectInputValues(array $xv) {
38 $result = array();
40 $x_min = $this->getMinimumValue();
41 $x_max = $this->getMaximumValue();
42 $limit = $this->getLimit();
44 if ($x_min !== null) {
45 foreach ($xv as $key => $x) {
46 if ($x < $x_min) {
47 unset($xv[$key]);
52 if ($x_max !== null) {
53 foreach ($xv as $key => $x) {
54 if ($x > $x_max) {
55 unset($xv[$key]);
60 // If we have too many data points, throw away some of the data.
62 // TODO: This doesn't work especially well right now.
64 if ($limit !== null) {
65 $count = count($xv);
66 if ($count > $limit) {
67 $ii = 0;
68 $every = ceil($count / $limit);
69 foreach ($xv as $key => $x) {
70 $ii++;
71 if (($ii % $every) && ($ii != $count)) {
72 unset($xv[$key]);
78 return array_values($xv);