Source
['name' => _('Missing data').'/'._x('Treat as 0', 'missing data function'), 'callback' => 'addOverride', 'args' => ['missingdatafunc', SVG_GRAPH_MISSING_DATA_TREAT_AS_ZERO]],
<?php declare(strict_types = 0);
/*
** 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/>.
**/
namespace Widgets\SvgGraph\Includes;
use CButton,
CButtonIcon,
CSimpleButton,
CDiv,
CList,
CListItem,
CPatternSelect,
CTemplateTag,
CVar,
CWidgetFieldView;
class CWidgetFieldOverrideView extends CWidgetFieldView {
public function __construct(CWidgetFieldOverride $field) {
$this->field = $field;
}
public function getView(): CList {
$view = (new CList())->addClass(ZBX_STYLE_OVERRIDES_LIST);
$i = 0;
foreach ($this->field->getValue() as $override) {
$view->addItem($this->getItemTemplate($override, $i));
$i++;
}
$view->addItem(
(new CDiv(
(new CButton('override_add', _('Add new override')))
->setId('override-add')
->addClass(ZBX_STYLE_BTN_ALT)
->addClass(ZBX_ICON_PLUS_SMALL)
)),
'overrides-foot'
);
return $view;
}
public function getJavaScript(): string {
return '
// Define it as function to avoid redundancy.
function initializeOverrides() {
jQuery("#overrides .'.ZBX_STYLE_OVERRIDES_OPTIONS_LIST.'").overrides({
add: ".'.ZBX_STYLE_BTN_ALT.'",
options: "input[type=hidden]",
captions: '.json_encode($this->getGraphOverrideOptionNames()).',
makeName: function(option, row_id) {
return "'.$this->field->getName().'[" + row_id + "][" + option + "]";
},
makeOption: function(name) {
return name.match(
/.*\[('.implode('|', $this->field->getOverrideOptions()).')\]/
)[1];
},
override: ".'.ZBX_STYLE_OVERRIDES_LIST_ITEM.'",
overridesList: ".'.ZBX_STYLE_OVERRIDES_LIST.'",
onUpdate: () => widget_svggraph_form.onGraphConfigChange(),
menu: '.json_encode($this->getGraphOverrideMenu()).'
});
}
// Initialize dynamicRows.
jQuery("#overrides")
.dynamicRows({
template: "#overrides-row",
allow_empty: true,
beforeRow: ".overrides-foot",
remove: ".js-remove",
add: "#override-add",
row: ".'.ZBX_STYLE_OVERRIDES_LIST_ITEM.'",
sortable: true,