Source
xxxxxxxxxx
<?php
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
function graphType($type = null) {
$types = [
GRAPH_TYPE_NORMAL => _('Normal'),
GRAPH_TYPE_STACKED => _('Stacked'),
GRAPH_TYPE_PIE => _('Pie'),
GRAPH_TYPE_EXPLODED => _('Exploded')
];
if (is_null($type)) {
return $types;
}
elseif (isset($types[$type])) {
return $types[$type];
}
else {
return _('Unknown');
}
}
function graph_item_drawtypes() {
return [
GRAPH_ITEM_DRAWTYPE_LINE,
GRAPH_ITEM_DRAWTYPE_FILLED_REGION,
GRAPH_ITEM_DRAWTYPE_BOLD_LINE,
GRAPH_ITEM_DRAWTYPE_DOT,
GRAPH_ITEM_DRAWTYPE_DASHED_LINE,
GRAPH_ITEM_DRAWTYPE_GRADIENT_LINE
];
}
function graph_item_drawtype2str($drawtype) {
switch ($drawtype) {
case GRAPH_ITEM_DRAWTYPE_LINE:
return _('Line');
case GRAPH_ITEM_DRAWTYPE_FILLED_REGION:
return _('Filled region');
case GRAPH_ITEM_DRAWTYPE_BOLD_LINE:
return _('Bold line');
case GRAPH_ITEM_DRAWTYPE_DOT:
return _('Dot');
case GRAPH_ITEM_DRAWTYPE_DASHED_LINE:
return _('Dashed line');
case GRAPH_ITEM_DRAWTYPE_GRADIENT_LINE:
return _('Gradient line');
default:
return _('Unknown');
}
}
function getGraphDims($graphid = null) {
$graphDims = [];
$graphDims['shiftYtop'] = CGraphDraw::DEFAULT_HEADER_PADDING_TOP;
if (is_null($graphid)) {
$graphDims['graphHeight'] = 200;
$graphDims['graphtype'] = 0;
if (GRAPH_YAXIS_SIDE_DEFAULT == 0) {
$graphDims['shiftXleft'] = 85;
$graphDims['shiftXright'] = 30;
}
else {
$graphDims['shiftXleft'] = 30;
$graphDims['shiftXright'] = 85;
}
return $graphDims;
}
// Select graph's type and height as well as which Y axes are used by graph items.
$dbGraphs = DBselect(
'SELECT MAX(g.graphtype) AS graphtype,MIN(gi.yaxisside) AS yaxissidel,MAX(gi.yaxisside) AS yaxissider,MAX(g.height) AS height'.
' FROM graphs g,graphs_items gi'.
' WHERE g.graphid='.zbx_dbstr($graphid).
' AND gi.graphid=g.graphid'