Changeset View
Changeset View
Standalone View
Standalone View
src/applications/fact/chart/PhabricatorAccumulateChartFunction.php
Show All 29 Lines | public function evaluateFunction(array $xv) { | ||||
// Use an unconstrained query to pull all the data from the underlying | // Use an unconstrained query to pull all the data from the underlying | ||||
// source. We need to accumulate data since the beginning of time to | // source. We need to accumulate data since the beginning of time to | ||||
// figure out the right Y-intercept -- otherwise, we'll always start at | // figure out the right Y-intercept -- otherwise, we'll always start at | ||||
// "0" wherever our domain begins. | // "0" wherever our domain begins. | ||||
$empty_query = new PhabricatorChartDataQuery(); | $empty_query = new PhabricatorChartDataQuery(); | ||||
$datasource_xv = $datasource->newInputValues($empty_query); | $datasource_xv = $datasource->newInputValues($empty_query); | ||||
if (!$datasource_xv) { | if (!$datasource_xv) { | ||||
// TODO: Maybe this should just be an error? | // When the datasource has no datapoints, we can't evaluate the function | ||||
$datasource_xv = $xv; | // anywhere. | ||||
return array_fill(0, count($xv), null); | |||||
} | } | ||||
$yv = $datasource->evaluateFunction($datasource_xv); | $yv = $datasource->evaluateFunction($datasource_xv); | ||||
$map = array_combine($datasource_xv, $yv); | $map = array_combine($datasource_xv, $yv); | ||||
$accumulator = 0; | $accumulator = 0; | ||||
foreach ($map as $x => $y) { | foreach ($map as $x => $y) { | ||||
Show All 34 Lines |