Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
piediagram.php
1<?php
2
4
9
14class PieDiagram extends Base
15{
16 const VIEW_KEY = 'pieDiagram';
17
20
24 public function __construct()
25 {
26 parent::__construct();
27 $this->setLabel(Loc::getMessage('REPORT_PIE_DIAGRAM_VIEW_LABEL'));
28 $this->setLogoUri('/bitrix/images/report/visualconstructor/view-pie.jpg');
29 $this->setCompatibleDataType(Common::MULTIPLE_REPORT_TYPE);
30 $this->setJsClassName('BX.Report.VisualConstructor.Widget.Content.AmChart.PieDiagram');
31 }
32
38 public function getCompatibleViewTypes()
39 {
40 $viewTypes = parent::getCompatibleViewTypes();
41 $viewTypes[] = 'funnel';
42 $viewTypes[] = 'donutDiagram';
43 return $viewTypes;
44 }
45
51 public function getCustomColorList()
52 {
53 return array(
54 '#4fc3f7',
55 '#f6ce00',
56 '#98d470',
57 '#f35455',
58 '#cf83ae',
59 '#374b89',
60 );
61 }
62
69 public function handlerFinallyBeforePassToView($dataFromReport)
70 {
71 $result = parent::handlerFinallyBeforePassToView($dataFromReport);
72 $customColors = $this->getCustomColorList();
73 $result['dataProvider'] = !empty($dataFromReport['items']) ? $dataFromReport['items'] : array();
74
75 foreach ($result['dataProvider'] as $number => &$data)
76 {
77 if (!isset($data['color']) && isset($customColors[$number]))
78 {
79 $data['color'] = $customColors[$number];
80 }
81 }
82 $result['titleField'] = 'label';
83 $result['valueField'] = 'value';
84 $result['colorField'] = 'color';
85 $result['outlineAlpha'] = 0.4;
86 $result['outlineColor'] = "#FFFFFF";
87 $result['outlineThickness'] = 1;
88 $result['labelsEnabled'] = false;
89 $result['legend'] = array(
90 "markerType" => "circle",
91 "position" => "right",
92 "marginRight" => 50,
93 "marginTop" => 10,
94 "autoMargins" => false
95 );
96 return $result;
97 }
98
104 protected function getAmChartType()
105 {
106 return 'pie';
107 }
108
109
116 public function collectReportHandlerFormElements($reportHandler)
117 {
118 parent::collectReportHandlerFormElements($reportHandler);
119
121 $whatWillCalculateField = $reportHandler->getFormElement('calculate');
122 if ($whatWillCalculateField)
123 {
124 $labelField = $reportHandler->getWidgetHandler()->getFormElement('label');
125 $labelField->addJsEventListener($whatWillCalculateField, $whatWillCalculateField::JS_EVENT_ON_CHANGE, array(
126 'class' => 'BX.Report.VisualConstructor.FieldEventHandlers.Title',
127 'action' => 'whatWillCalculateChange',
128 ));
129 $whatWillCalculateField->addAssets(array(
130 'js' => array('/bitrix/js/report/js/visualconstructor/fields/reporttitle.js')
131 ));
132 }
133
134 $removeFormElement = $reportHandler->getFormElementByDataAttribute('role', 'report-remove-button');
135 if ($removeFormElement)
136 {
137 $removeFormElement->setDisplay(false);
138 }
139
140 $colorField = $reportHandler->getFormElement('color');
141 $reportHandler->getFormElement('label_color_container_start')->setDisplay(false);
142 $reportHandler->getFormElement('label_color_container_end')->setDisplay(false);
143 $reportHandler->getFormElement('head_container_start')->setDisplay(false);
144 $reportHandler->getFormElement('head_container_end')->setDisplay(false);
145 if ($colorField)
146 {
147 $colorField->setDisplay(false);
148 }
149
150
151 $labelField = $reportHandler->getFormElement('label');
152 if ($labelField)
153 {
154 $labelField->setDisplay(false);
155 }
156 }
157
164 public function getReportDefaultColor($num)
165 {
166 return '#ffffff';
167 }
168}
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
setCompatibleDataType($compatibleDataType)
Definition view.php:121
collectReportHandlerFormElements($reportHandler)
Definition view.php:289