23 parent::__construct();
38 $result = parent::handlerFinallyBeforePassToView($dataFromReport);
40 'dataProvider' => array(),
41 'dataDateFormat' =>
'YYYY-MM-DD',
44 'integersOnly' =>
true,
52 'startDuration' => 0.5,
54 'categoryField' =>
'groupingField',
55 'categoryAxis' => array(
59 'position' =>
'bottom',
63 'position' =>
'bottom-right'
66 'useGraphSettings' =>
true,
67 'equalWidths' =>
false,
68 'position' =>
"bottom"
70 'chartCursor' => array(
72 'oneBalloonOnly' =>
true,
73 'categoryBalloonEnabled' =>
true,
74 'categoryBalloonColor' =>
"#000000",
81 foreach ($dataFromReport as $data)
84 if (isset($data[
'items']))
86 foreach ($data[
'items'] as $key => $res)
88 if (!isset($result[
'dataProvider'][$res[
'groupBy']]))
90 $result[
'dataProvider'][$res[
'groupBy']] = [
91 'groupingField' => $data[
'config'][
'groupsLabelMap'][$res[
'groupBy']] ??
'-',
95 $result[
'dataProvider'][$res[
'groupBy']][
'value_' . $reportCount] = $res[
'value'];
99 $result[
'dataProvider'][$res[
'groupBy']][
'label_' . $reportCount] = $res[
'label'];
101 if ($res[
'targetUrl'])
103 $result[
'dataProvider'][$res[
'groupBy']][
'targetUrl_' . $reportCount] = $res[
'targetUrl'];
108 $balloon = $result[
'dataProvider'][$res[
'groupBy']][
'balloon'] ?: [];
109 $result[
'dataProvider'][$res[
'groupBy']][
'balloon'] = array_merge($balloon, $res[
'balloon']);
112 if ($result[
'valueAxes'][0][
'maximum'] < $res[
'value'])
114 $result[
'valueAxes'][0][
'maximum'] = $res[
'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,
129 if(isset($data[
"config"][
"balloonFunction"]))
131 $graph[
"balloonFunction"] = $data[
"config"][
"balloonFunction"];
135 $graph[
"balloonText"] = htmlspecialcharsbx($data[
"config"][
"reportTitle"]) .
" [[value]]";
137 $result[
'graphs'][] = $graph;
141 if (static::ENABLE_SORTING)
143 ksort($result[
'dataProvider']);
146 $result[
'dataProvider'] = array_values($result[
'dataProvider']);
158 parent::collectReportHandlerFormElements($reportHandler);
160 $whatWillCalculateField = $reportHandler->getFormElement(
'calculate');
161 $labelField = $reportHandler->getFormElement(
'label');
162 if ($whatWillCalculateField)
164 $labelField->addJsEventListener($whatWillCalculateField, $whatWillCalculateField::JS_EVENT_ON_CHANGE, array(
165 'class' =>
'BX.Report.VisualConstructor.FieldEventHandlers.Title',
166 'action' =>
'whatWillCalculateChange',
168 $whatWillCalculateField->addAssets(array(
169 'js' => array(
'/bitrix/js/report/js/visualconstructor/fields/reporttitle.js')