@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class PhabricatorSumChartFunction
4 extends PhabricatorHigherOrderChartFunction {
5
6 const FUNCTIONKEY = 'sum';
7
8 protected function newArguments() {
9 return array(
10 $this->newArgument()
11 ->setName('f')
12 ->setType('function')
13 ->setRepeatable(true),
14 );
15 }
16
17 public function evaluateFunction(array $xv) {
18 $fv = array();
19 foreach ($this->getFunctionArguments() as $function) {
20 $fv[] = $function->evaluateFunction($xv);
21 }
22
23 $n = count($xv);
24 $yv = array_fill(0, $n, null);
25
26 foreach ($fv as $f) {
27 for ($ii = 0; $ii < $n; $ii++) {
28 if ($f[$ii] !== null) {
29 if (!isset($yv[$ii])) {
30 $yv[$ii] = 0;
31 }
32 $yv[$ii] += $f[$ii];
33 }
34 }
35 }
36
37 return $yv;
38 }
39
40}