Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
storeprofitgraph.php
1
<?php
2
3
namespace
Bitrix\Catalog\Integration\Report\View\StoreProfit
;
4
5
use
Bitrix\Catalog\Integration\Report\Handler\BaseHandler
;
6
use
Bitrix\Catalog\Integration\Report\Handler\StoreProfit\GraphHandler
;
7
use
Bitrix\Catalog\Integration\Report\View\ViewRenderable
;
8
use
Bitrix\Currency\CurrencyManager
;
9
use
Bitrix\Main\Localization\Loc
;
10
use
Bitrix\Main\UI\Extension
;
11
use
Bitrix\Report\VisualConstructor\Views\JsComponent\AmChart\LinearGraph
;
12
13
class
StoreProfitGraph
extends
LinearGraph
implements
ViewRenderable
14
{
15
public
const
ENABLE_SORTING
=
false
;
16
public
const
VIEW_KEY
=
'store_profit_graph'
;
17
public
const
MAX_RENDER_REPORT_COUNT
= 1;
18
public
const
USE_IN_VISUAL_CONSTRUCTOR
=
false
;
19
20
public
function
__construct
()
21
{
22
parent::__construct();
23
24
$this->
setLabel
(
Loc::getMessage
(
'STORE_PROFIT_CHART_LABEL'
));
25
$this->
setDraggable
(
false
);
26
Extension::load
([
"catalog.store-chart"
]);
27
}
28
32
public
function
handlerFinallyBeforePassToView
($dataFromReport)
33
{
34
$result = parent::handlerFinallyBeforePassToView($dataFromReport);
35
36
if
(is_array($dataFromReport) && isset($result[
'valueAxes'
]))
37
{
38
foreach
($dataFromReport as $data)
39
{
40
if
(empty($data[
'items'
]))
41
{
42
continue
;
43
}
44
45
foreach
($data[
'items'
] as $item)
46
{
47
if
($item[
'value'
] < 0 && $result[
'valueAxes'
][0][
'minimum'
] > $item[
'value'
])
48
{
49
$result[
'valueAxes'
][0][
'minimum'
] = $item[
'value'
];
50
}
51
}
52
}
53
}
54
55
if
(is_array($result[
'dataProvider'
]))
56
{
57
$result[
'categoryAxis'
][
'autoGridCount'
] =
true
;
58
$result[
'categoryAxis'
][
'minHorizontalGap'
] = 0;
59
$result[
'categoryAxis'
][
'labelFrequency'
] = ceil(count($result[
'dataProvider'
]) / 10);
60
61
foreach
($result[
'dataProvider'
] as $k => $item)
62
{
63
if
(!isset($result[
'dataProvider'
][$k][
'value_1'
]))
64
{
65
$result[
'dataProvider'
][$k][
'value_1'
] = 0;
66
}
67
if
(!isset($result[
'dataProvider'
][$k][
'value_2'
]))
68
{
69
$result[
'dataProvider'
][$k][
'value_2'
] = 0;
70
}
71
}
72
}
73
74
if
(is_array($result[
'graphs'
]))
75
{
76
$baseCurrency = CurrencyManager::getBaseCurrency();
77
foreach
($result[
'graphs'
] as $k => $graph)
78
{
79
$result[
'graphs'
][$k][
"balloonFunction"
] =
"BX.Catalog.LinearGraphBalloon.renderBalloon"
;
80
$result[
'graphs'
][$k][
"balloon"
][
"borderThickness"
] = 0;
81
$title = $result[
'graphs'
][$k][
'title'
];
82
$amount = $dataFromReport[$k][
'config'
][
'amount'
] ?? \CCurrencyLang::CurrencyFormat(0, $baseCurrency);
83
$result[
'graphs'
][$k][
"title"
] =
"$title ($amount)"
;
84
}
85
}
86
87
$result[
'legend'
][
'valueText'
] =
''
;
88
$result[
'legend'
][
'align'
] =
'center'
;
89
90
return
$result;
91
}
92
96
public
function
getViewHandler
():
BaseHandler
97
{
98
return
new
GraphHandler
();
99
}
100
}
Bitrix\Catalog\Integration\Report\Handler\BaseHandler
Definition
basehandler.php:26
Bitrix\Catalog\Integration\Report\Handler\StoreProfit\GraphHandler
Definition
graphhandler.php:16
Bitrix\Catalog\Integration\Report\View\StoreProfit\StoreProfitGraph
Definition
storeprofitgraph.php:14
Bitrix\Catalog\Integration\Report\View\StoreProfit\StoreProfitGraph\__construct
__construct()
Definition
storeprofitgraph.php:20
Bitrix\Catalog\Integration\Report\View\StoreProfit\StoreProfitGraph\USE_IN_VISUAL_CONSTRUCTOR
const USE_IN_VISUAL_CONSTRUCTOR
Definition
storeprofitgraph.php:18
Bitrix\Catalog\Integration\Report\View\StoreProfit\StoreProfitGraph\ENABLE_SORTING
const ENABLE_SORTING
Definition
storeprofitgraph.php:15
Bitrix\Catalog\Integration\Report\View\StoreProfit\StoreProfitGraph\MAX_RENDER_REPORT_COUNT
const MAX_RENDER_REPORT_COUNT
Definition
storeprofitgraph.php:17
Bitrix\Catalog\Integration\Report\View\StoreProfit\StoreProfitGraph\handlerFinallyBeforePassToView
handlerFinallyBeforePassToView($dataFromReport)
Definition
storeprofitgraph.php:32
Bitrix\Catalog\Integration\Report\View\StoreProfit\StoreProfitGraph\VIEW_KEY
const VIEW_KEY
Definition
storeprofitgraph.php:16
Bitrix\Catalog\Integration\Report\View\StoreProfit\StoreProfitGraph\getViewHandler
getViewHandler()
Definition
storeprofitgraph.php:96
Bitrix\Currency\CurrencyManager
Definition
currencymanager.php:15
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\UI\Extension
Definition
extension.php:11
Bitrix\Main\UI\Extension\load
static load($extNames)
Definition
extension.php:17
Bitrix\Report\VisualConstructor\View\setDraggable
setDraggable($draggable)
Definition
view.php:453
Bitrix\Report\VisualConstructor\View\setLabel
setLabel($label)
Definition
view.php:83
Bitrix\Report\VisualConstructor\Views\JsComponent\AmChart\LinearGraph
Definition
lineargraph.php:12
Bitrix\Catalog\Integration\Report\View\ViewRenderable
Definition
viewrenderable.php:12
Bitrix\Catalog\Integration\Report\View\StoreProfit
Definition
storeprofitgraph.php:3
modules
catalog
lib
integration
report
view
storeprofit
storeprofitgraph.php
Создано системой
1.10.0