Changeset View
Changeset View
Standalone View
Standalone View
src/applications/fact/engine/PhabricatorChartRenderingEngine.php
Show First 20 Lines • Show All 113 Lines • ▼ Show 20 Lines | final class PhabricatorChartRenderingEngine | ||||
public function newChartData() { | public function newChartData() { | ||||
$chart = $this->getStoredChart(); | $chart = $this->getStoredChart(); | ||||
$chart_key = $chart->getChartKey(); | $chart_key = $chart->getChartKey(); | ||||
$datasets = $chart->getDatasets(); | $datasets = $chart->getDatasets(); | ||||
$functions = array(); | $functions = array(); | ||||
foreach ($datasets as $dataset) { | foreach ($datasets as $dataset) { | ||||
$functions[] = $dataset->getFunction(); | foreach ($dataset->getFunctions() as $function) { | ||||
$functions[] = $function; | |||||
} | |||||
} | } | ||||
$subfunctions = array(); | $subfunctions = array(); | ||||
foreach ($functions as $function) { | foreach ($functions as $function) { | ||||
foreach ($function->getSubfunctions() as $subfunction) { | foreach ($function->getSubfunctions() as $subfunction) { | ||||
$subfunctions[] = $subfunction; | $subfunctions[] = $subfunction; | ||||
} | } | ||||
} | } | ||||
foreach ($subfunctions as $subfunction) { | foreach ($subfunctions as $subfunction) { | ||||
$subfunction->loadData(); | $subfunction->loadData(); | ||||
} | } | ||||
list($domain_min, $domain_max) = $this->getDomain($functions); | list($domain_min, $domain_max) = $this->getDomain($functions); | ||||
$axis = id(new PhabricatorChartAxis()) | $axis = id(new PhabricatorChartAxis()) | ||||
->setMinimumValue($domain_min) | ->setMinimumValue($domain_min) | ||||
->setMaximumValue($domain_max); | ->setMaximumValue($domain_max); | ||||
$data_query = id(new PhabricatorChartDataQuery()) | $data_query = id(new PhabricatorChartDataQuery()) | ||||
->setMinimumValue($domain_min) | ->setMinimumValue($domain_min) | ||||
->setMaximumValue($domain_max) | ->setMaximumValue($domain_max) | ||||
->setLimit(2000); | ->setLimit(2000); | ||||
$datasets = array(); | $wire_datasets = array(); | ||||
foreach ($functions as $function) { | |||||
$points = $function->newDatapoints($data_query); | |||||
$x = array(); | |||||
$y = array(); | |||||
foreach ($points as $point) { | |||||
$x[] = $point['x']; | |||||
$y[] = $point['y']; | |||||
} | |||||
$datasets[] = array( | |||||
'x' => $x, | |||||
'y' => $y, | |||||
'color' => '#ff00ff', | |||||
); | |||||
} | |||||
$y_min = 0; | |||||
$y_max = 0; | |||||
foreach ($datasets as $dataset) { | foreach ($datasets as $dataset) { | ||||
if (!$dataset['y']) { | $wire_datasets[] = $dataset->getWireFormat($data_query); | ||||
continue; | |||||
} | } | ||||
$y_min = min($y_min, min($dataset['y'])); | // TODO: Figure these out from the datasets again. | ||||
$y_max = max($y_max, max($dataset['y'])); | $y_min = -2; | ||||
} | $y_max = 20; | ||||
$chart_data = array( | $chart_data = array( | ||||
'datasets' => $datasets, | 'datasets' => $wire_datasets, | ||||
'xMin' => $domain_min, | 'xMin' => $domain_min, | ||||
'xMax' => $domain_max, | 'xMax' => $domain_max, | ||||
'yMin' => $y_min, | 'yMin' => $y_min, | ||||
'yMax' => $y_max, | 'yMax' => $y_max, | ||||
); | ); | ||||
return $chart_data; | return $chart_data; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 45 Lines • Show Last 20 Lines |