Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
serial.php
1<?php
2
4
8
13abstract class Serial extends Base
14{
16 const ENABLE_SORTING = true;
18
22 public function __construct()
23 {
24 parent::__construct();
25 $this->setCompatibleDataType(Common::MULTIPLE_GROUPED_REPORT_TYPE);
26 }
27
36 public function handlerFinallyBeforePassToView($dataFromReport)
37 {
38 $result = parent::handlerFinallyBeforePassToView($dataFromReport);
39 $result += array(
40 'paddingTop' => 0,
41 'maskBullets' => false,
42 'fontSize' => '11px',
43 'data' => [],
44 "series" => [],
45 "xAxes" => [
46 [
47 "type" => "CategoryAxis",
48 "dataFields" => [
49 "category" => "groupingField"
50 ],
51 "renderer" => [
52 "grid" => [
53 "disabled" => true,
54 ],
55 "labels" => [
56 "template" => [
57 "truncate" => true,
58 "ellipsis" => "&hellip;",
59 "fixedWidthGrid" => true,
60 "horizontalCenter" => "middle",
61 "fullWords" => false,
62 "tooltipText" => "{category}"
63 ],
64 ],
65 ]
66 ]
67 ],
68 "yAxes" => [[
69 "type" => "ValueAxis",
70 "min" => 0,
71 ]],
72 );
73
74 $reportCount = 0;
75 foreach ($dataFromReport as $data)
76 {
77 $reportCount++;
78 if (isset($data['items']))
79 {
80 foreach ($data['items'] as $key => $res)
81 {
82 if (!isset($result['data'][$res['groupBy']]))
83 {
84 $result['data'][$res['groupBy']] = [
85 'groupingField' => $data['config']['groupsLabelMap'][$res['groupBy']] ?? '-',
86 ];
87 }
88 $result['data'][$res['groupBy']]['value_'.$reportCount] = $res['value'];
89
90 if ($res['label'])
91 {
92 $result['data'][$res['groupBy']]['label_'.$reportCount] = $res['label'];
93 }
94 if ($res['targetUrl'])
95 {
96 $result['data'][$res['groupBy']]['targetUrl_'.$reportCount] = $res['targetUrl'];
97 }
98
99 if ($res['balloon'])
100 {
101 $balloon = $result['data'][$res['groupBy']]['balloon'] ?: [];
102 $result['data'][$res['groupBy']]['balloon'] = array_merge($balloon, $res['balloon']);
103 }
104 }
105
106 $series = [
107 "type" => "", // should be filled in child class
108 "dataFields" => [
109 "valueY" => 'value_'.$reportCount,
110 "categoryX" => "groupingField"
111 ],
112 "columns" => [
113 "fill" => $data['config']['reportColor'],
114 "strokeWidth" => 0,
115 "propertyFields" => [
116 "fill" => "color",
117 //"tooltipText" => 'label_'.$reportCount
118 // we are not using standard url, because we are trying to open in in a sidepanel
119 "valueUrl" => "targetUrl_1",
120 ],
121 "width" => "85%",
122 "tooltipText" => htmlspecialcharsbx($data["config"]["reportTitle"]) . " {valueY}",
123 ],
124
125 "tooltip" => [
126 "background" => ["disabled" => true],
127 "filters" => [
128 [
129 "type" => "DropShadowFilter",
130 "opacity" => 0.1
131 ]
132 ]
133 ]
134 ];
135
136 $result['series'][] = $series;
137 }
138 }
139
140 if (static::ENABLE_SORTING)
141 {
142 ksort($result['data']);
143 }
144
145 $result['data'] = array_values($result['data']);
146 return $result;
147 }
148
155 public function collectReportHandlerFormElements($reportHandler)
156 {
157 parent::collectReportHandlerFormElements($reportHandler);
159 $whatWillCalculateField = $reportHandler->getFormElement('calculate');
160 $labelField = $reportHandler->getFormElement('label');
161 if ($whatWillCalculateField)
162 {
163 $labelField->addJsEventListener($whatWillCalculateField, $whatWillCalculateField::JS_EVENT_ON_CHANGE, array(
164 'class' => 'BX.Report.VisualConstructor.FieldEventHandlers.Title',
165 'action' => 'whatWillCalculateChange',
166 ));
167 $whatWillCalculateField->addAssets(array(
168 'js' => array('/bitrix/js/report/js/visualconstructor/fields/reporttitle.js')
169 ));
170 }
171
172 }
173
179 protected function getAmChartType()
180 {
181 return 'XYChart';
182 }
183}
setCompatibleDataType($compatibleDataType)
Definition view.php:121
collectReportHandlerFormElements($reportHandler)
Definition view.php:289