Source
xxxxxxxxxx
135
135
136
136
$graph->showLegend(getRequest('legend', $dbGraph['show_legend']));
137
137
$graph->showWorkPeriod($dbGraph['show_work_period']);
138
138
$graph->showTriggers($dbGraph['show_triggers']);
139
139
$graph->setWidth($width);
140
140
$graph->setHeight($height);
141
141
$graph->setYMinAxisType($dbGraph['ymin_type']);
142
142
$graph->setYMaxAxisType($dbGraph['ymax_type']);
143
143
$graph->setYAxisMin($dbGraph['yaxismin']);
144
144
$graph->setYAxisMax($dbGraph['yaxismax']);
145
-
$graph->setYMinItemId($dbGraph['ymin_itemid']);
146
-
$graph->setYMaxItemId($dbGraph['ymax_itemid']);
145
+
146
+
$yaxis_items = array_intersect_key($dbGraph, array_filter([
147
+
'ymin_itemid' => $dbGraph['ymin_type'] == GRAPH_YAXIS_TYPE_ITEM_VALUE && $dbGraph['ymin_itemid'] != 0,
148
+
'ymax_itemid' => $dbGraph['ymax_type'] == GRAPH_YAXIS_TYPE_ITEM_VALUE && $dbGraph['ymax_itemid'] != 0
149
+
]));
150
+
151
+
if ($yaxis_items) {
152
+
$db_items = API::Item()->get([
153
+
'itemids' => array_values($yaxis_items),
154
+
'filter' => ['value_type' => [ITEM_VALUE_TYPE_FLOAT, ITEM_VALUE_TYPE_UINT64]],
155
+
'webitems' => true,
156
+
'preservekeys' => true
157
+
]);
158
+
159
+
if (array_key_exists('ymin_itemid', $yaxis_items) && array_key_exists($yaxis_items['ymin_itemid'], $db_items)) {
160
+
$graph->setYMinItemId($yaxis_items['ymin_itemid']);
161
+
}
162
+
163
+
if (array_key_exists('ymax_itemid', $yaxis_items) && array_key_exists($yaxis_items['ymax_itemid'], $db_items)) {
164
+
$graph->setYMaxItemId($yaxis_items['ymax_itemid']);
165
+
}
166
+
}
167
+
147
168
$graph->setLeftPercentage($dbGraph['percent_left']);
148
169
$graph->setRightPercentage($dbGraph['percent_right']);
149
170
150
171
if (hasRequest('outer')) {
151
172
$graph->setOuter(getRequest('outer'));
152
173
}
153
174
154
175
$min_dimensions = $graph->getMinDimensions();
155
176
if ($min_dimensions['width'] > $graph->getWidth()) {
156
177
$graph->setWidth($min_dimensions['width']);