Source
<?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/>.
**/
class CPieGraphDraw extends CGraphDraw {
const DEFAULT_HEADER_PADDING_TOP = 30;
const GRAPH_WIDTH_MIN = 20;
const GRAPH_HEIGHT_MIN = 20;
private $background;
private $sum;
private $exploderad;
private $exploderad3d;
private $graphheight3d;
private $shiftlegendright;
private $dataFrom;
private $shiftYLegend;
public function __construct($type = GRAPH_TYPE_PIE) {
parent::__construct($type);
$this->background = false;
$this->sum = false;
$this->exploderad = 1;
$this->exploderad3d = 3;
$this->graphheight3d = 12;
$this->shiftlegendright = 17 * 7 + 7 + 10; // count of static chars * px/char + for color rectangle + space
}
/********************************************************************************************************/
/* PRE CONFIG: ADD / SET / APPLY
/********************************************************************************************************/
public function addItem($itemid, bool $resolve_macros, $calc_fnc = CALC_FNC_AVG, $color = null, $type = null) {
$items = API::Item()->get([
'output' => ['itemid', 'hostid', $resolve_macros ? 'name_resolved' : 'name', 'key_', 'units', 'value_type',
'valuemapid', 'history', 'trends'
],
'itemids' => [$itemid],
'webitems' => true
]);
if ($resolve_macros) {
$items = CArrayHelper::renameObjectsKeys($items, ['name_resolved' => 'name']);
}
if (!$items) {
$items = API::ItemPrototype()->get([
'output' => ['itemid', 'hostid', 'name', 'key_', 'units', 'value_type', 'valuemapid', 'history',
'trends'
],