Source
if ($graph_dims['graphtype'] == GRAPH_TYPE_PIE || $graph_dims['graphtype'] == GRAPH_TYPE_EXPLODED) {
<?php
/*
** Zabbix
** Copyright (C) 2001-2022 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
class CControllerWidgetGraphView extends CControllerWidget {
public function __construct() {
parent::__construct();
$this->setType(WIDGET_GRAPH);
$this->setValidationRules([
'name' => 'string',
'edit_mode' => 'in 0,1',
'dashboardid' => 'db dashboard.dashboardid',
'fields' => 'json',
'dynamic_hostid' => 'db hosts.hostid',
'content_width' => 'int32',
'content_height' => 'int32'
]);
}
protected function doAction() {
$fields = $this->getForm()->getFieldsData();
$edit_mode = (int) $this->getInput('edit_mode', 0);
$width = (int) $this->getInput('content_width', 100);
$height = (int) $this->getInput('content_height', 100);
$dynamic_hostid = $this->getInput('dynamic_hostid', 0);
$resourceid = null;
$profileIdx = 'web.dashboard.filter';
$profileIdx2 = $this->getInput('dashboardid', 0);
$is_resource_available = true;
$header_name = $this->getDefaultName();
if ($fields['source_type'] == ZBX_WIDGET_FIELD_RESOURCE_GRAPH && $fields['graphid']) {
$resource_type = SCREEN_RESOURCE_GRAPH;
$resourceid = reset($fields['graphid']);
$graph_dims = getGraphDims($resourceid);
$graph_dims['graphHeight'] = $height;
$graph_dims['width'] = $width;
}
elseif ($fields['source_type'] == ZBX_WIDGET_FIELD_RESOURCE_SIMPLE_GRAPH && $fields['itemid']) {
$resource_type = SCREEN_RESOURCE_SIMPLE_GRAPH;
$resourceid = $fields['itemid'][0];
$graph_dims = getGraphDims();