Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / project / chart / PhabricatorProjectActivityChartEngine.php
blob7fc599317f53b37e86227e5f5a636a15dde832db
1 <?php
3 final class PhabricatorProjectActivityChartEngine
4 extends PhabricatorChartEngine {
6 const CHARTENGINEKEY = 'project.activity';
8 public function setProjects(array $projects) {
9 assert_instances_of($projects, 'PhabricatorProject');
10 $project_phids = mpull($projects, 'getPHID');
11 return $this->setEngineParameter('projectPHIDs', $project_phids);
14 protected function newChart(PhabricatorFactChart $chart, array $map) {
15 $viewer = $this->getViewer();
17 $map = $map + array(
18 'projectPHIDs' => array(),
21 if ($map['projectPHIDs']) {
22 $projects = id(new PhabricatorProjectQuery())
23 ->setViewer($viewer)
24 ->withPHIDs($map['projectPHIDs'])
25 ->execute();
26 $project_phids = mpull($projects, 'getPHID');
27 } else {
28 $project_phids = array();
31 $project_phid = head($project_phids);
33 $functions = array();
34 $stacks = array();
36 $function = $this->newFunction(
37 array(
38 'accumulate',
39 array(
40 'compose',
41 array('fact', 'tasks.open-count.assign.project', $project_phid),
42 array('min', 0),
44 ));
46 $function->getFunctionLabel()
47 ->setKey('moved-in')
48 ->setName(pht('Tasks Moved Into Project'))
49 ->setColor('rgba(128, 128, 200, 1)')
50 ->setFillColor('rgba(128, 128, 200, 0.15)');
52 $functions[] = $function;
54 $function = $this->newFunction(
55 array(
56 'accumulate',
57 array(
58 'compose',
59 array('fact', 'tasks.open-count.status.project', $project_phid),
60 array('min', 0),
62 ));
64 $function->getFunctionLabel()
65 ->setKey('reopened')
66 ->setName(pht('Tasks Reopened'))
67 ->setColor('rgba(128, 128, 200, 1)')
68 ->setFillColor('rgba(128, 128, 200, 0.15)');
70 $functions[] = $function;
72 $function = $this->newFunction(
73 array(
74 'accumulate',
75 array('fact', 'tasks.open-count.create.project', $project_phid),
76 ));
78 $function->getFunctionLabel()
79 ->setKey('created')
80 ->setName(pht('Tasks Created'))
81 ->setColor('rgba(0, 0, 200, 1)')
82 ->setFillColor('rgba(0, 0, 200, 0.15)');
84 $functions[] = $function;
86 $function = $this->newFunction(
87 array(
88 'accumulate',
89 array(
90 'compose',
91 array('fact', 'tasks.open-count.status.project', $project_phid),
92 array('max', 0),
94 ));
96 $function->getFunctionLabel()
97 ->setKey('closed')
98 ->setName(pht('Tasks Closed'))
99 ->setColor('rgba(0, 200, 0, 1)')
100 ->setFillColor('rgba(0, 200, 0, 0.15)');
102 $functions[] = $function;
104 $function = $this->newFunction(
105 array(
106 'accumulate',
107 array(
108 'compose',
109 array('fact', 'tasks.open-count.assign.project', $project_phid),
110 array('max', 0),
114 $function->getFunctionLabel()
115 ->setKey('moved-out')
116 ->setName(pht('Tasks Moved Out of Project'))
117 ->setColor('rgba(128, 200, 128, 1)')
118 ->setFillColor('rgba(128, 200, 128, 0.15)');
120 $functions[] = $function;
122 $stacks[] = array('created', 'reopened', 'moved-in');
123 $stacks[] = array('closed', 'moved-out');
125 $datasets = array();
127 $dataset = id(new PhabricatorChartStackedAreaDataset())
128 ->setFunctions($functions)
129 ->setStacks($stacks);
131 $datasets[] = $dataset;
132 $chart->attachDatasets($datasets);