3 abstract class PhabricatorChartDataset
8 final public function getDatasetTypeKey() {
9 return $this->getPhobjectClassConstant('DATASETKEY', 32);
12 final public function getFunctions() {
13 return $this->functions
;
16 final public function setFunctions(array $functions) {
17 assert_instances_of($functions, 'PhabricatorComposeChartFunction');
19 $this->functions
= $functions;
24 final public static function getAllDatasetTypes() {
25 return id(new PhutilClassMapQuery())
26 ->setAncestorClass(__CLASS__
)
27 ->setUniqueMethod('getDatasetTypeKey')
31 final public static function newFromDictionary(array $map) {
32 PhutilTypeSpec
::checkMap(
36 'functions' => 'list<wild>',
39 $types = self
::getAllDatasetTypes();
41 $dataset_type = $map['type'];
42 if (!isset($types[$dataset_type])) {
45 'Trying to construct a dataset of type "%s", but this type is '.
46 'unknown. Supported types are: %s.',
48 implode(', ', array_keys($types))));
51 $dataset = id(clone $types[$dataset_type]);
54 foreach ($map['functions'] as $map) {
55 $functions[] = PhabricatorChartFunction
::newFromDictionary($map);
57 $dataset->setFunctions($functions);
62 final public function getChartDisplayData(
63 PhabricatorChartDataQuery
$data_query) {
64 return $this->newChartDisplayData($data_query);
67 abstract protected function newChartDisplayData(
68 PhabricatorChartDataQuery
$data_query);
71 final public function getTabularDisplayData(
72 PhabricatorChartDataQuery
$data_query) {
75 $functions = $this->getFunctions();
76 foreach ($functions as $function) {
77 $datapoints = $function->newDatapoints($data_query);
79 $refs = $function->getDataRefs(ipull($datapoints, 'x'));
81 foreach ($datapoints as $key => $point) {
84 if (isset($refs[$x])) {
90 $datapoints[$key]['refs'] = $xrefs;
94 'data' => $datapoints,
98 return id(new PhabricatorChartDisplayData())
99 ->setWireData($results);