Changeset View
Changeset View
Standalone View
Standalone View
src/applications/fact/controller/PhabricatorFactChartController.php
<?php | <?php | ||||
final class PhabricatorFactChartController extends PhabricatorFactController { | final class PhabricatorFactChartController extends PhabricatorFactController { | ||||
public function handleRequest(AphrontRequest $request) { | public function handleRequest(AphrontRequest $request) { | ||||
$viewer = $request->getViewer(); | $viewer = $request->getViewer(); | ||||
// When drawing a chart, we send down a placeholder piece of HTML first, | // When drawing a chart, we send down a placeholder piece of HTML first, | ||||
// then fetch the data via async request. Determine if we're drawing | // then fetch the data via async request. Determine if we're drawing | ||||
// the structure or actually pulling the data. | // the structure or actually pulling the data. | ||||
$mode = $request->getURIData('mode'); | $mode = $request->getURIData('mode'); | ||||
$is_chart_mode = ($mode === 'chart'); | $is_chart_mode = ($mode === 'chart'); | ||||
$is_draw_mode = ($mode === 'draw'); | $is_draw_mode = ($mode === 'draw'); | ||||
$functions = array(); | $functions = array(); | ||||
$functions[] = id(new PhabricatorFactChartFunction()) | |||||
->setArguments(array('tasks.count.create')); | |||||
$functions[] = id(new PhabricatorFactChartFunction()) | |||||
->setArguments(array('tasks.open-count.create')); | |||||
$x_function = id(new PhabricatorXChartFunction()) | $x_function = id(new PhabricatorXChartFunction()) | ||||
->setArguments(array()); | ->setArguments(array()); | ||||
$functions[] = id(new PhabricatorConstantChartFunction()) | $functions[] = id(new PhabricatorConstantChartFunction()) | ||||
->setArguments(array(360)); | ->setArguments(array(360)); | ||||
$functions[] = id(new PhabricatorSinChartFunction()) | $functions[] = id(new PhabricatorSinChartFunction()) | ||||
->setArguments(array($x_function)); | ->setArguments(array($x_function)); | ||||
$cos_function = id(new PhabricatorCosChartFunction()) | $cos_function = id(new PhabricatorCosChartFunction()) | ||||
->setArguments(array($x_function)); | ->setArguments(array($x_function)); | ||||
$functions[] = id(new PhabricatorShiftChartFunction()) | $functions[] = id(new PhabricatorShiftChartFunction()) | ||||
->setArguments( | ->setArguments( | ||||
array( | array( | ||||
array( | array( | ||||
'scale', | 'scale', | ||||
array( | array( | ||||
'cos', | 'cos', | ||||
array( | array( | ||||
'scale', | 'scale', | ||||
array('x'), | array('x'), | ||||
0.001, | 0.0001, | ||||
), | ), | ||||
), | ), | ||||
10, | |||||
), | |||||
200, | 200, | ||||
), | |||||
75, | |||||
)); | |||||
$functions[] = id(new PhabricatorAccumulateChartFunction()) | |||||
->setArguments( | |||||
array( | |||||
array( | |||||
'fact', | |||||
'tasks.count.create', | |||||
), | |||||
)); | )); | ||||
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); | ||||
foreach ($functions as $function) { | |||||
foreach ($function->selectAllFunctions() as $subfunction) { | |||||
$subfunction->loadData(); | |||||
} | |||||
} | |||||
$datasets = array(); | $datasets = array(); | ||||
foreach ($functions as $function) { | foreach ($functions as $function) { | ||||
$function->setXAxis($axis); | $function->setXAxis($axis); | ||||
$function->loadData(); | $function->loadData(); | ||||
$points = $function->getDatapoints($data_query); | $points = $function->getDatapoints($data_query); | ||||
▲ Show 20 Lines • Show All 132 Lines • Show Last 20 Lines |