Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
serial.php
1<?php
2
4
8
13abstract class Serial extends Base
14{
16
17 const ENABLE_SORTING = true;
21 public function __construct()
22 {
23 parent::__construct();
24 $this->setCompatibleDataType(Common::MULTIPLE_GROUPED_REPORT_TYPE);
25 }
26
27
36 public function handlerFinallyBeforePassToView($dataFromReport)
37 {
38 $result = parent::handlerFinallyBeforePassToView($dataFromReport);
39 $result += array(
40 'dataProvider' => array(),
41 'dataDateFormat' => 'YYYY-MM-DD',
42 'valueAxes' => array(
43 array(
44 'integersOnly' => true,
45 'maximum' => 0,
46 'minimum' => 0,
47 'reversed' => false,
48 'axisAlpha' => 0,
49 'position' => 'left'
50 )
51 ),
52 'startDuration' => 0.5,
53 'graphs' => array(),
54 'categoryField' => 'groupingField',
55 'categoryAxis' => array(
56 'axisAlpha' => 0,
57 'fillAlpha' => 0.05,
58 'gridAlpha' => 0,
59 'position' => 'bottom',
60 ),
61 'export' => array(
62 'enabled' => true,
63 'position' => 'bottom-right'
64 ),
65 'legend' => array(
66 'useGraphSettings' => true,
67 'equalWidths' => false,
68 'position' => "bottom"
69 ),
70 'chartCursor' => array(
71 'enabled' => true,
72 'oneBalloonOnly' => true,
73 'categoryBalloonEnabled' => true,
74 'categoryBalloonColor' => "#000000",
75 'cursorAlpha' => 1,
76 'zoomable' => true,
77 ),
78 );
79
80 $reportCount = 0;
81 foreach ($dataFromReport as $data)
82 {
83 $reportCount++;
84 if (isset($data['items']))
85 {
86 foreach ($data['items'] as $key => $res)
87 {
88 if (!isset($result['dataProvider'][$res['groupBy']]))
89 {
90 $result['dataProvider'][$res['groupBy']] = [
91 'groupingField' => $data['config']['groupsLabelMap'][$res['groupBy']] ?? '-',
92 ];
93 }
94 //$result['dataProvider'][$res['groupBy']]['bullet'] = "https://www.amcharts.com/lib/images/faces/A04.png";
95 $result['dataProvider'][$res['groupBy']]['value_' . $reportCount] = $res['value'];
96
97 if ($res['label'])
98 {
99 $result['dataProvider'][$res['groupBy']]['label_' . $reportCount] = $res['label'];
100 }
101 if ($res['targetUrl'])
102 {
103 $result['dataProvider'][$res['groupBy']]['targetUrl_' . $reportCount] = $res['targetUrl'];
104 }
105
106 if ($res['balloon'])
107 {
108 $balloon = $result['dataProvider'][$res['groupBy']]['balloon'] ?: [];
109 $result['dataProvider'][$res['groupBy']]['balloon'] = array_merge($balloon, $res['balloon']);
110 }
111
112 if ($result['valueAxes'][0]['maximum'] < $res['value'])
113 {
114 $result['valueAxes'][0]['maximum'] = $res['value'];
115 }
116 }
117
118 $graph = array(
119 "bullet" => "round",
120 //"labelText" => "[[value]]",
121 "title" => htmlspecialcharsbx($data['config']['reportTitle']),
122 "fillColors" => $data['config']['reportColor'],
123 "lineColor" => $data['config']['reportColor'],
124 "valueField" => 'value_' . $reportCount,
125 "descriptionField" => 'label_' . $reportCount,
126 "fillAlphas" => 0,
127 );
128
129 if(isset($data["config"]["balloonFunction"]))
130 {
131 $graph["balloonFunction"] = $data["config"]["balloonFunction"];
132 }
133 else
134 {
135 $graph["balloonText"] = htmlspecialcharsbx($data["config"]["reportTitle"]) . " [[value]]";
136 }
137 $result['graphs'][] = $graph;
138 }
139 }
140
141 if (static::ENABLE_SORTING)
142 {
143 ksort($result['dataProvider']);
144 }
145
146 $result['dataProvider'] = array_values($result['dataProvider']);
147 return $result;
148 }
149
156 public function collectReportHandlerFormElements($reportHandler)
157 {
158 parent::collectReportHandlerFormElements($reportHandler);
160 $whatWillCalculateField = $reportHandler->getFormElement('calculate');
161 $labelField = $reportHandler->getFormElement('label');
162 if ($whatWillCalculateField)
163 {
164 $labelField->addJsEventListener($whatWillCalculateField, $whatWillCalculateField::JS_EVENT_ON_CHANGE, array(
165 'class' => 'BX.Report.VisualConstructor.FieldEventHandlers.Title',
166 'action' => 'whatWillCalculateChange',
167 ));
168 $whatWillCalculateField->addAssets(array(
169 'js' => array('/bitrix/js/report/js/visualconstructor/fields/reporttitle.js')
170 ));
171 }
172
173 }
174
180 protected function getAmChartType()
181 {
182 return 'serial';
183 }
184}
setCompatibleDataType($compatibleDataType)
Definition view.php:121
collectReportHandlerFormElements($reportHandler)
Definition view.php:289