Changeset View
Changeset View
Standalone View
Standalone View
src/applications/fact/chart/PhabricatorChartStackedAreaDataset.php
<?php | <?php | ||||
final class PhabricatorChartStackedAreaDataset | final class PhabricatorChartStackedAreaDataset | ||||
extends PhabricatorChartDataset { | extends PhabricatorChartDataset { | ||||
const DATASETKEY = 'stacked-area'; | const DATASETKEY = 'stacked-area'; | ||||
protected function newChartDisplayData( | protected function newChartDisplayData( | ||||
PhabricatorChartDataQuery $data_query) { | PhabricatorChartDataQuery $data_query) { | ||||
$functions = $this->getFunctions(); | $functions = $this->getFunctions(); | ||||
$reversed_functions = array_reverse($functions, true); | |||||
epriestley: I'm defining functions in top-to-bottom order everywhere else now, but we need to sum them in… | |||||
$function_points = array(); | $function_points = array(); | ||||
foreach ($functions as $function_idx => $function) { | foreach ($reversed_functions as $function_idx => $function) { | ||||
$function_points[$function_idx] = array(); | $function_points[$function_idx] = array(); | ||||
$datapoints = $function->newDatapoints($data_query); | $datapoints = $function->newDatapoints($data_query); | ||||
foreach ($datapoints as $point) { | foreach ($datapoints as $point) { | ||||
$x = $point['x']; | $x = $point['x']; | ||||
$function_points[$function_idx][$x] = $point; | $function_points[$function_idx][$x] = $point; | ||||
} | } | ||||
} | } | ||||
Show All 9 Lines | protected function newChartDisplayData( | ||||
$must_define = array(); | $must_define = array(); | ||||
foreach ($function_points as $function_idx => $points) { | foreach ($function_points as $function_idx => $points) { | ||||
foreach ($points as $x => $point) { | foreach ($points as $x => $point) { | ||||
$must_define[$x] = $x; | $must_define[$x] = $x; | ||||
} | } | ||||
} | } | ||||
ksort($must_define); | ksort($must_define); | ||||
foreach ($functions as $function_idx => $function) { | foreach ($reversed_functions as $function_idx => $function) { | ||||
$missing = array(); | $missing = array(); | ||||
foreach ($must_define as $x) { | foreach ($must_define as $x) { | ||||
if (!isset($function_points[$function_idx][$x])) { | if (!isset($function_points[$function_idx][$x])) { | ||||
$missing[$x] = true; | $missing[$x] = true; | ||||
} | } | ||||
} | } | ||||
if (!$missing) { | if (!$missing) { | ||||
▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | foreach ($function_points as $function_idx => $points) { | ||||
$range_max = $y1; | $range_max = $y1; | ||||
} | } | ||||
$range_max = max($range_max, $y0, $y1); | $range_max = max($range_max, $y0, $y1); | ||||
} | } | ||||
$series[] = $bounds; | $series[] = $bounds; | ||||
} | } | ||||
$series = array_reverse($series); | |||||
$events = array(); | $events = array(); | ||||
foreach ($raw_points as $function_idx => $points) { | foreach ($raw_points as $function_idx => $points) { | ||||
$event_list = array(); | $event_list = array(); | ||||
foreach ($points as $point) { | foreach ($points as $point) { | ||||
$event_list[] = $point; | $event_list[] = $point; | ||||
} | } | ||||
$events[] = $event_list; | $events[] = $event_list; | ||||
} | } | ||||
Show All 21 Lines |
I'm defining functions in top-to-bottom order everywhere else now, but we need to sum them in bottom-to-top order, so I'm flipping things around and then back again to make sure everything ends up in agreement.